From 21e84b7a3c45568ae20e4203d8c3036852c6e418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Am=C3=A9lia=20Liao?= Date: Sat, 9 Dec 2023 11:45:17 -0300 Subject: [PATCH] make the icon an sometimes --- support/web/js/equations.ts | 32 ++++++++++++++++---------------- support/web/js/theme.tsx | 28 +++++++++++++++++----------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/support/web/js/equations.ts b/support/web/js/equations.ts index 40ada5919..ba139694c 100644 --- a/support/web/js/equations.ts +++ b/support/web/js/equations.ts @@ -62,22 +62,22 @@ window.addEventListener("DOMContentLoaded", () => { window.addEventListener("hashchange", scrollToHash); function scrollToHash() { - if (window.location.hash != '') { - const id = window.location.hash.slice(1); - // #id doesn't work with numerical IDs - const elem = document.querySelector(`[id="${id}"]`); - if (!(elem instanceof HTMLInputElement)) return; - // If the element is in a commented-out block or a
tag, unhide it - // and scroll to it. - const commentedOut = elem.closest('.commented-out') as HTMLInputElement | null; - if (commentedOut) - commentedOut.style.display = 'revert'; - const details = elem.closest('details') as HTMLInputElement | null; - if (details) - details.setAttribute("open", ""); - if (commentedOut || details) - elem.scrollIntoView(); - } + if (window.location.hash === '') return; + + const id = window.location.hash.slice(1); + // #id doesn't work with numerical IDs + const elem = document.querySelector(`[id="${id}"]`); + if (!(elem instanceof HTMLInputElement)) return; + // If the element is in a commented-out block or a
tag, unhide it + // and scroll to it. + const commentedOut = elem.closest('.commented-out') as HTMLInputElement | null; + if (commentedOut) + commentedOut.style.display = 'revert'; + const details = elem.closest('details') as HTMLInputElement | null; + if (details) + details.setAttribute("open", ""); + if (commentedOut || details) + elem.scrollIntoView(); } export { }; diff --git a/support/web/js/theme.tsx b/support/web/js/theme.tsx index d9f366b8a..319e7bc6f 100644 --- a/support/web/js/theme.tsx +++ b/support/web/js/theme.tsx @@ -1,20 +1,28 @@ import { JSX, type Content } from "./lib/jsx"; import { type Theme, themeSetting, equationSetting, Setting, hiddenCodeSetting, footnoteSetting, serifFontSetting } from "./lib/settings"; +// This is pretty evil, but a loose