aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap2/static/js/autosidebar.js
blob: 2f4a6d2146bda1df2907bbcbfa5bb6d9d385c0d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
jQuery.fn.justtext = function() {
    return $(this).clone()
            .children()
            .remove()
            .end()
            .text();
 
};

$(document).ready(function(){    
   $("h1").each(function(){
        $("#sidebar").append(
            "<h4><a href='#'>"+$(this).justtext()+"</a></h4>"
        );
        ul = $("<ul>");
        $("h2",$(this).parent().parent()).each(function(){
            ul.append(
            "<li><a href='#'>"+$(this).justtext()+"</a></li>"
            );
            subul = $("<ul>");
            $("h3",$(this).parent()).each(function(){
                subul.append(
                "<li><a href='#'>"+$(this).justtext()+"</a></li>"
                );
            });
            ul.append(subul);
        });
        $("#sidebar").append(ul);
   });
});