-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
80 lines (79 loc) · 3.03 KB
/
Copy pathindex.html
File metadata and controls
80 lines (79 loc) · 3.03 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
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Architect as a Service</title>
<style>
:root { color-scheme: dark; }
body {
font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
background: #0d1117; color: #e6edf3; margin: 0;
display: grid; place-items: center; min-height: 100vh;
}
main { width: min(680px, 92vw); text-align: center; }
h1 { font-size: 1.4rem; color: #58a6ff; margin-bottom: .25rem; }
p.sub { color: #8b949e; margin-top: 0; }
#card {
background: #161b22; border: 1px solid #30363d; border-radius: 12px;
padding: 2rem; margin: 1.5rem 0; min-height: 3rem;
display: grid; place-items: center; font-size: 1.5rem;
}
#status { color: #8b949e; font-size: .85rem; letter-spacing: .1em; text-transform: uppercase; }
.row { display: flex; gap: .6rem; justify-content: center; align-items: center; }
button {
background: #238636; color: #fff; border: 0; border-radius: 8px;
padding: .7rem 1.4rem; font-size: 1rem; cursor: pointer; font-family: inherit;
}
button:hover { background: #2ea043; }
.lang { background: #21262d; padding: .5rem .9rem; }
.lang.active { background: #1f6feb; }
code { background: #161b22; padding: .15rem .4rem; border-radius: 5px; color: #79c0ff; }
footer { margin-top: 2rem; color: #8b949e; font-size: .8rem; }
</style>
</head>
<body>
<main>
<h1>🏗️ Architect as a Service</h1>
<p class="sub" id="sub">Co teraz powie Architekt?</p>
<div id="card">…</div>
<div id="status"></div>
<p class="row">
<button class="lang active" data-lang="pl">PL</button>
<button class="lang" data-lang="en">EN</button>
<button id="btn">Ask</button>
</p>
<footer>
Static API: <code>GET responses.json</code> — client-side random.<br/>
Real random GET? Deploy <code>worker.js</code> to Cloudflare Workers (<code>?lang=en</code>).
</footer>
</main>
<script>
let pool = [];
let lang = "pl";
const SUB = { pl: "Co teraz powie Architekt?", en: "What will the Architect say now?" };
async function load() {
const res = await fetch("./responses.json", { cache: "no-store" });
pool = (await res.json()).responses;
ask();
}
function ask() {
if (!pool.length) return;
const r = pool[Math.floor(Math.random() * pool.length)];
document.getElementById("card").textContent = '"' + r[lang] + '"';
document.getElementById("status").textContent = r.status;
}
document.getElementById("btn").addEventListener("click", ask);
document.querySelectorAll(".lang").forEach((b) => {
b.addEventListener("click", () => {
lang = b.dataset.lang;
document.querySelectorAll(".lang").forEach((x) => x.classList.toggle("active", x === b));
document.documentElement.lang = lang;
document.getElementById("sub").textContent = SUB[lang];
ask();
});
});
load();
</script>
</body>
</html>