Difference between revisions of "Template:SJTU-BioX-Shanghai/Alpha/Header"

Line 8: Line 8:
 
function toc_loop() {
 
function toc_loop() {
 
   var TOP = window.pageYOffset + 50;
 
   var TOP = window.pageYOffset + 50;
   var headings = $('#toc ~ h2 > span:last-child, #toc ~ h3 > span:last-child');
+
   var headings = $('#toc ~ h2 > span:last-child, #toc ~ h3 > span:last-child');
 
   if (headings.length == 0) return
 
   if (headings.length == 0) return
  
Line 31: Line 31:
 
       var id = a.attributes["href"].value;
 
       var id = a.attributes["href"].value;
 
       var ele = document.getElementById(id.slice(1, id.length));
 
       var ele = document.getElementById(id.slice(1, id.length));
       var top = ele.offsetTop, docEle = document.documentElement
+
       var top = ele.offsetTop, docEle = document.documentElement
       var pageHeight = docEle.offsetHeight, windowHeight = docEle.clientHeight
+
       var pageHeight = docEle.offsetHeight, windowHeight = docEle.clientHeight
  
       if ((pageHeight - top) > windowHeight) setTimeout("scrollBy(0, -20)", 10);
+
       if ((pageHeight - top) > windowHeight) setTimeout ("scrollBy(0, -20)", 10);
 
     }
 
     }
 
   )
 
   )
  
 
   setInterval("toc_loop()", 10);
 
   setInterval("toc_loop()", 10);
}}
+
}
 +
 
 
$(document).ready(init)
 
$(document).ready(init)
 
</script>
 
</script>
 
 
<style>
 
<style>
 
/* test BEGIN */
 
/* test BEGIN */

Revision as of 06:43, 18 August 2015