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

Line 1: Line 1:
 
var pages = {
 
var pages = {
 
     "Home": { "url": "1" },
 
     "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" },
+
     "Description": { "url": "../html/Projects/Description.html" },
     "Design": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Projects/Design.html&action=raw&ctype=text/html" },
+
     "Design": { "url": "../html/Projects/Design.html" },
     "Feature": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Projects/Feature.html&action=raw&ctype=text/html" },
+
     "Feature": { "url": "../html/Projects/Feature.html" },
     "Techniques": { "url": "" },
+
     "Techniques": { "url": "../html/Projects/Techniques.html" },
     "Validation": { "url": "" },
+
     "Validation": { "url": "../html/Projects/Validation.html" },
 
     "Demo": { "url": "" },
 
     "Demo": { "url": "" },
     "Modeling-Overview": { "url": "" },
+
    "Contribution": {"url": "../html/Projects/Contribution.html"},
     "Searching-Engine": { "url": "" },
+
    "Improve": {"url": "../html/Projects/Improve.html"},
     "Simulation-Circuits": { "url": "" },
+
    "Demostrate": {"url": ""},
     "Evolution-Algorithm": { "url": "" },
+
     "Modeling-Overview": { "url": "../html/Modeling/ModelingOverview.html" },
 +
     "Recommendation": { "url": "../html/Modeling/Recommendation.html" },
 +
     "Simulation-Circuits": { "url": "../html/Modeling/SimulationCircuit.html" },
 +
     "Evolution-Algorithm": { "url": "../html/Modeling/EvolutionAlgorithm.html" },
 
     "Reference": { "url": "" },
 
     "Reference": { "url": "" },
     "HP-Overview": { "url": "" },
+
     "HP-Overview": { "url": "../html/Human_Practice/Overview.html" },
     "HP-Siliver": { "url": "" },
+
     "HP-Siliver": { "url": "../html/Human_Practice/Silver.html" },
     "HP-Gold": { "url": "" },
+
     "HP-Gold": { "url": "../html/Human_Practice/Gold.html" },
     "Human-Practice": { "url": "" },
+
     "Human-Practice": { "url": "../html/Human_Practice/HumanPractice.html" },
     "Public-Engagement": { "url": "" },
+
     "Public-Engagement": { "url": "../html/Human_Practice/PublicEngagement.html" },
     "XMU": { "url": "" },
+
     "XMU": { "url": "../html/Collaboration/XMU.html" },
     "SCUT": { "url": "" },
+
     "SCUT": { "url": "../html/Collaboration/SCUT.html" },
     "WHU": { "url": "" },
+
     "WHU": { "url": "../html/Collaboration/WHU.html" },
     "SYSU": { "url": "" },
+
     "SYSU": { "url": "../html/Collaboration/SYSU.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" },
+
     "I-Overview": { "url": "../html/Interlab/Overview.html" },
     "Experiment": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Interlab/Results.html&action=raw&ctype=text/html" },
+
     "Experiment": { "url": "../html/Interlab/ExperimentDesign.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" },
+
     "Material-Methods": { "url": "../html/Interlab/MaterialMethods.html" },
     "Results": { "url": "https://2018.igem.org/wiki/index.php?title=Template:SYSU-Software/statics/html/Interlab/Results.html&action=raw&ctype=text/html" },
+
     "Results": { "url": "../html/Interlab/Results.html" },
     "Medal-Overview": { "url": "" },
+
    "Wet-Lab": { "url": "../html/Safety/WetLabSafety.html"},
     "Medal-Bronze": { "url": "" },
+
     "Dry-Lab": { "url": "../html/Safety/DryLabSafety.html"},
     "Medal-Sliver": { "url": "" },
+
     "Medal-Overview": { "url": "../html/Medal/Overview.html" },
     "Medal-Gold": { "url": "" },
+
     "Medal-Bronze": { "url": "../html/Medal/Bronze.html" },
     "T-Overview": { "url": "" },
+
     "Medal-Sliver": { "url": "../html/Medal/Silver.html" },
     "Members": { "url": "" },
+
     "Medal-Gold": { "url": "../html/Medal/Gold.html" },
     "Advisors": { "url": "" },
+
     "T-Overview": { "url": "../html/Team/Overview.html" },
     "Instructors": { "url": "" },
+
     "Members": { "url": "../html/Team/TeamMember.html" },
     "Notebook": { "url": "" },
+
     "Advisors": { "url": "../html/Team/Advisor.html" },
     "Notebook": { "url": "" },
+
     "Instructors": { "url": "../html/Team/Instructor.html" },
     "A-Overview": { "url": "" },
+
     "Notebook": { "url": "../html/Team/Notebook.html" },
     "Group": { "url": "" },
+
     "A-Overview": { "url": "../html/Attribution/Overview.html" },
     "Attribution": { "url": "" },
+
     "Group": { "url": "../html/Attribution/GroupStructure.html" },
     "Acknowlegement": { "url": "" }
+
     "Attribution": { "url": "../html/Attribution/Attribution.html" },
 +
     "Acknowlegement": { "url": "../html/Attribution/Acknowledge.html" }
 
}
 
}
  
