Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
malwaredllc
GitHub Repository: malwaredllc/byob
Path: blob/master/web-gui/buildyourownbotnet/assets/js/codemirror/doc/activebookmark.js
1293 views
1
// Kludge in HTML5 tag recognition in IE8
2
document.createElement("section");
3
document.createElement("article");
4
5
(function() {
6
var pending = false, prevVal = null;
7
8
function updateSoon() {
9
if (!pending) {
10
pending = true;
11
setTimeout(update, 250);
12
}
13
}
14
15
function update() {
16
pending = false;
17
var marks = document.getElementById("nav").getElementsByTagName("a"), found;
18
for (var i = 0; i < marks.length; ++i) {
19
var mark = marks[i], m;
20
if (mark.getAttribute("data-default")) {
21
if (found == null) found = i;
22
} else if (m = mark.href.match(/#(.*)/)) {
23
var ref = document.getElementById(m[1]);
24
if (ref && ref.getBoundingClientRect().top < 50)
25
found = i;
26
}
27
}
28
if (found != null && found != prevVal) {
29
prevVal = found;
30
var lis = document.getElementById("nav").getElementsByTagName("li");
31
for (var i = 0; i < lis.length; ++i) lis[i].className = "";
32
for (var i = 0; i < marks.length; ++i) {
33
if (found == i) {
34
marks[i].className = "active";
35
for (var n = marks[i]; n; n = n.parentNode)
36
if (n.nodeName == "LI") n.className = "active";
37
} else {
38
marks[i].className = "";
39
}
40
}
41
}
42
}
43
44
if (window.addEventListener) {
45
window.addEventListener("scroll", updateSoon);
46
window.addEventListener("load", updateSoon);
47
}
48
})();
49
50