diff options
author | elioat <elioat@tilde.institute> | 2025-02-17 09:20:00 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2025-02-17 09:20:00 -0500 |
commit | 7d91eff5fc4245429e60c55b016fe1abeb21c6ac (patch) | |
tree | 0308e19c1a4823bf2df10a84d7ec0fa758daecfe /html/tower/docs/scripts/linenumber.js | |
parent | 86dc7f62ba51d1c9a6a8d943d188c2ddb6efa148 (diff) | |
download | tour-7d91eff5fc4245429e60c55b016fe1abeb21c6ac.tar.gz |
*
Diffstat (limited to 'html/tower/docs/scripts/linenumber.js')
-rw-r--r-- | html/tower/docs/scripts/linenumber.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/html/tower/docs/scripts/linenumber.js b/html/tower/docs/scripts/linenumber.js new file mode 100644 index 0000000..4354785 --- /dev/null +++ b/html/tower/docs/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'; + } + } + } +})(); |