Fix Two Rivers production age gate
All checks were successful
Build Org Website / build (push) Successful in 44s
All checks were successful
Build Org Website / build (push) Successful in 44s
This commit is contained in:
35
assets/scripts/games/two-rivers/gate.js
Normal file
35
assets/scripts/games/two-rivers/gate.js
Normal file
@@ -0,0 +1,35 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var root = document.querySelector("[data-two-rivers]");
|
||||
if (!root) return;
|
||||
|
||||
var button = root.querySelector("[data-tr-age-confirm]");
|
||||
var ageScreen = root.querySelector("[data-tr-age]");
|
||||
var loading = root.querySelector("[data-tr-loading]");
|
||||
var loadingCopy = root.querySelector("[data-tr-loading-copy]");
|
||||
var AGE_KEY = "zxh_two_rivers_age_gate_v1";
|
||||
|
||||
if (!button || !ageScreen || !loading) return;
|
||||
|
||||
button.addEventListener("click", function () {
|
||||
root.dataset.ageConfirmed = "true";
|
||||
try {
|
||||
localStorage.setItem(AGE_KEY, "true");
|
||||
} catch (_error) {
|
||||
// The module bootstrap can still use the in-page marker when storage is unavailable.
|
||||
}
|
||||
|
||||
ageScreen.hidden = true;
|
||||
loading.hidden = false;
|
||||
if (loadingCopy) loadingCopy.textContent = "Opening the festival…";
|
||||
|
||||
window.setTimeout(function () {
|
||||
if (!loading.hidden && !root.querySelector("[data-tr-menu]:not([hidden])")) {
|
||||
loading.innerHTML = "<div><strong>The festival files did not finish loading.</strong><p>Refresh once to fetch the latest game files. If the problem continues, the deployment is incomplete.</p><button type=\"button\" data-tr-gate-retry>Refresh</button><a href=\"/play/play.html\">Return to the playroom</a></div>";
|
||||
var retry = loading.querySelector("[data-tr-gate-retry]");
|
||||
if (retry) retry.addEventListener("click", function () { location.reload(); });
|
||||
}
|
||||
}, 12000);
|
||||
}, {once: true});
|
||||
}());
|
||||
Reference in New Issue
Block a user