71 lines
2.4 KiB
PHP
71 lines
2.4 KiB
PHP
|
|
</main>
|
|
</div>
|
|
<script>
|
|
// Dark Mode Toggle
|
|
const themeBtn = document.getElementById('theme-toggle');
|
|
const iconLight = document.getElementById('theme-icon-light');
|
|
const iconDark = document.getElementById('theme-icon-dark');
|
|
|
|
function updateThemeIcon() {
|
|
if(document.body.classList.contains('dark-mode')) {
|
|
iconLight.style.display = 'block';
|
|
iconDark.style.display = 'none';
|
|
} else {
|
|
iconLight.style.display = 'none';
|
|
iconDark.style.display = 'block';
|
|
}
|
|
}
|
|
|
|
if(themeBtn) {
|
|
updateThemeIcon();
|
|
themeBtn.addEventListener('click', () => {
|
|
document.body.classList.toggle('dark-mode');
|
|
const isDark = document.body.classList.contains('dark-mode');
|
|
localStorage.setItem('theme', isDark ? 'dark' : 'light');
|
|
updateThemeIcon();
|
|
});
|
|
}
|
|
|
|
// Toast Notifier
|
|
function showToast(msg) {
|
|
const t = document.getElementById('toast');
|
|
t.textContent = msg;
|
|
t.classList.add('show');
|
|
setTimeout(() => t.classList.remove('show'), 3000);
|
|
}
|
|
|
|
// User dropdown
|
|
function toggleUserDropdown() {
|
|
const menu = document.getElementById('user-dropdown-menu');
|
|
menu.classList.toggle('open');
|
|
}
|
|
function closeUserDropdown() {
|
|
const menu = document.getElementById('user-dropdown-menu');
|
|
if(menu) menu.classList.remove('open');
|
|
}
|
|
document.addEventListener('click', (e) => {
|
|
const wrap = document.getElementById('user-dropdown-wrap');
|
|
if (wrap && !wrap.contains(e.target)) closeUserDropdown();
|
|
});
|
|
|
|
// Close modals on overlay click
|
|
document.querySelectorAll('.modal-overlay').forEach(mo => {
|
|
mo.addEventListener('click', (e) => {
|
|
if (e.target === mo) mo.classList.remove('active');
|
|
});
|
|
});
|
|
|
|
// Auto open change-pw modal if there was a pw msg
|
|
<?php
|
|
$pw_msg_bottom = $_SESSION['pw_change_msg_bottom'] ?? null;
|
|
if($pw_msg_bottom):
|
|
?>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
document.getElementById('change-pw-modal').classList.add('active');
|
|
});
|
|
<?php endif; ?>
|
|
</script>
|
|
</body>
|
|
</html>
|