easyappointments/doc/code/js/scripts/linenumber.js

26 lines
674 B
JavaScript
Raw Normal View History

2015-01-22 00:17:16 +02:00
/*global document */
(function() {
2015-01-22 00:17:16 +02:00
var source = document.getElementsByClassName('prettyprint source linenums');
var i = 0;
var lineNumber = 0;
var lineId;
var lines;
var totalLines;
var anchorHash;
if (source && source[0]) {
2015-01-22 00:17:16 +02:00
anchorHash = document.location.hash.substring(1);
lines = source[0].getElementsByTagName('li');
totalLines = lines.length;
2015-01-22 00:17:16 +02:00
for (; i < totalLines; i++) {
lineNumber++;
lineId = 'line' + lineNumber;
lines[i].id = lineId;
if (lineId === anchorHash) {
lines[i].className += ' selected';
}
}
}
})();