Add getsecret method

This commit is contained in:
Kai Vogelgesang
2020-07-18 02:57:13 +02:00
parent 1138badacc
commit 504b85b7ed
3 changed files with 42 additions and 9 deletions

View File

@@ -24,7 +24,26 @@ Object.defineProperty(String.prototype, 'hashCode', {
}
});
function render_table(data) {
async function get_secret(user) {
const r = await fetch(admin_api_path + 'get_secret', {
method: 'POST',
body: JSON.stringify({
uuid: user.uuid
}),
});
console.log(r);
if (r.status !== 200) {
console.log("oh no");
return;
}
const data = await r.json();
return data[user.uuid]
}
async function render_table(data) {
const users = Object.values(data.users);
const newusername = document.querySelector("#newusername");
@@ -65,9 +84,13 @@ function render_table(data) {
plusbutton = clone.querySelector("#plusbutton")
;
name.innerText = user.name;
cur.innerText = user.score;
max.innerText = user.maxscore;
const secret = await get_secret(user);
name.innerText = user.name;
name.href = `../dealer/${secret}`;
// console.log(secret);
//const button = document.getElementById("plusbutton");