2023-12-30 15:24:12 +08:00
|
|
|
/*global document */
|
2022-06-23 00:32:51 +08:00
|
|
|
(() => {
|
2023-12-30 15:24:12 +08:00
|
|
|
const source = document.getElementsByClassName('prettyprint source linenums');
|
|
|
|
let i = 0;
|
|
|
|
let lineNumber = 0;
|
|
|
|
let lineId;
|
|
|
|
let lines;
|
|
|
|
let totalLines;
|
|
|
|
let anchorHash;
|
2022-06-23 00:32:51 +08:00
|
|
|
|
2023-12-30 15:24:12 +08:00
|
|
|
if (source && source[0]) {
|
|
|
|
anchorHash = document.location.hash.substring(1);
|
|
|
|
lines = source[0].getElementsByTagName('li');
|
|
|
|
totalLines = lines.length;
|
2022-06-23 00:32:51 +08:00
|
|
|
|
2023-12-30 15:24:12 +08:00
|
|
|
for (; i < totalLines; i++) {
|
|
|
|
lineNumber++;
|
|
|
|
lineId = `line${lineNumber}`;
|
|
|
|
lines[i].id = lineId;
|
|
|
|
if (lineId === anchorHash) {
|
|
|
|
lines[i].className += ' selected';
|
|
|
|
}
|
|
|
|
}
|
2022-06-23 00:32:51 +08:00
|
|
|
}
|
|
|
|
})();
|