/* * Script modifié de façon mineure par Gnieark http://blog-du-grouik.tinad.fr juin 2012 * (place le sommaire dans le post-content afin de mieux pouvoir le gérer en CSS) * * Script initial par Thomas Muguet: * http://fr.blog.thomasmuguet.info/index.php?post/2011/07/31/Generer-une-table-des-matieres-dans-les-billets-dotclear * */ // Unique ID for each element in TOC var uid=0; // Generate the TOC from an element, at a certain depth function getTOCLevel(from, level) { var content = ''; // Depending on the depth, detect where to stop traversing the DOM var to = (level == 2) ? ".post-content" : "h2"; if (level > 3) {to += " h3";} if (level > 4) {to += " h4";} if (level > 5) {to += " h5";} // Traverse the DOM for all elements $.each(from.nextUntil(to, "h"+level), function() { // Get the title and the UID var title = $(this).text(); var aname = "toc_"+uid; uid++; // Create an anchor so the user can reach the header element $(this).append(''); // Create the TOC entry content += '