Difference between revisions of "Template:ETH Zurich"
m |
m |
||
Line 15: | Line 15: | ||
var menu = document.getElementById('sidemenu'); | var menu = document.getElementById('sidemenu'); | ||
− | + | var items = $("#contentContainer h1,h2,h3,h4,h5,h6"); | |
− | var items = $("#contentContainer h2,h3,h4,h5,h6"); | + | var cur = 0,next=0,count=0; |
− | var cur = 0,next=0; | + | |
var menuText = ""; | var menuText = ""; | ||
− | for (i= | + | for (i=0; 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>"); | menuText = menuText.concat("<ul>"); | ||
+ | count = count + 1; | ||
} | } | ||
if (next < cur) { | if (next < cur) { | ||
menuText = menuText.concat("</ul>"); | menuText = menuText.concat("</ul>"); | ||
+ | count = count - 1; | ||
} | } | ||
Line 34: | Line 35: | ||
} | } | ||
− | while ( | + | while (count) { |
menuText = menuText.concat("</ul>"); | menuText = menuText.concat("</ul>"); | ||
− | + | count = count - 1; | |
} | } | ||
menu.innerHTML += menuText; | menu.innerHTML += menuText; | ||
Line 221: | Line 222: | ||
</div> | </div> | ||
<div id="sidemenu"> | <div id="sidemenu"> | ||
− | |||
</div> | </div> | ||
Revision as of 20:58, 16 August 2015