Menu
Public repository / ff9da97d52660e56a2e087564bf233f3dcb2dfee
AkurAI-Platform / frontend/app.js
Latest change 4e26cf9997ee91f352c553ce4b9a4c5aa01187a0 - Upgrade AkurAI landing experience by Olafur Bui
const statusEl = document.getElementById("health");
const stateEls = document.querySelectorAll("[data-platform-state]");
const root = document.documentElement;
root.classList.add("js");
function isIcelandic() {
return (root.lang || "is").startsWith("is");
}
function platformText(key) {
const text = {
ok: isIcelandic() ? "í loftinu" : "online",
fail: isIcelandic() ? "óvíst" : "uncertain",
};
return text[key];
}
function setPlatformState(state) {
for (const el of stateEls) {
el.dataset.state = state;
el.textContent = platformText(state);
}
}
async function checkHealth() {
if (!statusEl && !stateEls.length) return;
try {
const res = await fetch("/api/health", { headers: { accept: "application/json" } });
if (!res.ok) throw new Error(`status ${res.status}`);
await res.json();
if (statusEl) {
statusEl.textContent = isIcelandic() ? "AkurAI-síðan er í loftinu" : "Platform page is live";
statusEl.dataset.state = "ok";
}
setPlatformState("ok");
} catch (err) {
if (statusEl) {
statusEl.textContent = isIcelandic() ? "Stöðuathugun mistókst" : "Status check failed";
statusEl.dataset.state = "fail";
}
setPlatformState("fail");
}
}
function cycleControlMap() {
const map = document.querySelector("[data-control-map]");
if (!map || matchMedia("(prefers-reduced-motion: reduce)").matches) return;
const nodes = Array.from(map.querySelectorAll("[data-service]"));
if (!nodes.length) return;
let index = nodes.findIndex((node) => node.classList.contains("is-active"));
if (index < 0) index = 0;
function activate(node) {
for (const item of nodes) item.classList.toggle("is-active", item === node);
}
for (const node of nodes) {
node.addEventListener("mouseenter", () => activate(node));
node.addEventListener("focus", () => activate(node));
}
setInterval(() => {
index = (index + 1) % nodes.length;
activate(nodes[index]);
}, 1800);
}
function setupReveal() {
const revealItems = document.querySelectorAll(".motion-copy, .motion-stage, .cat, .feature, .proof-card, .trust-cell, .cta, .sources-section");
revealItems.forEach((item) => item.setAttribute("data-reveal", ""));
if (!("IntersectionObserver" in window)) {
revealItems.forEach((item) => item.classList.add("is-visible"));
return;
}
const observer = new IntersectionObserver((entries) => {
for (const entry of entries) {
if (entry.isIntersecting) {
entry.target.classList.add("is-visible");
observer.unobserve(entry.target);
}
}
}, { rootMargin: "0px 0px -10% 0px", threshold: 0.12 });
revealItems.forEach((item) => observer.observe(item));
}
checkHealth();
cycleControlMap();
setupReveal();