diff options
author | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-05-01 11:42:55 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-05-01 11:42:55 +0200 |
commit | faa32647ac69305dd2b111ca18b3f7fa2b948a49 (patch) | |
tree | e17631be330ae74b872e53a979dc83691f4f4796 /spec/public/scripts/main.js | |
parent | 00b5adfbf3618639b501d1859f7a023083a4b8c3 (diff) | |
parent | e596d1a65d81a81a54847d90d2d90be3ffbb3d92 (diff) | |
download | scala-faa32647ac69305dd2b111ca18b3f7fa2b948a49.tar.gz scala-faa32647ac69305dd2b111ca18b3f7fa2b948a49.tar.bz2 scala-faa32647ac69305dd2b111ca18b3f7fa2b948a49.zip |
Merge pull request #4480 from retronym/merge/2.11.x-to-2.12.x-20150501
Merge 2.11.x to 2.12.x [ci: last-only]
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"); +}); |