Sha256: 679db48b6f18cd663340612d9daeaa14905921b856d7afa71ca80a03a293e548

Contents?: true

Size: 1.08 KB

Versions: 30

Compression:

Stored size: 1.08 KB

Contents

function generateTOC() {
  if ($('#filecontents').length == 0) return;
  var _toc = $('<ol class="top"></ol>');
  var show = false;
  var toc = _toc;
  var counter = 0;
  var tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
  for (i in tags) { tags[i] = '#filecontents > ' + tags[i] }
  var lastTag = parseInt(tags[0][1]);
  $(tags.join(', ')).each(function() {
    if (this.id == "filecontents") return;
    show = true;
    var thisTag = parseInt(this.tagName[1]);
    if (this.id.length == 0) {
      var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
      if ($('#' + proposedId).length > 0) proposedId += counter++;
      this.id = proposedId;
    }
    if (thisTag > lastTag) { 
      for (var i = 0; i < thisTag - lastTag; i++) { 
        var tmp = $('<ol/>'); toc.append(tmp); toc = tmp; 
      } 
    }
    if (thisTag < lastTag) { 
      for (var i = 0; i < lastTag - thisTag; i++) toc = toc.parent(); 
    }
    toc.append('<li><a href="#' + this.id + '">' + $(this).text() + '</a></li>');
    lastTag = thisTag;
  });
  if (!show) return;
  $('#toc').append()
  $('#toc').append(_toc);
}

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
challah-0.6.2 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.6.1 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.6.0 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.5.4 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.5.3 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.5.2 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.5.1 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.5.0 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.4.1 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.4.0 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.3.5 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.3.4 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.3.3 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.3.2 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.3.1 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.3.0 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.2.1 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
challah-0.2.0 vendor/bundle/gems/yard-0.7.5/templates/guide/fulldoc/html/js/app.js
yard-0.7.5 templates/guide/fulldoc/html/js/app.js
nutshell-crm-0.0.6.alpha vendor/bundle/gems/yard-0.7.4/templates/guide/fulldoc/html/js/app.js