Attempt to convert to ES5

This commit is contained in:
alistair3149 2020-02-15 17:52:32 -05:00
parent ed22023fce
commit a40547ec1b
No known key found for this signature in database
GPG key ID: 94D081060FD3DD9C

View file

@ -5,9 +5,10 @@
* Smooth scroll fallback and Scrollspy * Smooth scroll fallback and Scrollspy
*/ */
var SmoothScroll = function SmoothScroll() { function SmoothScroll() {
var navLinks, eventListener, link;
if (!("scrollBehavior" in document.documentElement.style)) { if (!("scrollBehavior" in document.documentElement.style)) {
var navLinks = document.querySelectorAll("#toc a"), navLinks = document.querySelectorAll("#toc a"),
eventListener = function eventListener(e) { eventListener = function eventListener(e) {
e.preventDefault(); e.preventDefault();
e.target.scrollIntoView({ e.target.scrollIntoView({
@ -15,14 +16,14 @@ var SmoothScroll = function SmoothScroll() {
}); });
}; };
for (var 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);
} }
} }
} }
}, },
ScrollSpy = function ScrollSpy() { function ScrollSpy() {
var sections = document.querySelectorAll(".mw-headline"); var sections = document.querySelectorAll(".mw-headline");
window.addEventListener("scroll", function() { window.addEventListener("scroll", function() {
var scrollPos = var scrollPos =
@ -48,13 +49,13 @@ var SmoothScroll = function SmoothScroll() {
} }
} }
}); });
}, },
CheckToC = 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();