Spaces:
Running
Running
File size: 1,135 Bytes
385fef5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | "use strict";
// Top-level tabs. Each benchmark is a self-contained static app in its own folder,
// loaded in a same-origin iframe so its own CSS, JS and #hash tabs keep working unchanged.
// Deep links: #tooldoc, #tooldoc:explorer, #tool-output, #ctt, #ctt:article, #about
const APPS = { "tooldoc": "tooldoc/index.html", "tool-output": "tool-output/index.html", "ctt": "ctt/index.html" };
const frame = document.getElementById("app");
const about = document.getElementById("about");
function route() {
const [app, sub] = (location.hash.slice(1) || "tooldoc").split(":");
const key = app in APPS || app === "about" ? app : "tooldoc";
document.querySelectorAll(".shell-tabs a").forEach((a) => a.setAttribute("aria-selected", a.dataset.app === key));
if (key === "about") { frame.hidden = true; about.hidden = false; return; }
about.hidden = true; frame.hidden = false;
let src = APPS[key];
if (key === "ctt" && sub === "article") src = "ctt/article.html";
else if (sub) src += "#" + sub;
if (frame.getAttribute("src") !== src) frame.setAttribute("src", src);
}
window.addEventListener("hashchange", route);
route();
|