Skip to content

Commit a70548e

Browse files
added admin panel
1 parent 885d609 commit a70548e

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

app.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,26 @@ function loadLeaderboard() {
7676
tbody.appendChild(row);
7777
});
7878
});
79-
}
79+
}
80+
81+
function checkResults() {
82+
fetch("https://your-glitch-app.glitch.me/check-results", { method: "POST" })
83+
.then(res => res.json())
84+
.then(data => alert(`Updated games: ${data.updatedGames.length}`));
85+
}
86+
87+
function startRound() {
88+
fetch("https://your-glitch-app.glitch.me/start-round", { method: "POST" })
89+
.then(res => res.json())
90+
.then(data => alert(`Started new round with ${data.pairings} games.`));
91+
}
92+
93+
auth.onAuthStateChanged(async (user) => {
94+
if (user) {
95+
const email = user.email;
96+
if (email === "[email protected]") {
97+
document.getElementById("admin-panel").style.display = "block";
98+
}
99+
loadLeaderboard();
100+
}
101+
});

index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ <h2>Leaderboard</h2>
2424
<tr><th>Name</th><th>Score</th></tr>
2525
</thead>
2626
<tbody></tbody>
27-
</table>
27+
</table>
28+
29+
<div id="admin-panel" style="display:none;">
30+
<h2>Admin Panel</h2>
31+
<button onclick="startRound()">Start New Round</button>
32+
<button onclick="checkResults()">Check Results</button>
33+
</div>

0 commit comments

Comments
 (0)