CensoredManager/assets/js/activate.js
mctaylors 5f64caf6bc
Initial commit
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
2024-06-06 22:39:59 +05:00

22 lines
No EOL
893 B
JavaScript

const token = docCookies.getItem("token");
const notificationElement = document.getElementById("notification");
const balanceElement = document.getElementById("balance");
window.addEventListener("load", async function () {
balanceElement.innerText = await getBalance(token);
});
document.getElementById("activate-form").addEventListener("submit", async (e) => {
e.preventDefault();
const id = document.getElementById("id").value;
const infoResult = await chequeInfo(id);
const activateResult = await activateCheque(token, id);
if (activateResult !== undefined) {
notificationElement.innerText = `+${infoResult['amount']} coins`;
notificationElement.style.color = "green";
balanceElement.innerText = activateResult;
} else {
notificationElement.innerText = "Incorrect ID!";
notificationElement.style.color = "red";
}
});