Difference between revisions of "Template:ETH Zurich"
m |
m |
||
Line 18: | Line 18: | ||
var items = $("#contentContainer h2,h3,h4,h5,h6"); | var items = $("#contentContainer h2,h3,h4,h5,h6"); | ||
var cur = 0,next=0; | var cur = 0,next=0; | ||
− | + | var menuText = ""; | |
for (i=1; i<items.length; i++) { | for (i=1; i<items.length; i++) { | ||
next = parseInt(items[i].tagName.substring(1,2)); | next = parseInt(items[i].tagName.substring(1,2)); | ||
if (next > cur) { | if (next > cur) { | ||
− | + | menuText = menuText.concat("<ul>"); | |
− | + | ||
} | } | ||
if (next < cur) { | if (next < cur) { | ||
− | + | menuText = menuText.concat("</ul>"); | |
− | + | ||
} | } | ||
cur = next; | cur = next; | ||
− | + | menuText = menuText.concat("<li>"); | |
+ | menuText = menuText.concat(items[i].textContent); | ||
+ | menuText = menuText.concat("</li>"); | ||
} | } | ||
while (cur > 1) { | while (cur > 1) { | ||
− | + | menuText = menuText.concat("</ul>"); | |
cur = cur - 1; | cur = cur - 1; | ||
} | } | ||
+ | menu.innerHTML += menuText; | ||
}); | }); |
Revision as of 20:53, 16 August 2015