const config = window.STATIC_ROUTE || {}; function lang() { const value = new URLSearchParams(window.location.search).get("lang") || navigator.language || "en"; if (value.startsWith("ar")) return "AR"; if (value.startsWith("tr")) return "TR"; if (value.startsWith("bn")) return "BN"; return "EN"; } function goBack() { if (window.history.length > 1) { window.history.back(); return; } if (window.app && typeof window.app.closePage === "function") { window.app.closePage(); return; } if (window.FlutterPageControl && typeof window.FlutterPageControl.postMessage === "function") { window.FlutterPageControl.postMessage("close_page"); } } function renderRows(rows) { const list = document.getElementById("list"); list.innerHTML = ""; rows.forEach((row) => { const node = document.createElement("div"); node.className = "row"; node.innerHTML = `
`; node.querySelector(".row-title").textContent = row.title; node.querySelector(".row-subtitle").textContent = row.subtitle || ""; node.querySelector(".tag").textContent = row.tag || "Ready"; list.appendChild(node); }); } function init() { document.title = config.title || "Yumi H5"; document.getElementById("title").textContent = config.title || "Yumi H5"; document.getElementById("lang").textContent = lang(); document.getElementById("keyword").placeholder = config.placeholder || "Search"; document.getElementById("empty").textContent = config.empty || "No data"; document.querySelector("[data-action='back']").addEventListener("click", goBack); document.getElementById("search").addEventListener("click", () => { const value = document.getElementById("keyword").value.trim(); const base = config.rows || []; renderRows(value ? base.filter((row) => JSON.stringify(row).toLowerCase().includes(value.toLowerCase())) : base); }); renderRows(config.rows || []); document.getElementById("list").hidden = !(config.rows || []).length; document.getElementById("empty").hidden = (config.rows || []).length > 0; } init();