diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-04-27 07:34:25 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-04-27 07:34:25 -0700 |
commit | eeba018f27487e161de93d93c01cb8b2d8132f8f (patch) | |
tree | be200de3f3e5a87ad78c6938bee453f7a8fb7607 /spec/public/scripts/main.js | |
parent | 48f4a99fc7c0c6d14e7bb1ec3dcca88e3ff0b121 (diff) | |
parent | 62db8d98559766c06d490d9d4c18ff27587fde0b (diff) | |
download | scala-eeba018f27487e161de93d93c01cb8b2d8132f8f.tar.gz scala-eeba018f27487e161de93d93c01cb8b2d8132f8f.tar.bz2 scala-eeba018f27487e161de93d93c01cb8b2d8132f8f.zip |
Merge pull request #4404 from soc/topic/spec
Spec improvements
Diffstat (limited to 'spec/public/scripts/main.js')
-rw-r--r-- | spec/public/scripts/main.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/public/scripts/main.js b/spec/public/scripts/main.js new file mode 100644 index 0000000000..f0509aba41 --- /dev/null +++ b/spec/public/scripts/main.js @@ -0,0 +1,57 @@ +function currentChapter() { + var path = document.location.pathname; + var idx = path.lastIndexOf("/") + 1; + var chap = path.substring(idx, idx + 2); + return parseInt(chap, 10); +} + +function heading(i, heading, $heading) { + var currentLevel = parseInt(heading.tagName.substring(1)); + var result = ""; + if (currentLevel === this.headerLevel) { + this.headerCounts[this.headerLevel] += 1; + return "" + this.headerCounts[this.headerLevel] + " " + $heading.text(); + } else if (currentLevel < this.headerLevel) { + while(currentLevel < this.headerLevel) { + this.headerCounts[this.headerLevel] = 1; + this.headerLevel -= 1; + } + this.headerCounts[this.headerLevel] += 1; + return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text(); + } else { + while(currentLevel > this.headerLevel) { + this.headerLevel += 1; + this.headerCounts[this.headerLevel] = 1; + } + return "" + this.headerCounts[this.headerLevel]+ " " + $heading.text(); + } +} + +$('#toc').toc( + { + 'selectors': 'h1,h2,h3', + 'smoothScrolling': false, + 'chapter': currentChapter(), + 'headerLevel': 1, + 'headerCounts': [-1, currentChapter() - 1, 1, 1], + 'headerText': heading + } +); + +// no language auto-detect so that EBNF isn't detected as scala +hljs.configure({ + languages: [] +}); + +// syntax highlighting after mathjax is loaded so that mathjax can be used in code blocks +MathJax.Hub.Queue(function () { + hljs.initHighlighting(); + $("pre nobr").addClass("fixws"); +}) + +$("#chapters a").each(function (index) { + if (document.location.pathname.endsWith($(this).attr("href"))) + $(this).addClass("chapter-active"); + else + $(this).removeClass("chapter-active"); +}); |