Difference between revisions of "Template:SYSU-Software/statics/js/loader.js"

Line 44: Line 44:
 
     "Acknowlegement": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Attribution/Acknowledge.html&action=raw&ctype=text/html" }
 
     "Acknowlegement": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Attribution/Acknowledge.html&action=raw&ctype=text/html" }
 
}
 
}
 +
 
var pageList = [];
 
var pageList = [];
  
Line 54: Line 55:
 
function initTopBar(page) {
 
function initTopBar(page) {
 
     // main menu
 
     // main menu
 +
    requestAnimationFrame(function () {
 +
        $('.following.bar')
 +
            .removeClass('light fixed')
 +
            .find('.menu')
 +
            // .addClass('inverted')
 +
            .find('.additional.item')
 +
            .transition('hide')
 +
            ;
 +
    });
 +
    $(".sticky-navigator").addClass('showtext');
 +
    setTimeout(() => {
 +
        $(".sticky-navigator").removeClass('showtext');
 +
    }, 2000);
 
     if (page === 'Home') {
 
     if (page === 'Home') {
 
         $('.text').removeClass('default').addClass('light');
 
         $('.text').removeClass('default').addClass('light');
Line 59: Line 73:
 
         $('.text').removeClass('light').addClass('default');
 
         $('.text').removeClass('light').addClass('default');
 
     }
 
     }
 +
    if ($("#"+page+">.page-container>.next-page-identify").length > 0) {
 +
        $(".nextpage").show();
 +
        $(".nextpage").attr("data-value", $("#" + page + ">.page-container>.next-page-identify").attr("data-value"));
 +
    } else {
 +
        $(".nextpage").hide();
 +
    }
 +
    if ($("#" + page + ">.page-container>.last-page-identify").length > 0) {
 +
        $(".lastpage").show();
 +
        $(".lastpage").attr("data-value", $("#" + page + ">.page-container>.last-page-identify").attr("data-value"));
 +
    } else {
 +
        $(".lastpage").hide();
 +
    }
 +
    $(".top").attr("data-value", page);
 +
 
     $('#' + page + '>.page-container')
 
     $('#' + page + '>.page-container')
  
Line 89: Line 117:
 
                         ;
 
                         ;
 
                 });
 
                 });
            }
 
        });
 
    $('#' + page + '>.page-container>.next-page-identify')
 
        .visibility({
 
            offset: -5,
 
            observeChanges: true,
 
            once: false,
 
            context: $('#' + page),
 
            continuous: true,
 
            onTopVisible: function () {
 
            },
 
            onTopVisibleReverse: function () {
 
 
             }
 
             }
 
         });
 
         });
Line 111: Line 127:
  
 
function loadPages() {
 
function loadPages() {
     $('.page.dimmer').dimmer('show');
+
     $('#page-process').progress({
 +
        percent: 50
 +
    });
 
     for (let page in pages) {
 
     for (let page in pages) {
 
         pageList.push(page);
 
         pageList.push(page);
Line 126: Line 144:
 
             // console.log(nowLoadingID);
 
             // console.log(nowLoadingID);
 
             // console.log(pageList.length);
 
             // console.log(pageList.length);
 +
            $('#page-process').progress({
 +
                percent: parseInt((nowLoadingID + 1) / pageList.length * 50) + 50
 +
            });
 
             if (nowLoadingID + 1 === pageList.length) {
 
             if (nowLoadingID + 1 === pageList.length) {
 
                 // console.log('now mount');
 
                 // console.log('now mount');
Line 136: Line 157:
 
                     });
 
                     });
 
                     // console.log(dstPage);
 
                     // console.log(dstPage);
                     fkpage.goToSlide(dstPage + 1);
+
                     jumpToPage(dstPage + 1);
 
                 });
 
                 });
 
                 let index_map = {
 
                 let index_map = {
Line 193: Line 214:
 
                     $(this).children('.page-container').addClass('test' + temp);
 
                     $(this).children('.page-container').addClass('test' + temp);
 
                 });
 
                 });
                 $('.page.dimmer').dimmer('hide');
+
                 setTimeout(() => {
                // $('#home-video')[0].play();
+
                    $('.page.dimmer').dimmer('hide');
 +
                    $('#home-video')[0].play();
 +
                }, 1000);
 +
               
 
             }
 
             }
 
         });
 
         });
Line 201: Line 225:
 
}
 
}
  
loadPages();
+
// loadPages();
 +
$('page-process').hide();
 +
