This commit is contained in:
Clove 2026-06-16 22:26:34 +01:00
parent f18867d890
commit a801609eb9
1 changed files with 20 additions and 0 deletions

View File

@ -52,6 +52,15 @@
var root = document.getElementById("friends-root");
if (!root) return;
// title → URL-safe anchor id, e.g. "Close Friends" -> "close-friends"
function slugify(str) {
return String(str == null ? "" : str)
.toLowerCase()
.trim()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
}
// ---- helpers (mirrors now-playing.js) -------------------------------
function esc(str) {
return String(str == null ? "" : str)
@ -226,6 +235,7 @@
FRIENDS.forEach(function (group) {
var section = document.createElement("section");
section.className = "section";
section.id = slugify(group.title); // anchor target, e.g. #alts
var h2 = document.createElement("h2");
h2.className = "section-title";
@ -256,6 +266,16 @@
root.appendChild(section);
});
// ---- jump to anchor (sections are built after page load) ------------
function scrollToHash() {
var id = (location.hash || "").slice(1);
if (!id) return;
var target = document.getElementById(id);
if (target) target.scrollIntoView();
}
scrollToHash();
window.addEventListener("hashchange", scrollToHash);
// ---- poll live members ----------------------------------------------
if (liveMembers.length) {
setInterval(function () {