summaryrefslogtreecommitdiffhomepage
path: root/documentation/jsapi/scripts/linenumber.js
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-11-05 09:33:40 +0100
committerJo-Philipp Wich <jo@mein.io>2019-11-05 09:37:52 +0100
commit3942789dc62d6a0e7fcfb0a935bfe5c8d372245b (patch)
tree9ec432a1dc31c7d837575e7989a47d7cca93e86b /documentation/jsapi/scripts/linenumber.js
parent9b92b2c8f9ce69cfe89c231311d37177ecaa8d43 (diff)
documentation: add JS api docs
Signed-off-by: Jo-Philipp Wich <jo@mein.io> (cherry picked from commit d9452d1157aef6b8752fac0f4ed1e0b9221abb31)
Diffstat (limited to 'documentation/jsapi/scripts/linenumber.js')
-rw-r--r--documentation/jsapi/scripts/linenumber.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/documentation/jsapi/scripts/linenumber.js b/documentation/jsapi/scripts/linenumber.js
new file mode 100644
index 000000000..4354785ce
--- /dev/null
+++ b/documentation/jsapi/scripts/linenumber.js
@@ -0,0 +1,25 @@
+/*global document */
+(() => {
+ const source = document.getElementsByClassName('prettyprint source linenums');
+ let i = 0;
+ let lineNumber = 0;
+ let lineId;
+ let lines;
+ let totalLines;
+ let anchorHash;
+
+ if (source && source[0]) {
+ anchorHash = document.location.hash.substring(1);
+ lines = source[0].getElementsByTagName('li');
+ totalLines = lines.length;
+
+ for (; i < totalLines; i++) {
+ lineNumber++;
+ lineId = `line${lineNumber}`;
+ lines[i].id = lineId;
+ if (lineId === anchorHash) {
+ lines[i].className += ' selected';
+ }
+ }
+ }
+})();