1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

add content_toc

This commit is contained in:
ruanyf 2014-04-22 08:53:02 +08:00
parent efcb935c7e
commit 43e1dfb1ce

View File

@ -115,17 +115,20 @@ function create_page_anchors() {
$('#content h' + i).map(function() { $('#content h' + i).map(function() {
headers.push($(this).text()); headers.push($(this).text());
$(this).addClass(replace_symbols($(this).text())); $(this).addClass(replace_symbols($(this).text()));
this.id = 'h'+1+'-'+replace_symbols($(this).text()); this.id = 'h'+i+'-'+replace_symbols($(this).text());
}); });
// parse and set links between li and h2 if (i === 2){
$('#content ul li').map(function() { var ul_tag = $('#content h1')
for (var j = 0; j < headers.length; j++) { .after(ul)
if (headers[j] === $(this).text()) { .addClass("content-toc")
li_create_linkage($(this), i); .attr('id','content-toc');
} for (var j = 0; j < headers.length; j++) {
} var li_tag = $('<li></li>').text(headers[j]);
}); li_create_linkage(li_tag, i);
ul_tag.prepend(li_tag);
}
}
} }
} }