Files
portage-site/site.js
T
Christian 0f429d6b22 Redesign the site and fix the download page
Download page: each card now links to its store listing (Chrome Web
Store, Firefox Add-ons), with the latest unpacked build underneath. The
zip links come from the newest GitHub release by matching "chrome" or
"firefox" in the file name; the old code looked for underscore names
that don't exist, so the buttons only ever opened the release page.
Dropped the .crx/.xpi instructions, which no browser accepts from a
website.

Home page: new hero with a Chrome <-> Firefox transfer strip and the
real 2.1.1 dashboard (light and dark), a three-step "how it works" with
real screens, a bento feature grid, the transfer table and a closing
call to action with store buttons.

Style: same monochrome ink scale, Geist and Geist Mono hosted on the
site (SIL OFL), hairline borders, contrast-checked text pairs, motion
limited to transform/opacity with hover gated to fine pointers and
reduced-motion handling.

Privacy: list everything Portage reads about installed extensions,
note that it stores appearance settings locally, and that cookies are
set again on import. Updated the date.

Adds .assetsignore so wrangler.jsonc and other repo files aren't
published with the site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 04:27:49 -04:00

79 lines
3.9 KiB
JavaScript

/*
Portage by pvrz
https://github.com/pvrzz/Portage/
File Name: site.js
*/
(function () {
const KEY = "portage-site-theme";
const root = document.documentElement;
root.classList.remove("no-js");
const SUN = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4"/></svg>';
const MOON = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>';
function current() { try { return localStorage.getItem(KEY) || "system"; } catch { return "system"; } }
function effective() { const m = current(); return m !== "system" ? m : (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"); }
function setMode(m) { if (m === "system") root.removeAttribute("data-mode"); else root.setAttribute("data-mode", m); try { localStorage.setItem(KEY, m); } catch {} updateIcon(); }
function updateIcon() {
const b = document.getElementById("themeToggle"); if (!b) return;
const dark = effective() === "dark";
b.innerHTML = dark ? SUN : MOON;
b.setAttribute("aria-label", dark ? "Switch to light theme" : "Switch to dark theme");
}
const init = current();
if (init !== "system") root.setAttribute("data-mode", init);
document.addEventListener("DOMContentLoaded", () => {
updateIcon();
const toggle = document.getElementById("themeToggle");
if (toggle) toggle.addEventListener("click", () => setMode(effective() === "dark" ? "light" : "dark"));
const nav = document.querySelector(".nav");
const onScroll = () => { if (nav) nav.classList.toggle("scrolled", window.scrollY > 8); };
onScroll();
window.addEventListener("scroll", onScroll, { passive: true });
const targets = document.querySelectorAll(".reveal, .reveal-group");
if ("IntersectionObserver" in window) {
const obs = new IntersectionObserver((entries) => {
entries.forEach((e) => { if (e.isIntersecting) { e.target.classList.add("in"); obs.unobserve(e.target); } });
}, { threshold: 0.12, rootMargin: "0px 0px -40px 0px" });
targets.forEach((el) => obs.observe(el));
} else {
targets.forEach((el) => el.classList.add("in"));
}
const y = document.getElementById("year");
if (y) y.textContent = new Date().getFullYear();
loadLatestBuild();
});
// Download page: point the "latest build" links at the newest GitHub release's zips.
// Falls back to the releases page if the API is unavailable or an asset is missing.
async function loadLatestBuild() {
const pills = document.querySelectorAll("[data-build-version]");
const links = document.querySelectorAll("[data-build-zip]");
if (!pills.length && !links.length) return;
const setPills = (text, state) => pills.forEach((p) => { p.textContent = text; p.dataset.state = state; });
try {
const res = await fetch("https://api.github.com/repos/pvrzz/Portage/releases/latest", { headers: { Accept: "application/vnd.github+json" } });
if (!res.ok) throw new Error("GitHub API " + res.status);
const rel = await res.json();
const version = ((rel.name || "") + " " + (rel.tag_name || "")).match(/v?\d+\.\d+(\.\d+)?/);
setPills(version ? (version[0].startsWith("v") ? version[0] : "v" + version[0]) : "Latest release", "ready");
const assets = rel.assets || [];
links.forEach((a) => {
const browser = a.dataset.buildZip;
const zip = assets.find((x) => /\.zip$/i.test(x.name) && x.name.toLowerCase().includes(browser));
a.href = zip ? zip.browser_download_url : rel.html_url;
});
} catch (err) {
console.warn("Could not load the latest release:", err);
setPills("Latest release", "ready");
}
}
})();