diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/concerts.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/concerts.js b/scripts/concerts.js new file mode 100644 index 0000000..fb45819 --- /dev/null +++ b/scripts/concerts.js @@ -0,0 +1,34 @@ +// When JS is enabled, hide concert details by default, and allow the +// user to display concerts selectively. +var detailsStyle = document.createElement('style'); +document.head.appendChild(detailsStyle); +detailsStyle.sheet.insertRule('.details:not(.active) {display:none}'); + +var pHint = document.querySelector('p.hint'); + +var anchor = document.location.hash; +if (anchor.match(/#concert-/)) { + document.querySelector(anchor).classList.add('active'); + document.querySelector(`a[href="${document.location.hash}"]`).parentNode + .classList.add('active'); + pHint.style.display = 'none'; +} +document.querySelectorAll('a.event').forEach((link) => { + link.addEventListener('click', function(click) { + if (click.ctrlKey || click.shiftKey) + return; + + var prev = document.querySelector('.details.active'); + if (prev) + prev.classList.remove('active'); + var id = link.attributes['href'].value; + document.querySelector(id).classList.add('active'); + + prev = document.querySelector('.eventcontainer.active'); + if (prev) + prev.classList.remove('active'); + link.parentNode.classList.add('active'); + + pHint.style.display = 'none'; + }); +}); |
