AkurAI Build
Menu

Public repository / master

AkurAI-Platform / frontend/app.js

Latest change 7c98a6fe64be6cf4971a37c541e219b5dfcd684b - OLI-105: baseline snapshot of live platform.olibuijr.com frontend (source was missing from repo) by DevLead

const statusEl = document.getElementById("health");
const root = document.documentElement;
root.classList.add("js");

async function checkHealth() {
  if (!statusEl) return;

  try {
    const res = await fetch("/api/health", { headers: { accept: "application/json" } });
    if (!res.ok) throw new Error(`status ${res.status}`);
    await res.json();
    statusEl.textContent = "Platform page is live";
    statusEl.dataset.state = "ok";
  } catch {
    statusEl.textContent = "Status check failed";
    statusEl.dataset.state = "fail";
  }
}

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));
}

function setupMotionVideo() {
  const details = document.getElementById("detail");
  if (!details) return;

  const video = details.querySelector(".motion-video");
  if (!video) return;

  details.addEventListener("toggle", () => {
    if (details.open) {
      if (!video.src) video.src = video.dataset.src;
      video.play().catch(() => {});
    } else {
      video.pause();
    }
  });
}

checkHealth();
setupReveal();
setupMotionVideo();