lthn.io/public/api/js/main.js
Claude 77cc45dd83
feat: lthn.io CorePHP app — TLD website + blockchain services
Modules:
- Chain: daemon RPC client (DaemonRpc singleton, cached queries)
- Explorer: block browser, tx viewer, alias directory, search, stats API
- Names: .lthn TLD registrar portal (availability check, lookup, directory)
- Trade: scaffold (DEX frontend + API)
- Pool: scaffold (mining pool dashboard)

Replaces 5 Node.js containers (5.9GB) with one FrankenPHP app.
Built on CorePHP framework pattern from host.uk.com.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-03 16:13:55 +01:00

53 lines
1.8 KiB
JavaScript

// Light switcher
const lightSwitches = document.querySelectorAll('.light-switch');
if (lightSwitches.length > 0) {
lightSwitches.forEach((lightSwitch, i) => {
if (localStorage.getItem('dark-mode') === 'true') {
// eslint-disable-next-line no-param-reassign
lightSwitch.checked = true;
}
lightSwitch.addEventListener('change', () => {
const { checked } = lightSwitch;
lightSwitches.forEach((el, n) => {
if (n !== i) {
// eslint-disable-next-line no-param-reassign
el.checked = checked;
}
});
if (lightSwitch.checked) {
document.documentElement.classList.add('dark');
localStorage.setItem('dark-mode', true);
} else {
document.documentElement.classList.remove('dark');
localStorage.setItem('dark-mode', false);
}
});
});
}
// Scrollspy
document.addEventListener('DOMContentLoaded', function () {
const targets = document.querySelectorAll('[data-scrollspy-target]');
const links = document.querySelectorAll('[data-scrollspy-link]');
if (links.length < 1) return;
const addActive = (i) => {
const link = links[i] ? links[i] : links[0];
link.classList.add('scrollspy-active');
}
const removeActive = (i) => {
links[i].classList.remove('scrollspy-active');
}
const removeAllActive = () => [...Array(targets.length).keys()].forEach((link) => removeActive(link));
const targetMargin = 100;
let currentActive = 0;
addActive(0);
// listen for scroll events
window.addEventListener('scroll', () => {
const current = targets.length - [...targets].reverse().findIndex((target) => window.scrollY >= target.offsetTop - targetMargin) - 1;
if (current !== currentActive) {
removeAllActive();
currentActive = current;
addActive(current);
}
});
}, false);