-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
171 lines (160 loc) · 4.68 KB
/
Copy pathadmin.html
File metadata and controls
171 lines (160 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TappyYak Admin</title>
<style>
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
body {
min-height: 100vh;
background: #0d1b2a;
display: flex;
align-items: center;
justify-content: center;
font-family: -apple-system, 'Segoe UI', Helvetica, sans-serif;
color: #fff;
}
.panel {
background: rgba(5,15,30,0.95);
border: 1.5px solid rgba(255,255,255,0.13);
border-radius: 20px;
padding: 36px 32px;
width: min(420px, 94vw);
display: flex;
flex-direction: column;
gap: 20px;
}
h1 {
font-size: 1.6rem;
font-weight: 900;
color: #f5c842;
text-align: center;
letter-spacing: 2px;
}
.subtitle {
text-align: center;
color: #888;
font-size: 0.85rem;
margin-top: -12px;
}
label {
font-size: 0.8rem;
color: #aaa;
font-weight: 600;
letter-spacing: 0.5px;
text-transform: uppercase;
}
input[type="password"] {
width: 100%;
padding: 11px 14px;
border-radius: 10px;
border: 2px solid rgba(255,255,255,0.18);
background: rgba(255,255,255,0.07);
color: #fff;
font-size: 1rem;
outline: none;
transition: border-color 0.2s;
margin-top: 6px;
}
input[type="password"]:focus { border-color: #f5c842; }
.divider {
border: none;
border-top: 1px solid rgba(255,255,255,0.1);
}
.reset-card {
border: 1px solid rgba(255,255,255,0.1);
border-radius: 12px;
padding: 16px 18px;
display: flex;
flex-direction: column;
gap: 10px;
}
.reset-card h2 {
font-size: 1rem;
font-weight: 800;
color: #fff;
}
.reset-card p {
font-size: 0.8rem;
color: #888;
line-height: 1.4;
}
button {
width: 100%;
padding: 12px;
border: none;
border-radius: 10px;
font-size: 0.95rem;
font-weight: 700;
cursor: pointer;
transition: transform 0.08s, filter 0.15s;
font-family: inherit;
}
button:active { transform: scale(0.97); filter: brightness(0.9); }
.btn-danger {
background: linear-gradient(135deg, #e03030, #a01010);
color: #fff;
}
.btn-warning {
background: linear-gradient(135deg, #e07820, #b04010);
color: #fff;
}
.msg {
text-align: center;
font-size: 0.85rem;
min-height: 1.2em;
font-weight: 600;
}
.msg.ok { color: #6f6; }
.msg.err { color: #f88; }
</style>
</head>
<body>
<div class="panel">
<h1>🦬 TappyYak Admin</h1>
<p class="subtitle">Leaderboard management</p>
<div>
<label>Admin Password</label>
<input type="password" id="pwInput" placeholder="Enter password" autocomplete="current-password">
</div>
<hr class="divider">
<div class="reset-card">
<h2>📅 Reset Today's Scores</h2>
<p>Removes all scores submitted today (Sydney time). All-time scores are kept.</p>
<button class="btn-warning" onclick="reset('today')">Reset Today's Leaderboard</button>
</div>
<div class="reset-card">
<h2>🗑️ Reset All-Time Scores</h2>
<p>Permanently deletes every score ever submitted. This cannot be undone.</p>
<button class="btn-danger" onclick="reset('alltime')">Reset All-Time Leaderboard</button>
</div>
<div class="msg" id="msg"></div>
</div>
<script>
async function reset(type) {
const pw = document.getElementById('pwInput').value.trim();
const msg = document.getElementById('msg');
if (!pw) { msg.className='msg err'; msg.textContent='Enter the admin password first.'; return; }
const label = type === 'today' ? "today's scores" : "ALL scores ever";
if (!confirm(`Are you sure you want to delete ${label}? This cannot be undone.`)) return;
msg.className='msg'; msg.textContent='Working…';
try {
const res = await fetch(`/api/scores?type=${type}&key=${encodeURIComponent(pw)}`, { method: 'DELETE' });
const data = await res.json();
if (!res.ok) throw new Error(data.error || res.status);
msg.className='msg ok';
msg.textContent = type === 'today'
? `✓ Today's scores cleared. ${data.remaining} all-time scores remain.`
: '✓ All scores deleted. Leaderboard is now empty.';
} catch(e) {
msg.className='msg err';
msg.textContent = e.message === 'Unauthorised' ? '✗ Wrong password.' : `✗ Error: ${e.message}`;
}
}
document.getElementById('pwInput').addEventListener('keydown', e => {
if (e.key === 'Enter') document.querySelector('button').focus();
});
</script>
</body>
</html>