Attempt to convert to ES5

This commit is contained in:
alistair3149 2020-02-15 18:01:17 -05:00
commit bfec3c1135
No known key found for this signature in database
GPG key ID: 94D081060FD3DD9C

View file

@ -16,12 +16,12 @@ function SmoothScroll() {
}); });
}; };
for (link in navLinks) { for (link in navLinks) {
if (Object.prototype.hasOwnProperty.call(navLinks, link)) { if (Object.prototype.hasOwnProperty.call(navLinks, link)) {
navLinks[link].addEventListener("click", eventListener); navLinks[link].addEventListener("click", eventListener);
} }
} }
} }
} }
function ScrollSpy() { function ScrollSpy() {
@ -39,35 +39,34 @@ function ScrollSpy() {
node = document.querySelector('a[href * = "'.concat(id, '"]')) node = document.querySelector('a[href * = "'.concat(id, '"]'))
.parentNode, .parentNode,
active = document.querySelector(".active"); active = document.querySelector(".active");
if (active !== null) {
if (active !== null) { active.classList.remove("active");
active.classList.remove("active"); }
} if (node !== null) {
if (node !== null) { node.classList.add("active");
node.classList.add("active"); }
} }
} }
} });
});
} }
function CheckToC() { function CheckToC() {
if (document.getElementById("toc")) { if (document.getElementById("toc")) {
SmoothScroll(); SmoothScroll();
ScrollSpy(); ScrollSpy();
} }
} }
if (document.readyState !== "loading") { if (document.readyState !== "loading") {
CheckToC(); CheckToC();
} else if (document.addEventListener) { } else if (document.addEventListener) {
// All modern browsers to register DOMContentLoaded // All modern browsers to register DOMContentLoaded
document.addEventListener("DOMContentLoaded", CheckToC); document.addEventListener("DOMContentLoaded", CheckToC);
} else { } else {
// Old IE browsers // Old IE browsers
document.attachEvent("onreadystatechange", function() { document.attachEvent("onreadystatechange", function() {
if (document.readyState === "complete") { if (document.readyState === "complete") {
CheckToC(); CheckToC();
} }
}); });
} }