Webchance/static/app.js

27 lines
806 B
JavaScript
Raw Normal View History

2024-09-26 16:43:51 +02:00
2024-09-26 17:46:12 +02:00
async function calcChanche() {
const name = document.getElementById("name").value
2024-09-26 16:43:51 +02:00
const chance = document.getElementById("Chance").value
const mult = document.getElementById("Multiplicator").value
2024-09-26 17:46:12 +02:00
const url = "/random?chance="+chance+"&multiplicator="+mult+"&name="+name;
2024-09-26 16:43:51 +02:00
try {
const response = await fetch(url);
const content = await response.text()
document.getElementById("won").innerText=content
2024-09-26 17:46:12 +02:00
getWinners()
} catch (error) {
console.error(error.message);
}
}
async function getWinners() {
const url = "/winners"
try {
const response = await fetch(url);
const content = await response.text()
document.getElementById("winners").innerText=content
2024-09-26 16:43:51 +02:00
} catch (error) {
console.error(error.message);
}
}