Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
72 lines (72 loc) · 4.26 KB
/
Copy pathindex.html
File metadata and controls
72 lines (72 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
<meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#10162b" media="(prefers-color-scheme: dark)">
<meta name="description" content="Practice in logic and debate on the path of reasoning (Dudra and Tarig).">
<meta name="robots" content="noindex, nofollow, noarchive">
<link rel="icon" href="icons/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="icons/apple-touch-icon.png">
<title>Riglam practice</title>
</head>
<body>
<!--@cover-->
<!--@markup-->
<script>
// A way out of a start that never finishes. If the page still says "Loading." (or that the data could not be loaded) after a while, because
// the scripts or the data did not arrive, offer a plain reload and a reload that first drops the service worker and its cached files. Answers
// and settings are in IndexedDB and localStorage, which this never touches. Inline on purpose: it must run when the app's own script does not.
(function () {
var after = window.__riglamRecoverMs || 12000, t0 = Date.now(), box = null, timer, trouble = "";
// What went wrong, for the note in the panel (and for whoever reads a screenshot of it).
addEventListener("error", function (e) { trouble = String(e.message || "error"); });
addEventListener("unhandledrejection", function (e) { trouble = String((e.reason && e.reason.message) || e.reason || "error"); });
function detail() {
var w = "";
try { w = typeof window.__riglamWaiting === "function" ? window.__riglamWaiting() : ""; } catch (_) {}
var bad = window.__riglamFailed || trouble;
return (w ? "Waiting for " + w + ". " : "The app's own code has not started. ") + (bad ? "Error: " + bad.slice(0, 160) + "." : "");
}
function stuck() {
var s = document.querySelector("#path .pstatus"), t = (s && s.textContent) || "";
return t.indexOf("Loading.") === 0 || t.indexOf("The practice data could not be loaded") === 0;
}
function fresh() {
// Only this app's: the origin may hold other apps (this one can sit under a path), whose workers and offline copies stay.
var scope = new URL("./", document.baseURI).href, jobs = [];
if (navigator.serviceWorker) jobs.push(navigator.serviceWorker.getRegistration(scope).then(function (r) { return r && r.unregister(); }));
if (window.caches) jobs.push(caches.keys().then(function (ks) {
return Promise.all(ks.filter(function (k) { return k.indexOf("workbox-") === 0 && k.slice(-scope.length) === scope; }).map(function (k) { return caches.delete(k); }));
}));
Promise.all(jobs).catch(function () {}).then(function () { location.reload(); });
}
function button(label, run) {
var b = document.createElement("button");
b.type = "button"; b.textContent = label; b.addEventListener("click", run);
b.style.cssText = "height:40px;margin:0 8px 8px 0;padding:0 16px;border:1.5px solid #4d5260;background:#fff;color:#000;font:15px sans-serif";
return b;
}
function show() {
box = document.createElement("div");
box.id = "recover"; box.setAttribute("role", "alert");
box.style.cssText = "position:fixed;left:0;right:0;bottom:0;z-index:40;box-sizing:border-box;padding:12px 16px calc(12px + env(safe-area-inset-bottom,0px));background:#fff;color:#000;border-top:2px solid #4d5260;font:15px/1.4 sans-serif";
var p = document.createElement("p"), d = document.createElement("p"), n = document.createElement("p");
p.style.margin = "0 0 6px"; d.style.cssText = "margin:0 0 10px;font-size:13px"; n.style.cssText = "margin:0;font-size:13px";
p.textContent = "The app is taking longer than usual to start.";
d.textContent = detail();
n.textContent = "Reloading with fresh files keeps your answers and settings; only the saved copy of the app itself is replaced.";
box.append(p, d, button("Reload", function () { location.reload(); }), button("Reload with fresh files", fresh), n);
document.body.append(box);
}
timer = setInterval(function () {
if (stuck()) { if (!box && Date.now() - t0 > after) show(); return; }
clearInterval(timer);
if (box) box.remove();
}, 1000);
})();
</script>
<script type="module" src="/src/entry-pwa.ts"></script>
</body>
</html>