Wweeiiyyiinn (Talk | contribs) m |
Wweeiiyyiinn (Talk | contribs) |
||
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) { |
− | + | $("#mySidenav").remove(); | |
− | + | } else { | |
− | + | 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