shoGambler/templates/index.html

140 lines
5.2 KiB
HTML
Raw Permalink Normal View History

2024-10-20 17:12:11 +01:00
<!DOCTYPE html>
<html lang="en">
<head>
<title>Gamble</title>
<script src="/static/js/jwt.min.js"></script>
</head>
<body>
<p>Shounic's un-styled ultra-ugly gambling site</p>
<p id="unclaimedPoints">Loading...</p>
<p>Click the button to claim unclaimed points</p>
<button id="claimPoints">Claim Points</button>
<p id="pointAmount">Loading...</p>
<p>Here are the current activities:</p>
<ul id="fillIn">
<!-- Fill in the activities here with JavaScript -->
</ul>
<a href="/privacy">Privacy Policy</a>
<a href="/tos">Terms of Service</a>
<script>
async function main() {
function isUserInEU() {
// Updated list of time zones that are in the European Union
const euTimeZones = [
'Europe/Andorra',
'Europe/Belgrade',
'Europe/Berlin',
'Europe/Brussels',
'Europe/Bucharest',
'Europe/Budapest',
'Europe/Copenhagen',
'Europe/Dublin',
'Europe/Helsinki',
'Europe/Kiev',
'Europe/Lisbon',
'Europe/Ljubljana',
'Europe/Madrid',
'Europe/Malta',
'Europe/Monaco',
'Europe/Oslo',
'Europe/Paris',
'Europe/Prague',
'Europe/Rome',
'Europe/San_Marino',
'Europe/Stockholm',
'Europe/Tirane',
'Europe/Vaduz',
'Europe/Vienna',
'Europe/Vilnius',
'Europe/Zurich'
];
// Get the user's time zone
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
// Check if the user's time zone is in the EU list
return euTimeZones.includes(userTimeZone);
}
// Warn EU users that this website is not GDPR-compliant (in the EU)
if (isUserInEU()) {
if (!confirm("This website is not GDPR compliant in the EU (it is in the UK). It is compliant with every clause except the location one. If you use this service from within the EU, you are doing so at your own risk. Do you want to continue?")) {
// Redirect the user to the EU website (haha)
window.location.href = "https://europa.eu/"
}
}
if (localStorage.getItem("accessToken") === null) {
window.location.href = "/login"
}
let fillIn = document.getElementById("fillIn")
await fetch("/api/getPlugins", {
method: "GET",
headers: {
"Authorization": localStorage.getItem("accessToken")
}
}).then(async (response) => {
let data = await response.json()
for (let i = 0; i < data.length; i++) {
let li = document.createElement("li")
let a = document.createElement("a")
a.href = "/" + data[i]["Name"]
a.innerText = data[i]["Name"]
li.appendChild(a)
fillIn.appendChild(li)
}
})
document.getElementById('claimPoints').addEventListener('click', async () => {
let response = await fetch('/api/claimUnclaimedPoints', {
"method": "POST",
"headers": {
"Authorization": localStorage.getItem("accessToken")
}})
if (response.ok) {
alert("Claimed " + data['points'] + " points")
window.location.reload()
} else {
alert("Error claiming points")
}
})
}
async function updatePoints() {
while (true) {
let response = await fetch('/api/getPoints', {
"method": "GET",
"headers": {
"Authorization": localStorage.getItem("accessToken")
}
})
let data = await response.json()
document.getElementById('pointAmount').innerText = "You have " + data['points'] + " points"
response = await fetch('/api/getUnclaimedPoints', {
"method": "GET",
"headers": {
"Authorization": localStorage.getItem("accessToken")
}
})
if (!response.ok) {
document.getElementById('unclaimedPoints').innerText = "Error getting unclaimed points"
return
}
data = await response.json()
document.getElementById('unclaimedPoints').innerText = "You have " + data['points'] + " unclaimed points"
// Wait for a second before updating the points again
await new Promise(r => setTimeout(r, 1000))
}
}
main()
updatePoints()
</script>
</body>