SamJoshua's picture
Merge ToolDoc, tool-output and CTT-Bench leaderboards into one tabbed Space
385fef5 verified
Raw History Blame Contribute Delete
1.14 kB
"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();