Line 46: Line 50:
 
var onNextPageShow = false;
 
var onNextPageShow = false;
 
var isAllowNextPage = false;
 
var isAllowNextPage = false;
 +
var scrollLock = false;
 +
var nextPage = 0
  
 
function initTopBar(page) {
 
function initTopBar(page) {
 
     // main menu
 
     // main menu
 +
    if (page === 'Home') {
 +
        $('.text').removeClass('default').addClass('light');
 +
    } else {
 +
        $('.text').removeClass('light').addClass('default');
 +
    }
 
     $('#' + page + '>.page-container')
 
     $('#' + page + '>.page-container')
 +
 
         .visibility({
 
         .visibility({
 
             offset: -5,
 
             offset: -5,
Line 61: Line 73:
 
                         .addClass('light fixed')
 
                         .addClass('light fixed')
 
                         .find('.menu')
 
                         .find('.menu')
                         .removeClass('inverted')
+
                         // .removeClass('inverted')
 
                         ;
 
                         ;
 
                     $('.following .additional.item')
 
                     $('.following .additional.item')
Line 73: Line 85:
 
                         .removeClass('light fixed')
 
                         .removeClass('light fixed')
 
                         .find('.menu')
 
                         .find('.menu')
                         .addClass('inverted')
+
                         // .addClass('inverted')
 
                         .find('.additional.item')
 
                         .find('.additional.item')
 
                         .transition('hide')
 
                         .transition('hide')
 
                         ;
 
                         ;
 
                 });
 
                 });
 +
            }
 +
        });
 +
    $('#' + page + '>.page-container>.next-page-identify')
 +
        .visibility({
 +
            offset: -5,
 +
            observeChanges: true,
 +
            once: false,
 +
            context: $('#' + page),
 +
            continuous: true,
 +
            onTopVisible: function () {
 
             },
 
             },
             onBottomVisible: function () {
+
             onTopVisibleReverse: function () {
                if (onNextPageShow) return;
+
                onNextPageShow = true;
+
                setTimeout(() => {
+
                    isAllowNextPage = true;
+
                    $(".next-page").animate({
+
                        'opacity': '0.8'
+
                    }, 500);
+
                }, 500);
+
            },
+
            onBottomVisibleReverse: function () {
+
                $(".next-page").animate({
+
                    'opacity': '0'
+
                }, 200);
+
                onNextPageShow = false;
+
                isAllowNextPage = false;
+
 
             }
 
             }
 
         });
 
         });
 +
    nextPage = $('#' + page + '>.page-container>.next-page-identify').attr("data-value");
 
}
 
}
 +
 +
 +
 +
  
 
function loadPages() {
 
function loadPages() {
 
     for (let page in pages) {
 
     for (let page in pages) {
 
         pageList.push(page);
 
         pageList.push(page);
         if (pages[page].url === "") continue;
+
    }
 +
    for (let page in pages) {
 +
         if (pages[page].url === "") {
 +
            nowLoadingID += 1;
 +
            continue;
 +
        }
 
         $.get(pages[page].url, function (data) {
 
         $.get(pages[page].url, function (data) {
 
             $('#' + page).html(data);
 
             $('#' + page).html(data);
 
             nowLoadingID += 1;
 
             nowLoadingID += 1;
             initTopBar(page);
+
             //initTopBar(page);
 +
            // console.log(nowLoadingID);
 +
            // console.log(pageList.length);
 +
            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);
 +
                    fkpage.goToSlide(dstPage + 1);
 +
                });
 +
            }
 
         });
 
         });
 
          
 
          

Revision as of 19:55, 14 October 2018

var pages = {

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

}

var pageList = [];

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

function initTopBar(page) {

   // main menu
   if (page === 'Home') {
       $('.text').removeClass('default').addClass('light');
   } else {
       $('.text').removeClass('light').addClass('default');
   }
   $('#' + 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')
                       ;
               });
           }
       });
   $('#' + page + '>.page-container>.next-page-identify')
       .visibility({
           offset: -5,
           observeChanges: true,
           once: false,
           context: $('#' + page),
           continuous: true,
           onTopVisible: function () {
           },
           onTopVisibleReverse: function () {
           }
       });
   nextPage = $('#' + page + '>.page-container>.next-page-identify').attr("data-value");

}



function loadPages() {

   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);
           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);
                   fkpage.goToSlide(dstPage + 1);
               });
           }
       });
       
   }

}

loadPages();

$('.ui.sticky')

   .sticky()
   ;