]> git.somenet.org - somenet/www-somenet-org.git/blob - theme/static/js/autosidebar.js
content/ntp.md
[somenet/www-somenet-org.git] / theme / static / js / autosidebar.js
1 jQuery.fn.justtext = function() {
2     return $(this).clone()
3             .children()
4             .remove()
5             .end()
6             .text();
7  
8 };
9
10 $(document).ready(function(){
11    $("h1").each(function(){
12         $("#sidebar").append(
13             "<li class=\"nav-header\"><h4>"+$(this).children()[0].justtext()+"</h4></li>"
14         );
15         ul = $("<ul>");
16         $("h2",$(this).parent().parent()).each(function(){
17             ul.append(
18             "<li class=\"nav-header\"><h5>"+$(this).justtext()+"</h5></li>"
19             );
20             subul = $("<ul>");
21             $("h3",$(this).parent()).each(function(){
22                 subul.append(
23                 "<li class=\"nav-header\"><h6>"+$(this).justtext()+"</h6></li>"
24                 );
25             });
26             ul.append(subul);
27         });
28         $("#sidebar").append(ul);
29    });
30 });