Difference between revisions of "Template:Shanghaitech/js"

m
Line 7: Line 7:
 
function parseContentTitles() {
 
function parseContentTitles() {
 
     titles = document.getElementById("content-block").getElementsByTagName('h2');
 
     titles = document.getElementById("content-block").getElementsByTagName('h2');
     for (var i = 0; i < titles.length; i++) {
+
     if (titles.length === 0) {
        title = titles[i];
+
        $("#mySidenav").remove();
        title.id = title.textContent.replace(/\ /g, '-');
+
    } else {
        createSidenavElement(title);
+
        for (var i = 0; i < titles.length; i++) {
 +
            title = titles[i];
 +
            title.id = title.textContent.replace(/\ /g, '-');
 +
            createSidenavElement(title);
 +
        }
 
     }
 
     }
 
}
 
}
Line 19: Line 23:
 
}
 
}
  
function createSidenav(){
+
function createSidenav() {
 
     $("#mySidenav").remove();
 
     $("#mySidenav").remove();
 
     createEmptySidenav();
 
     createEmptySidenav();

Revision as of 13:41, 29 October 2017