button fixed

This commit is contained in:
nmemmert committed 2025-07-27 22:19:08 +00:00
1 parent b40e5136a1
commit fb879b1a23
3 files changed
+51 -28

No files matched your search

+1 -1
View File
@@ -7,7 +7,6 @@
<link href="styles.css" rel="stylesheet"/>
<!-- Scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsSHA/2.4.2/sha.js"></script>
<script src="js/admin.js"></script>
<script src="js/auth.js"></script>
<script src="js/ui.js"></script>
<script src="js/themes.js"></script>
@@ -454,5 +453,6 @@
}
});
</script>
<script src="js/admin.js"></script>
</body>
</html>
+43 -18
View File
@@ -1,3 +1,18 @@
// Ensure tab event listeners are attached after everything is defined
window.addEventListener('DOMContentLoaded', () => {
setTimeout(() => {
const tabButtons = document.querySelectorAll('#adminTabs button');
tabButtons.forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
const tabId = button.getAttribute('data-tab');
if (tabId && typeof window.switchTab === 'function') {
window.switchTab(tabId);
}
});
});
}, 0);
});
// Global variables for admin functionality
// --- Weeks input logic ---
// Populate active week dropdown from weeksContainer
@@ -104,8 +119,7 @@ window.switchTab = function switchTab(targetId) {
// Highlight the active button
document.querySelectorAll('#adminTabs button').forEach(btn => {
const onclick = btn.getAttribute('onclick');
if (onclick && onclick.includes(targetId)) {
if (btn.getAttribute('data-tab') === targetId) {
btn.classList.add('active');
}
});
@@ -146,6 +160,19 @@ window.switchTab = function switchTab(targetId) {
loadUserDropdowns();
break;
}
// Attach admin tab event listeners after switchTab is defined
window.addEventListener('DOMContentLoaded', () => {
const tabButtons = document.querySelectorAll('#adminTabs button');
tabButtons.forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
const tabId = button.getAttribute('data-tab');
if (tabId) {
window.switchTab(tabId);
}
});
});
});
};
// Load users from server
@@ -753,22 +780,20 @@ function populatePasswordUserDropdown() {
// Add event listeners for admin tabs as backup to onclick
window.addEventListener('DOMContentLoaded', () => {
setTimeout(() => {
const tabButtons = document.querySelectorAll('#adminTabs button');
tabButtons.forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
const tabId = button.getAttribute('data-tab');
if (tabId) {
console.log('Tab clicked:', tabId);
if (typeof window.switchTab === 'function') {
window.switchTab(tabId);
} else {
console.error('switchTab function not available');
}
const tabButtons = document.querySelectorAll('#adminTabs button');
tabButtons.forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
const tabId = button.getAttribute('data-tab');
if (tabId) {
console.log('Tab clicked:', tabId);
if (typeof window.switchTab === 'function') {
window.switchTab(tabId);
} else {
console.error('switchTab function not available');
}
});
}
});
console.log('✅ Tab event listeners added to', tabButtons.length, 'buttons');
}, 500);
});
console.log('✅ Tab event listeners added to', tabButtons.length, 'buttons');
});
+7 -9
View File
@@ -99,15 +99,13 @@ function showAdmin() {
});
// Set default tab to tabWords and enable tab buttons
setTimeout(() => {
document.querySelectorAll('#adminTabs button').forEach(btn => btn.disabled = false);
if (typeof window.switchTab === 'function') {
window.switchTab("tabWords");
console.log("✅ Default tab set to tabWords");
} else {
console.error("switchTab function not available");
}
}, 100);
document.querySelectorAll('#adminTabs button').forEach(btn => btn.disabled = false);
if (typeof window.switchTab === 'function') {
window.switchTab("tabWords");
console.log("✅ Default tab set to tabWords");
} else {
console.error("switchTab function not available");
}
} else {
console.error("Admin panel not found");
}