quatuorbellefeuille.com

Content, build scripts and admin scripts for the Bellefeuille Quartet website.
git clone https://git.kevinlegouguec.net/quatuorbellefeuille.com
Log | Files | Refs

commit 1efc3082a3ec64e71ab4a6b5ed290d9473e77bc9
parent b908b8959658676faff68677d4466d18a141b9f3
Author: Kévin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Tue, 24 Nov 2020 00:53:00 +0100

DTRT when loading a URL with an anchor

Diffstat:
Mactualités.html | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/actualités.html b/actualités.html @@ -224,20 +224,23 @@ </div> <!-- TODO: prevent scroll when clicking on overflowing details --> - <!-- TODO: check URL for anchor and auto-enable --> <script> var detailsStyle = document.createElement('style'); document.head.appendChild(detailsStyle); detailsStyle.sheet.insertRule('.details:not(.active) {display:none}'); + var anchor = document.location.hash; + if (anchor.match(/#concert-[0-9]/)) + document.querySelector(anchor).classList.add('active'); + document.querySelectorAll('.event a').forEach((link) => { - link.onclick = function() { + link.addEventListener('click', function() { var prev = document.querySelector('.details.active'); if (prev) prev.classList.remove('active'); var id = link.attributes['href'].value; document.querySelector(id).classList.add('active'); - } + }); }); </script>