-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
40 lines (40 loc) · 1.58 KB
/
Copy pathadmin.html
File metadata and controls
40 lines (40 loc) · 1.58 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>DTES Admin</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<style>body{font-family:Arial;padding:20px}textarea{width:100%;height:60vh;font-family:monospace}</style>
</head>
<body>
<h2>DTES Resources Admin</h2>
<p>Load current JSON, edit, and save. Use server with <code>UPDATE_TOKEN</code>.</p>
<label>Token: <input id="token" type="password" /></label>
<button id="load">Load</button>
<button id="save">Save</button>
<p><small>Make edits here carefully — this overwrites dtes-resources.json on your server.</small></p>
<textarea id="json"></textarea>
<script>
document.getElementById('load').onclick = async () => {
const resp = await fetch('/dtes-resources.json');
if(!resp.ok){ alert('Load failed'); return; }
const txt = await resp.text();
document.getElementById('json').value = txt;
};
document.getElementById('save').onclick = async () => {
const token = document.getElementById('token').value;
if(!token) return alert('Enter token');
let data;
try { data = JSON.parse(document.getElementById('json').value); } catch(e) { return alert('Invalid JSON'); }
const res = await fetch('/update-resources', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-update-token': token },
body: JSON.stringify(data)
});
const j = await res.json();
if(res.ok) alert('Saved: ' + JSON.stringify(j));
else alert('Error: ' + JSON.stringify(j));
};
</script>
</body>
</html>