2024-09-26 21:47:02 +02:00
|
|
|
const LOOSE_MESSAGE = "im sorry, but you lost"
|
|
|
|
const WIN_MESSAGE = "congrats, you win"
|
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 21:47:02 +02:00
|
|
|
const url = "/random?chance=" + chance + "&multiplicator=" + mult + "&name=" + name;
|
2024-09-26 16:43:51 +02:00
|
|
|
try {
|
|
|
|
|
2024-09-26 21:47:02 +02:00
|
|
|
const response = await fetch(url);
|
|
|
|
const content = await response.text()
|
|
|
|
console.log(content);
|
|
|
|
|
|
|
|
if (content == "true") {
|
|
|
|
document.getElementById("won").innerText = WIN_MESSAGE
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.getElementById("won").innerText = LOOSE_MESSAGE
|
|
|
|
}
|
|
|
|
|
|
|
|
getWinners()
|
2024-09-26 17:46:12 +02:00
|
|
|
} catch (error) {
|
2024-09-26 21:47:02 +02:00
|
|
|
console.error(error.message);
|
2024-09-26 17:46:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
async function getWinners() {
|
|
|
|
const url = "/winners"
|
|
|
|
try {
|
2024-09-26 21:47:02 +02:00
|
|
|
const response = await fetch(url);
|
|
|
|
const content = await response.text()
|
2024-09-26 17:46:12 +02:00
|
|
|
|
2024-09-26 21:47:02 +02:00
|
|
|
document.getElementById("winners").innerText = content
|
2024-09-26 16:43:51 +02:00
|
|
|
} catch (error) {
|
2024-09-26 21:47:02 +02:00
|
|
|
console.error(error.message);
|
2024-09-26 16:43:51 +02:00
|
|
|
}
|
|
|
|
}
|