UNPKG

674 BJavaScriptView Raw
1/*global document */
2(function() {
3 var source = document.getElementsByClassName('prettyprint source linenums');
4 var i = 0;
5 var lineNumber = 0;
6 var lineId;
7 var lines;
8 var totalLines;
9 var anchorHash;
10
11 if (source && source[0]) {
12 anchorHash = document.location.hash.substring(1);
13 lines = source[0].getElementsByTagName('li');
14 totalLines = lines.length;
15
16 for (; i < totalLines; i++) {
17 lineNumber++;
18 lineId = 'line' + lineNumber;
19 lines[i].id = lineId;
20 if (lineId === anchorHash) {
21 lines[i].className += ' selected';
22 }
23 }
24 }
25})();