document.addEventListener('DOMContentLoaded', function() { const settingsBtn = document.getElementById('settings-btn'); const settingsDropdown = document.getElementById('settings-dropdown'); const backdrop = document.querySelector('.settings-dropdown-backdrop'); const radioInputs = document.querySelectorAll('input[name="file-expiry"]'); function updateRadioButtons() { radioInputs.forEach(input => { const radioDiv = input.nextElementSibling.querySelector('.expiry-radio'); if (input.checked) { radioDiv.innerHTML = '
'; } else { radioDiv.innerHTML = ''; } }); } settingsBtn.addEventListener('click', function(e) { e.stopPropagation(); settingsDropdown.classList.toggle('show'); backdrop.classList.toggle('show'); updateRadioButtons(); }); backdrop.addEventListener('click', function() { settingsDropdown.classList.remove('show'); backdrop.classList.remove('show'); }); radioInputs.forEach(input => { input.addEventListener('change', function() { updateRadioButtons(); localStorage.setItem('preferred-expiry', this.value); }); }); const savedExpiry = localStorage.getItem('preferred-expiry'); if (savedExpiry) { const radioToCheck = document.querySelector(`input[name="file-expiry"][value="${savedExpiry}"]`); if (radioToCheck) { radioToCheck.checked = true; updateRadioButtons(); } } document.addEventListener('keydown', function(e) { if (e.key === 'Escape') { settingsDropdown.classList.remove('show'); backdrop.classList.remove('show'); } }); });