This repository has been archived on 2025-11-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
lan-web/static/theme/LCARS/assets/lcars.js
2025-09-16 09:25:23 +02:00

50 lines
1.6 KiB
JavaScript

document.addEventListener("touchstart", function() {},false);
let mybutton = document.getElementById("topBtn");
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 200 || document.documentElement.scrollTop > 200) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
function playSoundAndRedirect(audioId, url) {
var audio = document.getElementById(audioId);
audio.play();
audio.onended = function() {
window.location.href = url;
};
}
function goToAnchor(anchorId) {
window.location.hash = anchorId;
}
// Accordion drop-down
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var accordionContent = this.nextElementSibling;
if (accordionContent.style.maxHeight){
accordionContent.style.maxHeight = null;
} else {
accordionContent.style.maxHeight = accordionContent.scrollHeight + "px";
}
});
}
// LCARS keystroke sound (not to be used with hyperlinks)
const LCARSkeystroke = document.getElementById('LCARSkeystroke');
const allPlaySoundButtons = document.querySelectorAll('.playSoundButton');
allPlaySoundButtons.forEach(button => {
button.addEventListener('click', function() {
LCARSkeystroke.pause();
LCARSkeystroke.currentTime = 0; // Reset to the beginning of the sound
LCARSkeystroke.play();
});
});