Restructure
New Journal entries
Colour tabs update with wind
This commit is contained in:
fraxle
2026-08-31 15:12:45 +01:00
parent 47818fba33
commit 71860b9dd9
40 changed files with 3430 additions and 443 deletions
+49
View File
@@ -0,0 +1,49 @@
// ------------------------------------------------------------------------
// nav-account.js - Wires the "Account" nav dropdown on every static page
// (about.html, faq.html, dashboard.html, etc.) so it behaves exactly like
// the Preact-driven one on the main app (see app.js's Account dropdown):
// - Subscription link points at the manage-billing URL if the visitor
// already has Extra (localStorage sunscope_pro), else the buy URL.
// - Sign in/out reflects the dashboard's own session (api/me.php),
// independent of the Extra flag above.
//
// Plain vanilla JS - these pages have no build step and no framework.
// Expects the markup produced by nav-account-menu() in build.js's
// injectAccountMenu(), or written by hand to match: a toggle link with
// id="nav-account-signinout" for the Sign in/out item.
// ------------------------------------------------------------------------
(function () {
const SUBSCRIBE_URL = 'https://buy.stripe.com/9B63cw7vl8k15Ei9DQd7q00';
const MANAGE_URL = 'https://billing.stripe.com/p/login/9B63cw7vl8k15Ei9DQd7q00';
const subLink = document.getElementById('nav-account-subscription');
if (subLink) {
subLink.href = localStorage.getItem('sunscope_pro') === '1' ? MANAGE_URL : SUBSCRIBE_URL;
}
const signLink = document.getElementById('nav-account-signinout');
if (!signLink) return;
function setSignedOut() {
signLink.textContent = 'Sign in';
signLink.href = './dashboard.html';
signLink.onclick = null;
}
function setSignedIn() {
signLink.textContent = 'Sign out';
signLink.href = '#';
signLink.onclick = function (e) {
e.preventDefault();
fetch('./api/logout.php', { method: 'POST', credentials: 'same-origin' })
.then(setSignedOut)
.catch(() => {});
};
}
fetch('./api/me.php', { credentials: 'same-origin' })
.then((r) => r.json())
.then((d) => (d.user ? setSignedIn() : setSignedOut()))
.catch(() => {});
})();