Permalink
Browse files

Do this once, not per section

  • Loading branch information...
1 parent 1d68612 commit abf046c4c6cfac98ed46cbbc424b9a0d9915772c @tmcw tmcw committed May 25, 2011
Showing with 15 additions and 18 deletions.
  1. +15 −18 manual/site.js
View
@@ -9,26 +9,23 @@ $.domReady(function() {
html.id = this.id;
// TODO: free from shackles of jQuery
$(this).hide().after(html);
- /*
- $('h1, h2, h3, h4, h5, h6', html).each(function() {
- this.setAttribute('id', $(this).text().replace(/[\s\W]+/g, '-').toLowerCase());
-
- var para = document.createElement('a'),
- sectionLi = document.createElement('li'),
- sectionA = document.createElement('a');
+ });
+ $('h1, h2, h3, h4, h5, h6').each(function(elem, i, wrapped) {
+ this.setAttribute('id', $(this).text().replace(/[\s\W]+/g, '-').toLowerCase());
- para.innerHTML = '¶'
- para.className = 'para'
- para.href = '#' + this.id;
- sectionA.href = '#' + this.id;
- $(sectionA).text($(this).text());
- sectionLi.className = this.nodeName;
- sectionLi.appendChild(sectionA);
- nav.append(sectionLi);
+ var para = document.createElement('a'),
+ sectionLi = document.createElement('li'),
+ sectionA = document.createElement('a');
- this.appendChild(para);
- });
- */
+ para.innerHTML = '¶'
+ para.className = 'para'
+ para.href = '#' + this.id;
+ sectionA.href = '#' + this.id;
+ $(sectionA).text($(this).text());
+ sectionLi.className = this.nodeName;
+ sectionLi.appendChild(sectionA);
+ nav.append(sectionLi);
+ $(this).append(para);
});
$('.run').each(function() {
eval($(this).text());

0 comments on commit abf046c

Please sign in to comment.