shoGambler/templates/link.html

35 lines
No EOL
1.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Link your account</title>
<link rel="stylesheet" href="/static/css/styles.css">
</head>
<body>
<p id="status">Linking your account...</p>
<script>
let status = document.getElementById("status");
let ws = new WebSocket("ws://" + window.location.host + "/api/link");
ws.onmessage = (event) => {
let data = JSON.parse(event.data);
switch (data["type"]) {
case "ping":
ws.send(JSON.stringify({"type": "pong"}));
break;
case "nonce":
status.innerText = "To link your account, type \"!link " + data["nonce"] + "\" in the chat of the stream you are watching";
ws.send(JSON.stringify({"type": "success"}));
break;
case "success":
status.innerText = "Account linked successfully!";
setTimeout(() => {
window.location.href = "/";
}, 1000);
break;
case "error":
status.innerText = "Error linking account: " + data["error"];
break;
}
};
</script>
</body>