mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
fixed the map, made it so the map is scrollable and synced the timing between the admin page and map page. They now share the same elapsed time. need to fix map css for altering the svg.
Grey = cant click Red = current Green = complete blue = skipped? Need to add Clue page Need to fix Leaderboard.
This commit is contained in:
1 parent
e7ad53643c
commit
16319f1333
14 files changed
+791
-472
No files matched your search
@@ -90,10 +90,12 @@ async function ensureSettingsTableExists() {
|
||||
}
|
||||
|
||||
// Helper function to update hunt active status - ensure it updates all tables
|
||||
async function updateHuntActiveStatus(isActive) {
|
||||
async function updateHuntActiveStatus(isActive, startTime = null) {
|
||||
try {
|
||||
await ensureSettingsTableExists();
|
||||
|
||||
const now = startTime || new Date().toISOString();
|
||||
|
||||
// Update settings table - this is used by many endpoints to check status
|
||||
await run("INSERT OR REPLACE INTO settings (key, value) VALUES (?, ?)", [
|
||||
"hunt_active",
|
||||
@@ -102,7 +104,6 @@ async function updateHuntActiveStatus(isActive) {
|
||||
|
||||
// Update hunt_status table for consistency
|
||||
try {
|
||||
const now = new Date().toISOString();
|
||||
await run(`
|
||||
CREATE TABLE IF NOT EXISTS hunt_status (
|
||||
id INTEGER PRIMARY KEY CHECK (id = 1),
|
||||
@@ -121,11 +122,15 @@ async function updateHuntActiveStatus(isActive) {
|
||||
[isActive ? 1 : 0, isActive ? now : null]
|
||||
);
|
||||
} else {
|
||||
// Update existing record
|
||||
await run(
|
||||
"UPDATE hunt_status SET is_active = ?, start_time = ? WHERE id = 1",
|
||||
[isActive ? 1 : 0, isActive ? now : null]
|
||||
);
|
||||
// Update existing record - but preserve start_time when stopping
|
||||
if (isActive) {
|
||||
await run(
|
||||
"UPDATE hunt_status SET is_active = ?, start_time = ? WHERE id = 1",
|
||||
[1, now]
|
||||
);
|
||||
} else {
|
||||
await run("UPDATE hunt_status SET is_active = ? WHERE id = 1", [0]);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Error updating hunt_status table:", err);
|
||||
@@ -289,7 +294,7 @@ export async function POST(request) {
|
||||
);
|
||||
|
||||
// Update hunt active status to true
|
||||
await updateHuntActiveStatus(true);
|
||||
await updateHuntActiveStatus(true, startTime);
|
||||
|
||||
return Response.json({
|
||||
success: true,
|
||||
@@ -306,10 +311,13 @@ export async function POST(request) {
|
||||
}
|
||||
} else if (action === "stop") {
|
||||
try {
|
||||
// Get current time for the end timestamp
|
||||
const endTime = new Date().toISOString();
|
||||
|
||||
// Update the most recent timer to inactive
|
||||
await run(
|
||||
"UPDATE hunt_timer SET active = 0, end_time = ? WHERE active = 1",
|
||||
[new Date().toISOString()]
|
||||
[endTime]
|
||||
);
|
||||
|
||||
// Update hunt active status to false
|
||||
@@ -318,6 +326,7 @@ export async function POST(request) {
|
||||
return Response.json({
|
||||
success: true,
|
||||
message: "Timer stopped successfully",
|
||||
endTime: endTime,
|
||||
});
|
||||
} catch (dbError) {
|
||||
console.error("Database error stopping timer:", dbError);
|
||||
|
||||
Reference in new issue
Block a user