From 67efb771bf08b50300eeda7263dfd150f2736d0e Mon Sep 17 00:00:00 2001 From: Wonderfall Date: Fri, 29 Jul 2022 16:15:27 +0200 Subject: [PATCH] improve js --- assets/js/papermod.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/js/papermod.js b/assets/js/papermod.js index 0f449ed3..2c6874ce 100644 --- a/assets/js/papermod.js +++ b/assets/js/papermod.js @@ -1,7 +1,7 @@ import * as params from '@params'; function scrollToTop() { - var topButton = document.getElementById("top-link"); + const topButton = document.getElementById("top-link"); document.addEventListener('scroll', () => { if (document.body.scrollTop > 600 || document.documentElement.scrollTop > 600) { @@ -15,7 +15,7 @@ function scrollToTop() { } function themeToggle() { - var themeButton = document.getElementById("theme-toggle"); + const themeButton = document.getElementById("theme-toggle"); themeButton.addEventListener("click", () => { if (document.body.className.includes("dark")) { @@ -77,7 +77,7 @@ function showCodeCopyButtons() { } function openToc() { - var toc = document.getElementById("toc"); + const toc = document.getElementById("toc"); if (!toc) return; @@ -87,12 +87,12 @@ function openToc() { } function progressBar() { - var bar = document.getElementById("progressBar"); + const bar = document.getElementById("progressBar"); if (!bar) return; document.addEventListener('scroll', () => { - var scrollPercent = document.documentElement.scrollTop / (document.documentElement.scrollHeight - window.innerHeight) * 100; + let scrollPercent = document.documentElement.scrollTop / (document.documentElement.scrollHeight - window.innerHeight) * 100; if (scrollPercent >= 99) { scrollPercent = 0 }; bar.style.setProperty("--scrollAmount", scrollPercent + '%'); })