eorzea-songbook/static/script.js
2023-06-26 23:23:43 +10:00

38 lines
1.2 KiB
JavaScript

window.addEventListener('load', (event) => {
const preclicked = window.location.hash.slice(1);
console.log(preclicked);
if (! preclicked) return;
const radiobutton = document.getElementById(preclicked);
if (radiobutton){
radiobutton.checked = true;
const label = document.getElementById(`${preclicked}_label`);
label.scrollIntoView();
}
});
function albumselect(code){
const radiobutton = document.getElementById(code);
if (radiobutton){
radiobutton.checked = true;
const label = document.getElementById(`${code}_label`);
label.scrollIntoView();
}
document.getElementById('search-input').value = '';
document.getElementById('search-results').innerHTML = '';
};
function albumHeaderClick(clickevent){
const radiobutton = document.getElementById(clickevent.target.htmlFor);
if (radiobutton.checked){
radiobutton.checked = false;
clickevent.preventDefault();
history.replaceState(null, document.title, `${window.location.origin}${window.location.pathname}${window.location.search}`);
}
else{
window.location.hash = radiobutton.id;
const label = clickevent.target;
label.scrollIntoView();
}
};