This commit is contained in:
2025-10-21 22:29:44 +02:00
parent 04891bf449
commit a26c92ff2b
4 changed files with 27 additions and 11 deletions

View File

@@ -13,8 +13,19 @@ document.addEventListener('DOMContentLoaded', () => {
setupEventListeners();
setDefaultDate();
handleRouting();
checkAdminMode();
});
// Admin mode
function checkAdminMode() {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('admin') === 'true') {
document.querySelectorAll('.import-section').forEach(el => {
el.style.display = 'block';
});
}
}
// Routing
function handleRouting() {
// Handle initial load and hash changes
@@ -63,15 +74,17 @@ function initializeTabs() {
});
}
// Set default date to today
// Set default date to yesterday (since we enter steps the day after)
function setDefaultDate() {
const today = new Date().toISOString().split('T')[0];
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
const yesterdayStr = yesterday.toISOString().split('T')[0];
const dateInput = document.getElementById('step-date');
dateInput.value = today;
dateInput.value = yesterdayStr;
// Set max date to October 31, 2025
dateInput.max = '2025-10-31';
dateInput.min = '2025-10-15';
dateInput.min = '2025-10-20';
}
// Load initial data
@@ -832,6 +845,7 @@ async function importMonsters() {
}
const overwrite = overwriteCheckbox.checked;
console.log('Overwrite checkbox checked:', overwrite);
// Confirm if overwrite is selected
if (overwrite) {

View File

@@ -96,13 +96,10 @@
<strong>⏰ Important:</strong> The <strong>"Active Challenge"</strong> shows yesterday's monster.
Log your steps from yesterday to see if your team caught it!
</p>
<p style="margin: 8px 0; line-height: 1.6; font-size: 14px; color: #aaa;">
💡 You can enter steps for any past date, and catches will be updated automatically.
</p>
</div>
<!-- Monster CSV Import Section -->
<div class="import-section">
<div class="import-section" style="display: none;">
<h3>Admin: Import Monsters</h3>
<p class="help-text">Upload CSV with columns: date, monster_name, monster_description, step_goal, monster_icon</p>
<input type="file" id="monster-csv-file" accept=".csv">