-
Notifications
You must be signed in to change notification settings - Fork 355
Expand file tree
/
Copy pathclass_to_source.js
More file actions
22 lines (22 loc) · 898 Bytes
/
class_to_source.js
File metadata and controls
22 lines (22 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function () {
var href = document.location.href;
if (href.indexOf("file:") == 0 || !document.getElementsByTagName) return;
var _old_onload = window.onload;
window.onload = function () {
if (_old_onload) _old_onload.call(this);
_old_onload = null;
var anchors = document.getElementsByTagName('A');
var class_re = /\blines-(\d+)-(\d+)\b/;
var hash_re = /#.*$/;
for (var i = 0; i < anchors.length; i++) {
var anchor = anchors[i];
var found = anchor.className.match(class_re);
if (!found) continue;
href = anchor.href;
var hashidx = href.indexOf("#");
if (hashidx == -1) hashidx = href.length;
anchor.href = (href.substring(0, hashidx) + "?f=" + found[1] +
"&l=" + found[2] + href.substring(hashidx, href.length));
}
}
})();