64 lines
2.1 KiB
JavaScript
64 lines
2.1 KiB
JavaScript
// Check for hash on load.
|
|
|
|
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');
|
|
}
|
|
});
|
|
|
|
// Scroll to search result album
|
|
|
|
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();
|
|
}
|
|
|
|
// Toggle header when clicked
|
|
|
|
function albumHeaderClick(clickevent){
|
|
const albumheader = clickevent.target;
|
|
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;
|
|
}
|
|
}
|
|
|
|
// Fill out form with suggest search result
|
|
function suggestform1(id, desc){
|
|
document.getElementById('connection-1').valueAsNumber = id;
|
|
document.getElementById('connection-1-desc').valueAsNumber = desc;
|
|
document.getElementById('search-input-suggest-1').value = '';
|
|
document.getElementById('search-results-1').replaceChildren();
|
|
}
|
|
|
|
// Mutually exclusive audio playback
|
|
function onlyPlayOneIn(container) {
|
|
container.addEventListener("play", function(event) {
|
|
audio_elements = container.getElementsByTagName("audio")
|
|
for(i=0; i < audio_elements.length; i++) {
|
|
audio_element = audio_elements[i];
|
|
if (audio_element !== event.target) {
|
|
audio_element.pause();
|
|
}
|
|
}
|
|
}, true);
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
onlyPlayOneIn(document.body);
|
|
}); |