Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +8 -9
templates/index.html
CHANGED
|
@@ -432,18 +432,22 @@
|
|
| 432 |
|
| 433 |
<script>
|
| 434 |
let activeAlertAppId = null;
|
|
|
|
| 435 |
|
| 436 |
setInterval(function () {
|
| 437 |
fetch('/api/alerts')
|
| 438 |
.then(response => response.json())
|
| 439 |
.then(alerts => {
|
| 440 |
-
|
| 441 |
-
|
|
|
|
| 442 |
activeAlertAppId = topAlert.app_id;
|
| 443 |
|
| 444 |
document.getElementById("alertMessage").innerHTML = `<strong>${topAlert.title}</strong> has hit your threshold! Current Price: <b>${topAlert.price}</b>`;
|
| 445 |
document.getElementById("alertLink").href = `https://store.steampowered.com/app/${topAlert.app_id}/`;
|
| 446 |
document.getElementById("alertPopup").style.display = "block";
|
|
|
|
|
|
|
| 447 |
}
|
| 448 |
});
|
| 449 |
}, 4000);
|
|
@@ -451,13 +455,8 @@
|
|
| 451 |
function closePopup() {
|
| 452 |
document.getElementById("alertPopup").style.display = "none";
|
| 453 |
if (activeAlertAppId) {
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
headers: { 'Content-Type': 'application/json' },
|
| 457 |
-
body: JSON.stringify({ app_id: activeAlertAppId })
|
| 458 |
-
}).then(() => {
|
| 459 |
-
window.location.reload();
|
| 460 |
-
});
|
| 461 |
}
|
| 462 |
}
|
| 463 |
</script>
|
|
|
|
| 432 |
|
| 433 |
<script>
|
| 434 |
let activeAlertAppId = null;
|
| 435 |
+
const dismissedAlerts = new Set();
|
| 436 |
|
| 437 |
setInterval(function () {
|
| 438 |
fetch('/api/alerts')
|
| 439 |
.then(response => response.json())
|
| 440 |
.then(alerts => {
|
| 441 |
+
const activeAlerts = alerts.filter(alert => !dismissedAlerts.has(alert.app_id));
|
| 442 |
+
if (activeAlerts.length > 0) {
|
| 443 |
+
let topAlert = activeAlerts[0];
|
| 444 |
activeAlertAppId = topAlert.app_id;
|
| 445 |
|
| 446 |
document.getElementById("alertMessage").innerHTML = `<strong>${topAlert.title}</strong> has hit your threshold! Current Price: <b>${topAlert.price}</b>`;
|
| 447 |
document.getElementById("alertLink").href = `https://store.steampowered.com/app/${topAlert.app_id}/`;
|
| 448 |
document.getElementById("alertPopup").style.display = "block";
|
| 449 |
+
} else {
|
| 450 |
+
document.getElementById("alertPopup").style.display = "none";
|
| 451 |
}
|
| 452 |
});
|
| 453 |
}, 4000);
|
|
|
|
| 455 |
function closePopup() {
|
| 456 |
document.getElementById("alertPopup").style.display = "none";
|
| 457 |
if (activeAlertAppId) {
|
| 458 |
+
dismissedAlerts.add(activeAlertAppId);
|
| 459 |
+
activeAlertAppId = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
}
|
| 461 |
}
|
| 462 |
</script>
|