Sha256: 53e613c3b6b69264af2ba1eada3eed7d489b5a56d556b82018a4a1170c7f785f

Contents?: true

Size: 1.08 KB

Versions: 136

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

136 entries across 117 versions & 15 rubygems

Version Path
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/guide/fulldoc/html/js/app.js
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/guide/fulldoc/html/js/app.js
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/guide/fulldoc/html/js/app.js
yard-0.9.37 templates/guide/fulldoc/html/js/app.js
kinetic_sdk-5.0.27 gems/yard-0.9.36/templates/guide/fulldoc/html/js/app.js
kinetic_sdk-5.0.26 gems/yard-0.9.36/templates/guide/fulldoc/html/js/app.js
kinetic_sdk-5.0.25 gems/yard-0.9.25/templates/guide/fulldoc/html/js/app.js
kinetic_sdk-5.0.24 gems/yard-0.9.25/templates/guide/fulldoc/html/js/app.js
direct7-0.0.13 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/guide/fulldoc/html/js/app.js
yard-0.9.36 templates/guide/fulldoc/html/js/app.js
yard-0.9.35 templates/guide/fulldoc/html/js/app.js
direct7-0.0.12 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/guide/fulldoc/html/js/app.js
kinetic_sdk-5.0.23 gems/yard-0.9.25/templates/guide/fulldoc/html/js/app.js
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/yard-0.9.34/templates/guide/fulldoc/html/js/app.js
direct7-0.0.11 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/guide/fulldoc/html/js/app.js
kinetic_sdk-5.0.22 gems/yard-0.9.25/templates/guide/fulldoc/html/js/app.js
kinetic_sdk-5.0.21 gems/yard-0.9.25/templates/guide/fulldoc/html/js/app.js
yard-0.9.34 templates/guide/fulldoc/html/js/app.js
yard-0.9.33 templates/guide/fulldoc/html/js/app.js
yard-0.9.32 templates/guide/fulldoc/html/js/app.js