35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
window.addEventListener('load', (event) => {
|
|
const preclicked = window.location.hash.slice(1);
|
|
if (! preclicked) return;
|
|
const albumheader = document.getElementById(preclicked);
|
|
if (albumheader){
|
|
albumheader.classList.add('open');
|
|
albumheader.scrollIntoView();
|
|
}
|
|
});
|
|
|
|
function albumselect(code){
|
|
const albumheader = document.getElementById(code);
|
|
for (const other of document.querySelectorAll('.sort-header.album.open')){
|
|
other.classList.remove('open');
|
|
}
|
|
albumheader.classList.add('open');
|
|
document.getElementById('search-input').value = '';
|
|
document.getElementById('search-results').replaceChildren();
|
|
}
|
|
|
|
function albumHeaderClick(clickevent){
|
|
const albumheader = clickevent.target;
|
|
// console.log(albumheader);
|
|
if (albumheader.classList.contains('open')){
|
|
albumheader.classList.remove('open');
|
|
history.replaceState(null, document.title, `${window.location.origin}${window.location.pathname}${window.location.search}`);
|
|
}
|
|
else{
|
|
for (const other of document.querySelectorAll('.sort-header.album.open')){
|
|
other.classList.remove('open');
|
|
}
|
|
albumheader.classList.add('open');
|
|
window.location.hash = albumheader.id;
|
|
}
|
|
} |