You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
document.addEventListener('DOMContentLoaded', () => {
|
|
const aboutLink = document.getElementById('about');
|
|
const controlsLink = document.getElementById('controls');
|
|
|
|
const aboutModal = document.getElementById('about-modal');
|
|
const controlsModal = document.getElementById('controls-modal');
|
|
|
|
const closeButtons = document.querySelectorAll('.close-modal');
|
|
|
|
function showModal(modal) {
|
|
// Hide any other open modals first
|
|
hideAllModals();
|
|
modal.classList.add('show');
|
|
}
|
|
|
|
function hideAllModals() {
|
|
document.querySelectorAll('.modal.show').forEach(m => m.classList.remove('show'));
|
|
}
|
|
|
|
aboutLink.addEventListener('click', (e) => {
|
|
e.stopPropagation();
|
|
showModal(aboutModal);
|
|
});
|
|
|
|
controlsLink.addEventListener('click', (e) => {
|
|
e.stopPropagation();
|
|
showModal(controlsModal);
|
|
});
|
|
|
|
closeButtons.forEach(button => {
|
|
button.addEventListener('click', () => {
|
|
hideAllModals();
|
|
});
|
|
});
|
|
|
|
// Optional: Close modal if clicking outside of it
|
|
document.addEventListener('click', (e) => {
|
|
if (!e.target.closest('.modal')) {
|
|
hideAllModals();
|
|
}
|
|
});
|
|
});
|