diff options
Diffstat (limited to 'documentation/jsapi/scripts/linenumber.js')
-rw-r--r-- | documentation/jsapi/scripts/linenumber.js | 25 |
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 0000000000..4354785cea --- /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'; + } + } + } +})(); |