$('.page.dimmer').dimmer('show');
  
$('.ui.sticky')
+
$('#loading').load(function () {
     .sticky()
+
    $('page-process').show();
     ;
+
     if($('#page-process').attr('data-precent') < 50) {
 +
        $('#page-process').progress({
 +
            percent: 50
 +
        });
 +
     }
 +
   
 +
});

Revision as of 14:46, 17 October 2018

var pages = {

   "Home": { "url": "1" },
   "Description": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Projects/Description.html&action=raw&ctype=text/html" },
   "Design": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Projects/Design.html&action=raw&ctype=text/html" },
   "Feature": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Projects/Feature.html&action=raw&ctype=text/html" },
   "Techniques": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Projects/Techniques.html&action=raw&ctype=text/html" },
   "Validation": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Projects/Validation.html&action=raw&ctype=text/html" },
   "Demo": { "url": "" },
   "Contribution": {"url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Projects/Contribution.html&action=raw&ctype=text/html"},
   "Improve": {"url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Projects/Improve.html&action=raw&ctype=text/html"},
   "Demostrate": {"url": ""},
   "Modeling-Overview": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Modeling/ModelingOverview.html&action=raw&ctype=text/html" },
   "Recommendation": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Modeling/Recommendation.html&action=raw&ctype=text/html" },
   "Simulation-Circuits": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Modeling/SimulationCircuit.html&action=raw&ctype=text/html" },
   "Evolution-Algorithm": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Modeling/EvolutionAlgorithm.html&action=raw&ctype=text/html" },
   "Reference": { "url": "" },
   "HP-Overview": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Human_Practice/Overview.html&action=raw&ctype=text/html" },
   "HP-Siliver": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Human_Practice/Silver.html&action=raw&ctype=text/html" },
   "HP-Gold": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Human_Practice/Gold.html&action=raw&ctype=text/html" },
   "Human-Practice": { "url": "" },
   "Public-Engagement": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Human_Practice/PublicEngagement.html&action=raw&ctype=text/html" },
   "XMU": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Collaboration/XMU.html&action=raw&ctype=text/html" },
   "SCUT": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Collaboration/SCUT.html&action=raw&ctype=text/html" },
   "WHU": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Collaboration/WHU.html&action=raw&ctype=text/html" },
   "SYSU": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Collaboration/SYSU.html&action=raw&ctype=text/html" },
   "I-Overview": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Interlab/Overview.html&action=raw&ctype=text/html" },
   "Experiment": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Interlab/ExperimentDesign.html&action=raw&ctype=text/html" },
   "Material-Methods": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Interlab/MaterialMethods.html&action=raw&ctype=text/html" },
   "Results": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Interlab/Results.html&action=raw&ctype=text/html" },
   "Wet-Lab": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Safety/WetLabSafety.html&action=raw&ctype=text/html"},
   "Dry-Lab": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Safety/DryLabSafety.html&action=raw&ctype=text/html"},
   "Medal-Overview": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Medal/Overview.html&action=raw&ctype=text/html" },
   "Medal-Bronze": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Medal/Bronze.html&action=raw&ctype=text/html" },
   "Medal-Sliver": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Medal/Silver.html&action=raw&ctype=text/html" },
   "Medal-Gold": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Medal/Gold.html&action=raw&ctype=text/html" },
   "T-Overview": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Team/Overview.html&action=raw&ctype=text/html" },
   "Members": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Team/TeamMember.html&action=raw&ctype=text/html" },
   "Advisors": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Team/Advisor.html&action=raw&ctype=text/html" },
   "Instructors": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Team/Instructor.html&action=raw&ctype=text/html" },
   "Notebook": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Team/Notebook.html&action=raw&ctype=text/html" },
   "A-Overview": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Attribution/Overview.html&action=raw&ctype=text/html" },
   "Group": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Attribution/GroupStructure.html&action=raw&ctype=text/html" },
   "Attribution": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Attribution/Attribution.html&action=raw&ctype=text/html" },
   "Acknowlegement": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Attribution/Acknowledge.html&action=raw&ctype=text/html" }

}

var pageList = [];

var nowLoadingID = 0; var onNextPageShow = false; var isAllowNextPage = false; var scrollLock = false; var nextPage = 0

