std-internal-docs/before.html
2025-08-17 15:13:04 +02:00

43 lines
1.6 KiB
HTML

<script type="module">
const selectedTarget =
window.location.pathname.split("/")[1] ?? "x86_64-unknown-linux-gnu";
const info = document.createElement("div");
info.classList.add("_internal-info");
const targets = [
{ value: "x86_64-unknown-linux-gnu", name: "x86-64 GNU/Linux" },
{ value: "x86_64-pc-windows-msvc", name: "x86-64 Windows MSVC" },
{ value: "aarch64-apple-darwin", name: "ARM64 MacOS" },
{ value: "wasm32-unknown-unknown", namr: "WebAssembly (32-bit) unknown-unknown" },
// { value: "wasm32-wasip1", name: "WebAssembly (32-bit) WASIp1" },
{ value: "aarch64-linux-android", name: "ARM64 Android" },
{ value: "aarch64-apple-ios", name: "ARM64 iOS" },
];
info.innerHTML = `
<div>⚠ Internal Docs ⚠</div>
<div>This website was built by <a href="https://github.com/Noratrieb/std-internal-docs">Noratrieb</a></div>
<div>
<div>
<label for="target-select">
Select Target
</label>
</div>
<div>
<select id="target-select">
${targets.map((target) => `<option value="${target.value}"${selectedTarget === target.value ? " selected" : ""}>${target.name}</option>`)}
</select>
</div>
</div>
`;
const elems = document.querySelector(".sidebar-elems");
elems.parentNode.insertBefore(info, elems);
document.getElementById("target-select").addEventListener("change", (e) => {
// not very clever, just change the target at all.
// we could try to substitute the path or something better.
window.location.pathname = `/${e.target.value}/std`;
});
</script>