diff options
author | elioat <elioat@tilde.institute> | 2025-02-17 15:14:47 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2025-02-17 15:14:47 -0500 |
commit | 05ae7e839729d7615ebf1714d21799a5d9f396eb (patch) | |
tree | f0b1e0041f38151a5c8df4e7a652df462aa4ea9e /html/simple-shape/docs/scripts/linenumber.js | |
parent | ed9c27f9e4cc7eb1327c2fd9c5bb97d55a580e91 (diff) | |
download | tour-05ae7e839729d7615ebf1714d21799a5d9f396eb.tar.gz |
*
Diffstat (limited to 'html/simple-shape/docs/scripts/linenumber.js')
-rw-r--r-- | html/simple-shape/docs/scripts/linenumber.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/html/simple-shape/docs/scripts/linenumber.js b/html/simple-shape/docs/scripts/linenumber.js new file mode 100644 index 0000000..4354785 --- /dev/null +++ b/html/simple-shape/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'; + } + } + } +})(); |