function initTopBar(page) {

   // main menu
   requestAnimationFrame(function () {
       $('.following.bar')
           .removeClass('light fixed')
           .find('.menu')
           // .addClass('inverted')
           .find('.additional.item')
           .transition('hide')
           ;
   });
   $(".sticky-navigator").addClass('showtext');
   setTimeout(() => {
       $(".sticky-navigator").removeClass('showtext');
   }, 2000);
   if (page === 'Home') {
       $('.text').removeClass('default').addClass('light');
   } else {
       $('.text').removeClass('light').addClass('default');
   }
   if ($("#"+page+">.page-container>.next-page-identify").length > 0) {
       $(".nextpage").show();
       $(".nextpage").attr("data-value", $("#" + page + ">.page-container>.next-page-identify").attr("data-value"));
   } else {
       $(".nextpage").hide();
   }
   if ($("#" + page + ">.page-container>.last-page-identify").length > 0) {
       $(".lastpage").show();
       $(".lastpage").attr("data-value", $("#" + page + ">.page-container>.last-page-identify").attr("data-value"));
   } else {
       $(".lastpage").hide();
   }
   $(".top").attr("data-value", page);
   $('#' + page + '>.page-container')
       .visibility({
           offset: -5,
           observeChanges: true,
           once: false,
           context: $('#' + page),
           continuous: true,
           onTopPassed: function () {
               requestAnimationFrame(function () {
                   $('.following.bar')
                       .addClass('light fixed')
                       .find('.menu')
                       // .removeClass('inverted')
                       ;
                   $('.following .additional.item')
                       .transition('scale in', 750)
                       ;
               });
           },
           onTopPassedReverse: function () {
               requestAnimationFrame(function () {
                   $('.following.bar')
                       .removeClass('light fixed')
                       .find('.menu')
                       // .addClass('inverted')
                       .find('.additional.item')
                       .transition('hide')
                       ;
               });
           }
       });
   nextPage = $('#' + page + '>.page-container>.next-page-identify').attr("data-value");

}



function loadPages() {

   $('#page-process').progress({
       percent: 50
   });
   for (let page in pages) {
       pageList.push(page);
   }
   for (let page in pages) {
       if (pages[page].url === "") {
           nowLoadingID += 1;
           continue;
       }
       $.get(pages[page].url, function (data) {
           $('#' + page).html(data);
           nowLoadingID += 1;
           //initTopBar(page);
           // console.log(nowLoadingID);
           // console.log(pageList.length);
           $('#page-process').progress({
               percent: parseInt((nowLoadingID + 1) / pageList.length * 50) + 50
           });
           if (nowLoadingID + 1 === pageList.length) {
               // console.log('now mount');
               $('a').on('click', function() {
                   // console.log('click');
                   let target = $(this).attr('goto');
                   // console.log(target);
                   let dstPage = pageList.findIndex((value, index, arr) => {
                       return value === target;
                   });
                   // console.log(dstPage);
                   jumpToPage(dstPage + 1);
               });
               let index_map = {
                   1: 0,
                   2: 1,
                   3: 1,
                   4: 1,
                   5: 1,
                   6: 1,
                   7: 1,
                   8: 1,
                   9: 1,
                   10: 1,
                   11: 2,
                   12: 2,
                   13: 2,
                   14: 2,
                   15: 2,
                   16: 3,
                   17: 3,
                   18: 3,
                   19: 3,
                   20: 3,
                   21: 4,
                   22: 4,
                   23: 4,
                   24: 4,
                   25: 5,
                   26: 5,
                   27: 5,
                   28: 5,
                   29: 8,  /* Wet-lab */
                   30: 8,  /* Dry-lab */
                   31: 6,
                   32: 6,
                   33: 6,
                   34: 6,
                   35: 7,
                   36: 7,
                   37: 7,
                   38: 7,
                   39: 7,
                   40: 8,
                   41: 8,
                   42: 8,
                   43: 8
               };
               $('.myfkpage').children('li').each(function (index, ele) {
                   let temp = index_map[index];
                   // if (temp === 0) {
                   //     $(this).addClass('noscroll');
                   // } else {
                   //     $(this).addClass('scroll');
                   // }
                   $(this).children('.page-container').addClass('test' + temp);
               });
               setTimeout(() => {
                   $('.page.dimmer').dimmer('hide');
                   $('#home-video')[0].play();
               }, 1000);
               
           }
       });
       
   }

}

// loadPages(); $('page-process').hide(); $('.page.dimmer').dimmer('show');

$('#loading').load(function () {

   $('page-process').show();
   if($('#page-process').attr('data-precent') < 50) {
       $('#page-process').progress({
           percent: 50
       });
   }
   

});