1353 lines
46 KiB
HTML
1353 lines
46 KiB
HTML
<!DOCTYPE html>
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<html lang="en" dir="ltr">
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>VJ PLAYLIST</title>
|
|
|
|
<style>
|
|
#divBody {
|
|
flex-direction: column !important;
|
|
flex-wrap: nowrap !important;
|
|
align-items: center !important;
|
|
justify-content: flex-start !important;
|
|
align-content: flex-start !important;
|
|
gap: 10px;
|
|
overflow-y: auto;
|
|
padding: 10px;
|
|
}
|
|
|
|
#divPlaylistRoot {
|
|
width: min(100%, 1000px);
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
|
|
#divPlaylistControls {
|
|
border: var(--border);
|
|
border-radius: var(--border-radius);
|
|
background: var(--secondary-color);
|
|
padding: 10px;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 8px;
|
|
align-items: center;
|
|
}
|
|
|
|
.playlistControlLabel {
|
|
font-size: 12px;
|
|
color: var(--primary-color);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.04em;
|
|
}
|
|
|
|
#selShowFilter {
|
|
min-width: 260px;
|
|
max-width: 100%;
|
|
padding: 6px 8px;
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 6px;
|
|
background: transparent;
|
|
color: var(--text-color);
|
|
font-family: inherit;
|
|
font-size: 13px;
|
|
}
|
|
|
|
#divPlaylistTarget,
|
|
#divPlaylistStatus,
|
|
#divPlaylistSummary {
|
|
width: min(100%, 1000px);
|
|
color: var(--muted-color);
|
|
font-size: 12px;
|
|
}
|
|
|
|
#divPlaylistEpisodes {
|
|
width: min(100%, 1000px);
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.playlistEpisodeCard {
|
|
border: var(--border);
|
|
border-radius: var(--border-radius);
|
|
background: var(--secondary-color);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.playlistEpisodeSummary {
|
|
padding: 10px;
|
|
cursor: pointer;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
gap: 10px;
|
|
align-items: center;
|
|
list-style: none;
|
|
}
|
|
|
|
.playlistEpisodeSummary::-webkit-details-marker {
|
|
display: none;
|
|
}
|
|
|
|
.playlistEpisodeTitle {
|
|
color: var(--primary-color);
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.playlistEpisodeMeta {
|
|
font-size: 12px;
|
|
color: var(--muted-color);
|
|
text-align: right;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.playlistEpisodeContent {
|
|
border-top: 1px solid var(--border-color);
|
|
padding: 10px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
|
|
.playlistEpisodeDescription {
|
|
color: var(--text-color);
|
|
opacity: 0.85;
|
|
font-size: 13px;
|
|
margin: 0;
|
|
}
|
|
|
|
.playlistTrackTable {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.playlistTrackTable th,
|
|
.playlistTrackTable td {
|
|
border-bottom: 1px solid var(--border-color);
|
|
padding: 6px;
|
|
text-align: left;
|
|
vertical-align: top;
|
|
}
|
|
|
|
.playlistTrackTable th {
|
|
color: var(--primary-color);
|
|
text-transform: uppercase;
|
|
font-size: 11px;
|
|
letter-spacing: 0.03em;
|
|
}
|
|
|
|
.playlistTrackNum,
|
|
.playlistTrackTime {
|
|
font-family: var(--font-family-mono, monospace);
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.playlistEmpty {
|
|
border: var(--border);
|
|
border-radius: var(--border-radius);
|
|
background: var(--secondary-color);
|
|
color: var(--muted-color);
|
|
padding: 14px;
|
|
text-align: center;
|
|
font-size: 13px;
|
|
}
|
|
</style>
|
|
|
|
<link rel="stylesheet" href="./css/client.css" />
|
|
|
|
<!-- Initialize theme BEFORE any components load -->
|
|
<script>
|
|
(function () {
|
|
const savedTheme = localStorage.getItem('theme');
|
|
if (savedTheme === 'dark') {
|
|
document.documentElement.classList.add('dark-mode');
|
|
if (document.body) {
|
|
document.body.classList.add('dark-mode');
|
|
}
|
|
}
|
|
})();
|
|
</script>
|
|
<link rel="shortcut icon" type="image/x-icon" href="./favicon/favicon-dots2.ico" />
|
|
|
|
<!-- SVG.js library (required by HamburgerMorphing) -->
|
|
<script src="./js/vendor/svg.min.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<!-- ================================================================
|
|
HAMBURGER BUTTON (Fixed, separate from header)
|
|
================================================================
|
|
The hamburger button is a fixed element outside the header
|
|
to ensure it stays visible above the sidenav (z-index: 10 > 3).
|
|
================================================================ -->
|
|
<div id="divSvgHam" class="divHeaderButtons">
|
|
<!-- HamburgerMorphing will be injected here -->
|
|
</div>
|
|
|
|
<!-- ================================================================
|
|
HEADER
|
|
================================================================
|
|
Standard header with title (center).
|
|
================================================================ -->
|
|
<div id="divHeader">
|
|
<div id="divHeaderFlexLeft">
|
|
<!-- Hamburger is now separate fixed element -->
|
|
</div>
|
|
|
|
<div id="divHeaderFlexCenter">
|
|
<div class="divHeaderText">VJ PLAYLISTS</div>
|
|
</div>
|
|
|
|
<div id="divHeaderFlexRight">
|
|
<!-- No button in header right - logout is in sidenav footer -->
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ================================================================
|
|
BODY
|
|
================================================================
|
|
Main content area. Add your page-specific content here.
|
|
================================================================ -->
|
|
<div id="divBody">
|
|
<div id="divPlaylistRoot">
|
|
<div id="divPlaylistControls">
|
|
<span class="playlistControlLabel">Show</span>
|
|
<select id="selShowFilter" aria-label="Select show playlist">
|
|
<option value="">Loading shows…</option>
|
|
</select>
|
|
<button id="btnRefreshPlaylists" class="btn" type="button">Refresh</button>
|
|
</div>
|
|
<div id="divPlaylistTarget"></div>
|
|
<div id="divPlaylistStatus"></div>
|
|
<div id="divPlaylistSummary"></div>
|
|
<div id="divPlaylistEpisodes"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ================================================================
|
|
FOOTER
|
|
================================================================
|
|
Three-section footer layout:
|
|
- Left: Relay status animations (HamburgerMorphing instances)
|
|
- Center: General status information
|
|
- Right: Additional information
|
|
================================================================ -->
|
|
<div id="divFooter">
|
|
<div id="divFooterLeft" class="divFooterBox"></div>
|
|
<div id="divFooterCenter" class="divFooterBox"></div>
|
|
<div id="divFooterRight" class="divFooterBox"></div>
|
|
<div id="divFooterBalance" class="divFooterBox">0 sats</div>
|
|
</div>
|
|
|
|
<!-- ================================================================
|
|
SIDENAV
|
|
================================================================
|
|
Slide-out navigation panel. Opens from left when hamburger clicked.
|
|
Uses flexbox layout to pin version bar to bottom.
|
|
Includes a version bar footer with theme toggle and logout buttons.
|
|
================================================================ -->
|
|
<div id="divSideNav">
|
|
<div id="divSideNavHeader">
|
|
<!-- No close button - use main hamburger to close -->
|
|
</div>
|
|
|
|
<div id="divSideNavBody">
|
|
<div id="divFiles"></div>
|
|
</div>
|
|
|
|
<div id="divAiSection" class="sidenavSection">
|
|
<div id="divAiSectionTitle" class="sidenavSectionTitle">AI</div>
|
|
<div id="divAiList" class="sidenavSectionList">
|
|
<div id="divAiProvidersList">No saved providers yet.</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div id="divRelaySection">
|
|
<div id="divRelaySectionTitle">
|
|
リレー
|
|
</div>
|
|
<div id="divRelayList">
|
|
Loading relays...
|
|
</div>
|
|
</div>
|
|
|
|
<div id="divBlossomSection">
|
|
|
|
<div id="divBlossomSectionTitle">ブロッサム</div>
|
|
|
|
<div id="divBlossomList">Loading blossom servers...</div>
|
|
|
|
</div>
|
|
|
|
|
|
<div id="divVersionBar">
|
|
<span id="versionDisplay">v0.0.1</span>
|
|
<div id="divVersionBarButtons">
|
|
<button id="themeToggleButton" title="Toggle Dark/Light Mode">
|
|
<div id="themeToggleHamburgerContainer"></div>
|
|
</button>
|
|
<button id="logoutButton" title="Logout">
|
|
<div id="logoutHamburgerContainer"></div>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ================================================================
|
|
REQUIRED SCRIPTS
|
|
================================================================
|
|
These scripts must be loaded in this order:
|
|
1. nostr.bundle.js - Nostr tools library
|
|
2. nostr-lite.js - Authentication modal (nostr-login-lite)
|
|
================================================================ -->
|
|
<script src="./nostr.bundle.js"></script>
|
|
<script src="/nostr-login-lite/nostr-lite.js"></script>
|
|
|
|
<script type="module">
|
|
/* ================================================================
|
|
IMPORTS
|
|
================================================================
|
|
Import shared NDK functionality from init-ndk.mjs:
|
|
- initNDKPage() - Initialize authentication and worker
|
|
- getPubkey() - Get current user's pubkey
|
|
- subscribe() - Create NDK subscriptions
|
|
- publishEvent() - Publish events via NDK
|
|
- disconnect() - Disconnect from worker
|
|
- getRelayData() - Get relay connection data
|
|
- getRelayStats() - Get relay activity statistics
|
|
|
|
Import HamburgerMorphing for animated icons
|
|
================================================================ */
|
|
import {
|
|
initNDKPage,
|
|
getPubkey, injectHeaderAvatar,
|
|
subscribe,
|
|
publishEvent,
|
|
disconnect,
|
|
getVersion,
|
|
updateVersionDisplay,
|
|
queryCache,
|
|
ndkFetchEvents,
|
|
getUserSettings,
|
|
patchUserSettings,
|
|
onUserSettings
|
|
} from './js/init-ndk.mjs';
|
|
import { HamburgerMorphing } from "./hamburger_morphing/hamburger.mjs";
|
|
import { initFooterRelayStatus, updateFooterRelayStatus, initSidenavRelaySection, updateSidenavRelaySection, setRelayActivityState } from './js/relay-ui.mjs';
|
|
|
|
import { initBlossomSection, updateBlossomSection } from './js/blossom-ui.mjs';
|
|
|
|
import { initAiSectionWithLocalConfig } from './js/ai-ui.mjs';
|
|
// Version will be loaded asynchronously
|
|
const versionInfo = await getVersion();
|
|
const VERSION = versionInfo.VERSION;
|
|
console.log(`[template.html ${VERSION}] Loading...`);
|
|
|
|
/* ================================================================
|
|
GLOBAL VARIABLES
|
|
================================================================
|
|
Track state for hamburger menu, relay status, and theme.
|
|
================================================================ */
|
|
let updateIntervalId = null;
|
|
let currentPubkey = null;
|
|
|
|
/*
|
|
AUTH STATE MODEL (Template reference)
|
|
------------------------------------------------------------------
|
|
This template now demonstrates three auth modes for standalone pages:
|
|
|
|
- required (default):
|
|
Behaves like existing pages: login is required immediately.
|
|
|
|
- optional:
|
|
Page can render public/read-only data without login, but can still
|
|
prompt login later for user actions (publish, settings, etc).
|
|
|
|
- none:
|
|
Never auto-login on load (pure public page).
|
|
|
|
URL behavior in this template:
|
|
- If ?auth=required|optional|none is present, it wins.
|
|
- Otherwise, if URL includes ?npub=... or ?pubkey=..., mode defaults
|
|
to optional because pages with explicit profile targets are commonly
|
|
public-readable.
|
|
- Otherwise, mode defaults to required.
|
|
*/
|
|
let isAuthenticated = false;
|
|
let authMode = 'required';
|
|
let authedPageInitialized = false;
|
|
let relayActivityListenersBound = false;
|
|
|
|
// Hamburger menu
|
|
let hamburgerInstance = null;
|
|
let isNavOpen = false;
|
|
|
|
// Version bar buttons
|
|
let logoutHamburger = null;
|
|
let themeToggleHamburger = null;
|
|
let isDarkMode = false;
|
|
|
|
// App-wide user settings (NIP-78 kind 30078, d:user-settings)
|
|
let pageSettings = {};
|
|
let unsubscribeUserSettings = null;
|
|
|
|
/* ================================================================
|
|
DOM VARIABLES
|
|
================================================================
|
|
Cache DOM element references for better performance.
|
|
================================================================ */
|
|
const divBody = document.getElementById("divBody");
|
|
const divSideNav = document.getElementById("divSideNav");
|
|
const divSideNavBody = document.getElementById("divSideNavBody");
|
|
const divFooterCenter = document.getElementById("divFooterCenter");
|
|
const divFooterRight = document.getElementById("divFooterRight");
|
|
const selShowFilter = document.getElementById('selShowFilter');
|
|
const btnRefreshPlaylists = document.getElementById('btnRefreshPlaylists');
|
|
const divPlaylistTarget = document.getElementById('divPlaylistTarget');
|
|
const divPlaylistStatus = document.getElementById('divPlaylistStatus');
|
|
const divPlaylistSummary = document.getElementById('divPlaylistSummary');
|
|
const divPlaylistEpisodes = document.getElementById('divPlaylistEpisodes');
|
|
|
|
const STREAM_KIND = 30311;
|
|
const PLAYLIST_KIND = 30078;
|
|
const PLAYLIST_FETCH_LIMIT = 300;
|
|
|
|
let targetPubkey = '';
|
|
let selectedShowSlug = '';
|
|
let latestShowEventsBySlug = new Map();
|
|
|
|
/* ================================================================
|
|
HAMBURGER MENU
|
|
================================================================
|
|
Initialize and control the animated hamburger menu.
|
|
================================================================ */
|
|
function initHamburgerMenu() {
|
|
hamburgerInstance = new HamburgerMorphing('#divSvgHam', {
|
|
foreground: 'var(--primary-color)',
|
|
background: 'var(--secondary-color)',
|
|
hover: 'var(--accent-color)'
|
|
});
|
|
hamburgerInstance.animateTo('burger');
|
|
}
|
|
|
|
/* ================================================================
|
|
SIDENAV FUNCTIONS
|
|
================================================================
|
|
Open/close sidenav with hamburger morphing animation.
|
|
================================================================ */
|
|
function openNav() {
|
|
divSideNav.style.zIndex = 3;
|
|
divSideNav.style.width = "clamp(400px, 50vw, 600px)";
|
|
isNavOpen = true;
|
|
if (hamburgerInstance) {
|
|
hamburgerInstance.animateTo('arrow_left');
|
|
}
|
|
|
|
|
|
// Initialize version bar buttons when sidenav opens (lazy load)
|
|
if (!logoutHamburger) {
|
|
logoutHamburger = new HamburgerMorphing('#logoutHamburgerContainer', {
|
|
size: 24,
|
|
foreground: 'var(--primary-color)',
|
|
background: 'var(--secondary-color)',
|
|
hover: 'var(--accent-color)'
|
|
});
|
|
logoutHamburger.animateTo('x');
|
|
}
|
|
|
|
if (!themeToggleHamburger) {
|
|
themeToggleHamburger = new HamburgerMorphing('#themeToggleHamburgerContainer', {
|
|
size: 24,
|
|
foreground: 'var(--primary-color)',
|
|
background: 'var(--secondary-color)',
|
|
hover: 'var(--accent-color)'
|
|
});
|
|
|
|
// Determine current theme
|
|
const savedTheme = localStorage.getItem('theme');
|
|
isDarkMode = savedTheme === 'dark' || document.body.classList.contains('dark-mode');
|
|
const initialShape = isDarkMode ? 'moon' : 'circle';
|
|
themeToggleHamburger.animateTo(initialShape);
|
|
}
|
|
}
|
|
|
|
function closeNav() {
|
|
divSideNav.style.width = "0vw";
|
|
divSideNav.style.zIndex = -1;
|
|
isNavOpen = false;
|
|
if (hamburgerInstance) {
|
|
hamburgerInstance.animateTo('burger');
|
|
}
|
|
}
|
|
|
|
function toggleNav() {
|
|
if (isNavOpen) {
|
|
closeNav();
|
|
} else {
|
|
openNav();
|
|
}
|
|
}
|
|
|
|
|
|
/* ================================================================
|
|
AUTH MODE HELPERS
|
|
================================================================
|
|
These functions are meant as reusable guidance for future pages.
|
|
================================================================ */
|
|
function hasTargetPubkeyInUrl() {
|
|
const params = new URLSearchParams(window.location.search || '');
|
|
const npub = String(params.get('npub') || '').trim();
|
|
const pubkey = String(params.get('pubkey') || '').trim();
|
|
return Boolean(npub || pubkey);
|
|
}
|
|
|
|
function resolveAuthModeFromUrl() {
|
|
const params = new URLSearchParams(window.location.search || '');
|
|
const explicitAuth = String(params.get('auth') || '').trim().toLowerCase();
|
|
if (explicitAuth === 'required' || explicitAuth === 'optional' || explicitAuth === 'none') {
|
|
return explicitAuth;
|
|
}
|
|
|
|
// Convention: explicit target profiles are public-readable by default.
|
|
if (hasTargetPubkeyInUrl()) {
|
|
return 'optional';
|
|
}
|
|
|
|
return 'required';
|
|
}
|
|
|
|
function isAuthRequiredError(error) {
|
|
const message = String(error?.message || error || '').toLowerCase();
|
|
return message.includes('authentication required');
|
|
}
|
|
|
|
async function initializeAuthentication(mode) {
|
|
// required: existing behavior, throw if auth fails.
|
|
if (mode === 'required') {
|
|
await initNDKPage();
|
|
currentPubkey = await getPubkey();
|
|
isAuthenticated = true;
|
|
return;
|
|
}
|
|
|
|
// none: public page, no login attempt on load.
|
|
if (mode === 'none') {
|
|
isAuthenticated = false;
|
|
currentPubkey = null;
|
|
return;
|
|
}
|
|
|
|
// optional: try silent/normal init; if auth required, continue public.
|
|
try {
|
|
await initNDKPage();
|
|
currentPubkey = await getPubkey();
|
|
isAuthenticated = true;
|
|
} catch (error) {
|
|
if (isAuthRequiredError(error)) {
|
|
console.log('[template.html] Optional auth mode: continuing unauthenticated');
|
|
isAuthenticated = false;
|
|
currentPubkey = null;
|
|
return;
|
|
}
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
async function initializeAuthenticatedPageFeatures() {
|
|
if (!isAuthenticated || authedPageInitialized) return;
|
|
|
|
await injectHeaderAvatar(currentPubkey);
|
|
console.log('[template.html] Authenticated as:', currentPubkey);
|
|
|
|
// Hydrate app-wide user settings for this page
|
|
try {
|
|
pageSettings = await getUserSettings();
|
|
} catch (error) {
|
|
console.warn('[template.html] getUserSettings failed:', error);
|
|
pageSettings = {};
|
|
}
|
|
|
|
// Subscribe to live user settings updates (cross-tab + publish echoes)
|
|
if (!unsubscribeUserSettings) {
|
|
unsubscribeUserSettings = onUserSettings((settings) => {
|
|
pageSettings = settings || {};
|
|
// TODO: Re-render page-specific UI from pageSettings here.
|
|
});
|
|
}
|
|
|
|
// Initialize relay-dependent UI only once authenticated.
|
|
initFooterRelayStatus();
|
|
initSidenavRelaySection();
|
|
await initBlossomSection();
|
|
initAiSectionWithLocalConfig();
|
|
await UpdateFooter();
|
|
|
|
if (!updateIntervalId) {
|
|
updateIntervalId = setInterval(UpdateFooter, 1000);
|
|
}
|
|
|
|
// Relay activity listeners only matter after worker init/auth.
|
|
if (!relayActivityListenersBound) {
|
|
window.addEventListener('ndkRelayActivity', (event) => {
|
|
const { relayUrl, activity, stats } = event.detail;
|
|
console.log(`[template.html] Relay activity: ${relayUrl} - ${activity}`, stats);
|
|
setRelayActivityState(relayUrl, activity);
|
|
});
|
|
|
|
window.addEventListener('message', (event) => {
|
|
if (event.data && event.data.type === 'relayActivity') {
|
|
const { relayUrl, activity } = event.data;
|
|
console.log(`[template.html] Relay activity: ${relayUrl} - ${activity}`);
|
|
setRelayActivityState(relayUrl, activity);
|
|
}
|
|
});
|
|
|
|
relayActivityListenersBound = true;
|
|
}
|
|
|
|
authedPageInitialized = true;
|
|
}
|
|
|
|
async function promptLoginIfNeeded() {
|
|
if (isAuthenticated) return true;
|
|
|
|
await initNDKPage();
|
|
currentPubkey = await getPubkey();
|
|
isAuthenticated = true;
|
|
await initializeAuthenticatedPageFeatures();
|
|
await initializePlaylistPage();
|
|
return true;
|
|
}
|
|
|
|
function getTagValue(evt, tagName) {
|
|
const tags = Array.isArray(evt?.tags) ? evt.tags : [];
|
|
const found = tags.find((t) => t && t[0] === tagName);
|
|
return found ? String(found[1] || '').trim() : '';
|
|
}
|
|
|
|
function getTagValues(evt, tagName) {
|
|
const tags = Array.isArray(evt?.tags) ? evt.tags : [];
|
|
return tags
|
|
.filter((t) => t && t[0] === tagName)
|
|
.map((t) => t.slice(1).map((v) => String(v ?? '').trim()));
|
|
}
|
|
|
|
function decodeNpubToHex(npub) {
|
|
try {
|
|
const decoded = window?.NostrTools?.nip19?.decode?.(npub);
|
|
if (decoded?.type === 'npub' && typeof decoded?.data === 'string') {
|
|
return decoded.data;
|
|
}
|
|
} catch (error) {
|
|
console.warn('[vj-playlist.html] Failed to decode npub:', error);
|
|
}
|
|
return '';
|
|
}
|
|
|
|
function resolveTargetPubkeyFromUrl() {
|
|
const params = new URLSearchParams(window.location.search || '');
|
|
const explicitPubkey = String(params.get('pubkey') || '').trim();
|
|
if (explicitPubkey) return explicitPubkey;
|
|
|
|
const npub = String(params.get('npub') || '').trim();
|
|
if (npub) return decodeNpubToHex(npub);
|
|
|
|
return '';
|
|
}
|
|
|
|
function getAddressableKey(evt) {
|
|
const kind = Number(evt?.kind) || 0;
|
|
const pubkey = String(evt?.pubkey || '').trim();
|
|
const dTag = getTagValue(evt, 'd');
|
|
if (!kind || !pubkey || !dTag) return '';
|
|
return `${kind}:${pubkey}:${dTag}`;
|
|
}
|
|
|
|
function dedupeAddressableEvents(events) {
|
|
const latestByKey = new Map();
|
|
(Array.isArray(events) ? events : []).forEach((evt) => {
|
|
if (!evt) return;
|
|
const key = getAddressableKey(evt) || String(evt.id || '');
|
|
if (!key) return;
|
|
const existing = latestByKey.get(key);
|
|
const evtCreated = Number(evt.created_at) || 0;
|
|
const existingCreated = Number(existing?.created_at) || 0;
|
|
if (!existing || evtCreated >= existingCreated) {
|
|
latestByKey.set(key, evt);
|
|
}
|
|
});
|
|
return Array.from(latestByKey.values());
|
|
}
|
|
|
|
async function fetchEventsWithCache(filters) {
|
|
const [cached, fresh] = await Promise.all([
|
|
queryCache(filters).catch(() => []),
|
|
ndkFetchEvents(filters).catch(() => []),
|
|
]);
|
|
|
|
return dedupeAddressableEvents([
|
|
...(Array.isArray(cached) ? cached : []),
|
|
...(Array.isArray(fresh) ? fresh : []),
|
|
]);
|
|
}
|
|
|
|
function deriveShowSlugFromPlaylistEvent(evt) {
|
|
const explicit = getTagValue(evt, 'show');
|
|
if (explicit) return explicit;
|
|
|
|
const dTag = getTagValue(evt, 'd');
|
|
const match = dTag.match(/^show-playlist:([^:]+):/i);
|
|
return match ? String(match[1] || '').trim() : '';
|
|
}
|
|
|
|
function formatEpisodeId(episodeId) {
|
|
const raw = String(episodeId || '').trim();
|
|
const n = Number(raw);
|
|
if (!Number.isFinite(n) || n <= 0) return raw || 'Unknown episode';
|
|
|
|
const iso = new Date(n * 1000);
|
|
if (Number.isNaN(iso.getTime())) return raw;
|
|
return `${iso.toLocaleString()} (${raw})`;
|
|
}
|
|
|
|
function parseTrackTags(evt) {
|
|
const tracks = getTagValues(evt, 'track').map((parts) => ({
|
|
trackNumber: parts[0] || '',
|
|
artist: parts[1] || '',
|
|
title: parts[2] || '',
|
|
nostrRef: parts[3] || '',
|
|
isoTime: parts[4] || '',
|
|
}));
|
|
|
|
tracks.sort((a, b) => String(a.trackNumber).localeCompare(String(b.trackNumber)));
|
|
return tracks;
|
|
}
|
|
|
|
function parsePeakViewers(evt) {
|
|
const snapshots = getTagValues(evt, 'viewers');
|
|
let peak = 0;
|
|
snapshots.forEach((parts) => {
|
|
const total = Number(parts[1] || 0);
|
|
if (Number.isFinite(total) && total > peak) peak = total;
|
|
});
|
|
return peak;
|
|
}
|
|
|
|
function renderPlaylistEpisodes(playlistEvents) {
|
|
const events = Array.isArray(playlistEvents) ? playlistEvents : [];
|
|
divPlaylistEpisodes.innerHTML = '';
|
|
|
|
if (!events.length) {
|
|
divPlaylistEpisodes.innerHTML = '<div class="playlistEmpty">No playlists found for this show yet.</div>';
|
|
divPlaylistSummary.textContent = '0 episodes';
|
|
divFooterRight.textContent = '0 tracks';
|
|
return;
|
|
}
|
|
|
|
const cards = events.map((evt) => {
|
|
const episodeId = getTagValue(evt, 'episode') || 'unknown';
|
|
const status = getTagValue(evt, 'status') || 'unknown';
|
|
const episodeDescription = getTagValue(evt, 'episode_description');
|
|
const tracks = parseTrackTags(evt);
|
|
const peakViewers = parsePeakViewers(evt);
|
|
const createdAt = Number(evt.created_at) || 0;
|
|
|
|
return {
|
|
evt,
|
|
episodeId,
|
|
status,
|
|
episodeDescription,
|
|
tracks,
|
|
peakViewers,
|
|
createdAt,
|
|
};
|
|
}).sort((a, b) => b.createdAt - a.createdAt);
|
|
|
|
const totalTracks = cards.reduce((sum, card) => sum + card.tracks.length, 0);
|
|
divPlaylistSummary.textContent = `${cards.length} episode${cards.length === 1 ? '' : 's'} • ${totalTracks} track${totalTracks === 1 ? '' : 's'}`;
|
|
divFooterRight.textContent = `${totalTracks} tracks`;
|
|
|
|
cards.forEach((card, index) => {
|
|
const details = document.createElement('details');
|
|
details.className = 'playlistEpisodeCard';
|
|
details.open = index === 0;
|
|
|
|
const summary = document.createElement('summary');
|
|
summary.className = 'playlistEpisodeSummary';
|
|
summary.innerHTML = `
|
|
<div>
|
|
<div class="playlistEpisodeTitle">Episode ${formatEpisodeId(card.episodeId)}</div>
|
|
<div class="playlistEpisodeMeta">Status: ${card.status}</div>
|
|
</div>
|
|
<div class="playlistEpisodeMeta">${card.tracks.length} tracks${card.peakViewers > 0 ? ` • peak ${card.peakViewers} viewers` : ''}</div>
|
|
`;
|
|
details.appendChild(summary);
|
|
|
|
const content = document.createElement('div');
|
|
content.className = 'playlistEpisodeContent';
|
|
|
|
if (card.episodeDescription) {
|
|
const description = document.createElement('p');
|
|
description.className = 'playlistEpisodeDescription';
|
|
description.textContent = card.episodeDescription;
|
|
content.appendChild(description);
|
|
}
|
|
|
|
if (!card.tracks.length) {
|
|
const empty = document.createElement('div');
|
|
empty.className = 'playlistEmpty';
|
|
empty.textContent = 'No track tags found in this playlist event.';
|
|
content.appendChild(empty);
|
|
} else {
|
|
const table = document.createElement('table');
|
|
table.className = 'playlistTrackTable';
|
|
table.innerHTML = `
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>Artist</th>
|
|
<th>Title</th>
|
|
<th>Time</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody></tbody>
|
|
`;
|
|
|
|
const tbody = table.querySelector('tbody');
|
|
card.tracks.forEach((track) => {
|
|
const tr = document.createElement('tr');
|
|
const timeLabel = track.isoTime ? new Date(track.isoTime).toLocaleTimeString() : '';
|
|
tr.innerHTML = `
|
|
<td class="playlistTrackNum">${track.trackNumber || ''}</td>
|
|
<td>${track.artist || ''}</td>
|
|
<td>${track.title || ''}</td>
|
|
<td class="playlistTrackTime">${timeLabel}</td>
|
|
`;
|
|
tbody.appendChild(tr);
|
|
});
|
|
|
|
content.appendChild(table);
|
|
}
|
|
|
|
details.appendChild(content);
|
|
divPlaylistEpisodes.appendChild(details);
|
|
});
|
|
}
|
|
|
|
function renderShows(shows, preferredShow) {
|
|
if (!selShowFilter) return;
|
|
|
|
const options = Array.isArray(shows) ? shows : [];
|
|
selShowFilter.innerHTML = '';
|
|
|
|
if (!options.length) {
|
|
const option = document.createElement('option');
|
|
option.value = '';
|
|
option.textContent = 'No shows found';
|
|
selShowFilter.appendChild(option);
|
|
selShowFilter.disabled = true;
|
|
selectedShowSlug = '';
|
|
return;
|
|
}
|
|
|
|
selShowFilter.disabled = false;
|
|
options.forEach((show) => {
|
|
const opt = document.createElement('option');
|
|
opt.value = show.slug;
|
|
opt.textContent = show.title ? `${show.title} (${show.slug})` : show.slug;
|
|
selShowFilter.appendChild(opt);
|
|
});
|
|
|
|
const candidate = options.some((s) => s.slug === preferredShow)
|
|
? preferredShow
|
|
: options[0].slug;
|
|
selectedShowSlug = candidate;
|
|
selShowFilter.value = candidate;
|
|
}
|
|
|
|
async function loadPlaylistsForShow(showSlug) {
|
|
if (!targetPubkey || !showSlug) {
|
|
renderPlaylistEpisodes([]);
|
|
return;
|
|
}
|
|
|
|
divPlaylistStatus.textContent = `Loading playlists for ${showSlug}…`;
|
|
|
|
const filters = {
|
|
kinds: [PLAYLIST_KIND],
|
|
authors: [targetPubkey],
|
|
'#show': [showSlug],
|
|
limit: PLAYLIST_FETCH_LIMIT,
|
|
};
|
|
|
|
const playlistEvents = await fetchEventsWithCache(filters);
|
|
const filtered = playlistEvents.filter((evt) => {
|
|
const slug = deriveShowSlugFromPlaylistEvent(evt);
|
|
return slug === showSlug;
|
|
});
|
|
|
|
renderPlaylistEpisodes(filtered);
|
|
divPlaylistStatus.textContent = `Loaded ${filtered.length} playlist event${filtered.length === 1 ? '' : 's'} for ${showSlug}.`;
|
|
}
|
|
|
|
async function discoverShows() {
|
|
if (!targetPubkey) {
|
|
renderShows([], '');
|
|
divPlaylistStatus.textContent = 'Sign in or provide ?npub=... to view playlists.';
|
|
divPlaylistEpisodes.innerHTML = '<div class="playlistEmpty">No target pubkey selected.</div>';
|
|
divPlaylistSummary.textContent = '';
|
|
return;
|
|
}
|
|
|
|
divPlaylistStatus.textContent = 'Loading shows…';
|
|
|
|
const showFilters = {
|
|
kinds: [STREAM_KIND],
|
|
authors: [targetPubkey],
|
|
limit: PLAYLIST_FETCH_LIMIT,
|
|
};
|
|
|
|
const playlistFilters = {
|
|
kinds: [PLAYLIST_KIND],
|
|
authors: [targetPubkey],
|
|
limit: PLAYLIST_FETCH_LIMIT,
|
|
};
|
|
|
|
const [showEvents, playlistEvents] = await Promise.all([
|
|
fetchEventsWithCache(showFilters),
|
|
fetchEventsWithCache(playlistFilters),
|
|
]);
|
|
|
|
latestShowEventsBySlug = new Map();
|
|
showEvents.forEach((evt) => {
|
|
const slug = getTagValue(evt, 'd');
|
|
if (!slug) return;
|
|
const prev = latestShowEventsBySlug.get(slug);
|
|
const evtCreated = Number(evt.created_at) || 0;
|
|
const prevCreated = Number(prev?.created_at) || 0;
|
|
if (!prev || evtCreated >= prevCreated) {
|
|
latestShowEventsBySlug.set(slug, evt);
|
|
}
|
|
});
|
|
|
|
playlistEvents.forEach((evt) => {
|
|
const slug = deriveShowSlugFromPlaylistEvent(evt);
|
|
if (!slug || latestShowEventsBySlug.has(slug)) return;
|
|
latestShowEventsBySlug.set(slug, null);
|
|
});
|
|
|
|
const shows = Array.from(latestShowEventsBySlug.entries())
|
|
.map(([slug, evt]) => ({
|
|
slug,
|
|
title: getTagValue(evt, 'title') || slug,
|
|
}))
|
|
.sort((a, b) => a.title.localeCompare(b.title));
|
|
|
|
const urlShow = String(new URLSearchParams(window.location.search || '').get('show') || '').trim();
|
|
renderShows(shows, urlShow || selectedShowSlug);
|
|
|
|
if (!selectedShowSlug) {
|
|
divPlaylistEpisodes.innerHTML = '<div class="playlistEmpty">No playlists found yet.</div>';
|
|
divPlaylistStatus.textContent = 'No shows discovered for this pubkey.';
|
|
divPlaylistSummary.textContent = '0 episodes';
|
|
divFooterRight.textContent = '0 tracks';
|
|
return;
|
|
}
|
|
|
|
await loadPlaylistsForShow(selectedShowSlug);
|
|
}
|
|
|
|
async function initializePlaylistPage() {
|
|
const urlPubkey = resolveTargetPubkeyFromUrl();
|
|
targetPubkey = urlPubkey || (isAuthenticated ? currentPubkey : '');
|
|
|
|
if (divPlaylistTarget) {
|
|
if (targetPubkey) {
|
|
divPlaylistTarget.textContent = `Target pubkey: ${targetPubkey}`;
|
|
} else {
|
|
divPlaylistTarget.textContent = 'Target pubkey: not set';
|
|
}
|
|
}
|
|
|
|
await discoverShows();
|
|
}
|
|
|
|
/* ================================================================
|
|
UPDATE FOOTER
|
|
================================================================
|
|
Update footer sections with relay status, pubkey, and other info.
|
|
Called periodically by update loop.
|
|
================================================================ */
|
|
const UpdateFooter = async () => {
|
|
|
|
try {
|
|
// Update relay status visuals in footer and sidenav
|
|
await updateFooterRelayStatus();
|
|
await updateSidenavRelaySection();
|
|
|
|
await updateBlossomSection();
|
|
// Clear center and right sections
|
|
divFooterCenter.innerHTML = '';
|
|
divFooterRight.innerHTML = '';
|
|
} catch (error) {
|
|
console.error('[template.html] Error updating footer:', error);
|
|
}
|
|
};
|
|
|
|
/* ================================================================
|
|
LOGOUT
|
|
================================================================
|
|
Complete logout process:
|
|
1. Stop update loop
|
|
2. Disconnect from NDK worker
|
|
3. Logout from nostr-login-lite
|
|
4. Clear all storage (localStorage, sessionStorage, IndexedDB)
|
|
5. Reload page
|
|
================================================================ */
|
|
const Logout = async () => {
|
|
console.log("[template.html] Starting logout process...");
|
|
|
|
// Stop the update loop
|
|
if (updateIntervalId) {
|
|
clearInterval(updateIntervalId);
|
|
updateIntervalId = null;
|
|
}
|
|
|
|
// Disconnect from worker
|
|
disconnect();
|
|
|
|
// Logout from nostr-login-lite
|
|
if (window.NOSTR_LOGIN_LITE && window.NOSTR_LOGIN_LITE.logout) {
|
|
await window.NOSTR_LOGIN_LITE.logout();
|
|
}
|
|
|
|
// Clear all storage
|
|
localStorage.clear();
|
|
sessionStorage.clear();
|
|
|
|
// Clear IndexedDB
|
|
if (window.indexedDB) {
|
|
const databases = await window.indexedDB.databases();
|
|
for (const db of databases) {
|
|
if (db.name) {
|
|
window.indexedDB.deleteDatabase(db.name);
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log("[template.html] Logged out, reloading page");
|
|
location.reload(true);
|
|
};
|
|
|
|
/* ================================================================
|
|
EVENT LISTENERS
|
|
================================================================
|
|
Wire up UI interactions.
|
|
Main hamburger button click handler is set up in main() after initialization.
|
|
================================================================ */
|
|
|
|
/* ================================================================
|
|
SUBSCRIPTION EXAMPLE
|
|
================================================================
|
|
Example of how to subscribe to Nostr events:
|
|
|
|
const sub = subscribe(
|
|
{ kinds: [1], authors: [pubkey], limit: 10 },
|
|
{ closeOnEose: false, cacheUsage: 'CACHE_FIRST' }
|
|
);
|
|
|
|
Cache usage options:
|
|
- 'CACHE_FIRST' - Check cache first, then relays
|
|
- 'ONLY_RELAY' - Only query relays
|
|
- 'ONLY_CACHE' - Only query cache
|
|
- 'PARALLEL' - Query cache and relays simultaneously
|
|
|
|
Listen for events via window events:
|
|
window.addEventListener('ndkEvent', (event) => {
|
|
const evt = event.detail;
|
|
console.log('Received event:', evt);
|
|
});
|
|
================================================================ */
|
|
|
|
/* ================================================================
|
|
PUBLISH EXAMPLE
|
|
================================================================
|
|
Example of how to publish a Nostr event:
|
|
|
|
const event = {
|
|
created_at: Math.floor(Date.now() / 1000),
|
|
kind: 1,
|
|
tags: [],
|
|
content: "Hello, Nostr!"
|
|
};
|
|
|
|
try {
|
|
const result = await publishEvent(event);
|
|
console.log("✅ Published to:", result.relayResults.successful);
|
|
console.log("❌ Failed:", result.relayResults.failed);
|
|
console.log("Total relays:", result.totalRelays);
|
|
} catch (error) {
|
|
console.error("Publish error:", error);
|
|
}
|
|
|
|
Note: Events are automatically signed by the NDK worker using
|
|
the message-based signer (which calls window.nostr.signEvent).
|
|
================================================================ */
|
|
|
|
/* ================================================================
|
|
USER SETTINGS EXAMPLE (NIP-78)
|
|
================================================================
|
|
Read/subscribe/write helper pattern for all pages:
|
|
|
|
// Read latest merged settings (cache + relay hydrated by worker)
|
|
const settings = await getUserSettings();
|
|
|
|
// Subscribe to cross-tab updates
|
|
const unsubscribe = onUserSettings((nextSettings) => {
|
|
// Re-render page from nextSettings
|
|
});
|
|
|
|
// Patch only your feature namespace
|
|
await patchUserSettings({
|
|
myFeature: {
|
|
someFlag: true
|
|
}
|
|
});
|
|
|
|
// On page teardown (if applicable)
|
|
// unsubscribe();
|
|
================================================================ */
|
|
|
|
/* ================================================================
|
|
INITIALIZATION
|
|
================================================================
|
|
Main initialization sequence:
|
|
1. Initialize hamburger menu
|
|
2. Set up hamburger click handler
|
|
3. Resolve auth mode from URL/query policy
|
|
4. Initialize authentication based on mode
|
|
5. Initialize authenticated-only features (if signed in)
|
|
6. Set up version bar button listeners
|
|
7. Restore sidenav state
|
|
8. Update version display
|
|
|
|
Notes:
|
|
- required mode = existing behavior (prompt login on load)
|
|
- optional mode = allow public load, login later on demand
|
|
- none mode = no auto-login on load
|
|
================================================================ */
|
|
(async function main() {
|
|
console.log("[template.html] Starting initialization...");
|
|
|
|
try {
|
|
// Initialize hamburger menu first
|
|
initHamburgerMenu();
|
|
|
|
// Add click handler to hamburger
|
|
const divSvgHam = document.getElementById('divSvgHam');
|
|
if (divSvgHam) {
|
|
divSvgHam.addEventListener('click', toggleNav);
|
|
}
|
|
|
|
// Initialize version bar buttons
|
|
const themeToggleButton = document.getElementById('themeToggleButton');
|
|
const logoutButton = document.getElementById('logoutButton');
|
|
|
|
if (themeToggleButton) {
|
|
themeToggleButton.addEventListener('click', () => {
|
|
isDarkMode = !isDarkMode;
|
|
localStorage.setItem('theme', isDarkMode ? 'dark' : 'light');
|
|
document.documentElement.classList.toggle('dark-mode', isDarkMode);
|
|
document.body.classList.toggle('dark-mode', isDarkMode);
|
|
if (themeToggleHamburger) {
|
|
themeToggleHamburger.animateTo(isDarkMode ? 'moon' : 'circle');
|
|
}
|
|
});
|
|
}
|
|
|
|
if (logoutButton) {
|
|
logoutButton.addEventListener('click', async () => {
|
|
try {
|
|
// In optional/none modes this doubles as a "Sign in" entry point.
|
|
if (!isAuthenticated) {
|
|
await promptLoginIfNeeded();
|
|
return;
|
|
}
|
|
await Logout();
|
|
} catch (error) {
|
|
console.error('Logout/login action failed:', error);
|
|
}
|
|
});
|
|
}
|
|
|
|
if (selShowFilter) {
|
|
selShowFilter.addEventListener('change', async (event) => {
|
|
selectedShowSlug = String(event?.target?.value || '').trim();
|
|
await loadPlaylistsForShow(selectedShowSlug);
|
|
});
|
|
}
|
|
|
|
if (btnRefreshPlaylists) {
|
|
btnRefreshPlaylists.addEventListener('click', async () => {
|
|
await initializePlaylistPage();
|
|
});
|
|
}
|
|
|
|
// Resolve and initialize page auth policy.
|
|
authMode = resolveAuthModeFromUrl();
|
|
console.log('[template.html] Resolved auth mode:', authMode);
|
|
await initializeAuthentication(authMode);
|
|
|
|
// Initialize authenticated features only when signed in.
|
|
await initializeAuthenticatedPageFeatures();
|
|
await initializePlaylistPage();
|
|
|
|
/* ============================================================
|
|
EXAMPLE: Subscribe to events
|
|
============================================================
|
|
Uncomment to subscribe to user's notes:
|
|
|
|
const notesSub = subscribe(
|
|
{ kinds: [1], authors: [currentPubkey], limit: 10 },
|
|
{ closeOnEose: false, cacheUsage: 'CACHE_FIRST' }
|
|
);
|
|
console.log("[template.html] Subscribed to kind 1");
|
|
============================================================ */
|
|
|
|
/* ============================================================
|
|
EXAMPLE: Listen for events from worker
|
|
============================================================
|
|
Uncomment to handle incoming events:
|
|
|
|
window.addEventListener('ndkEvent', (event) => {
|
|
const evt = event.detail;
|
|
console.log("[template.html] Received event:", evt.kind, evt.pubkey);
|
|
|
|
if (evt.pubkey === currentPubkey) {
|
|
if (evt.kind === 1) {
|
|
// Handle note event
|
|
console.log("Note:", evt.content);
|
|
}
|
|
}
|
|
});
|
|
============================================================ */
|
|
|
|
/* ============================================================
|
|
EXAMPLE: Listen for cached profile
|
|
============================================================
|
|
Uncomment to handle cached profile data:
|
|
|
|
window.addEventListener('ndkProfile', (event) => {
|
|
console.log("[template.html] Cached profile:", event.detail);
|
|
// event.detail contains profile object (name, about, etc.)
|
|
});
|
|
============================================================ */
|
|
|
|
|
|
// Optional UX note for public mode pages.
|
|
if (!isAuthenticated && (authMode === 'optional' || authMode === 'none')) {
|
|
divFooterCenter.textContent = 'Public mode';
|
|
divFooterRight.textContent = 'Sign in from side menu for private features';
|
|
}
|
|
|
|
// Update version display
|
|
await updateVersionDisplay();
|
|
|
|
console.log('[template.html] Initialization complete');
|
|
} catch (error) {
|
|
console.error('[template.html] Initialization failed:', error);
|
|
divBody.innerHTML = `<div style="text-align: center; padding: 50px;">
|
|
<div style="font-size: 24px; margin-bottom: 20px; color: red;">❌ Authentication Error</div>
|
|
<div style="font-size: 16px; color: #666;">${error.message}</div>
|
|
<div style="margin-top: 20px;">
|
|
<button onclick="location.reload()" style="padding: 10px 20px; font-size: 16px;">Retry</button>
|
|
</div>
|
|
</div>`;
|
|
}
|
|
})();
|
|
|
|
/* ================================================================
|
|
WORKER MESSAGE TYPES
|
|
================================================================
|
|
The NDK worker can send these message types:
|
|
|
|
1. 'response' - Response to init/subscribe/publish requests
|
|
- data.profile - User profile (from init)
|
|
- data.relays - User relays (from init)
|
|
- data.success - Publish success status
|
|
- data.relayResults - Relay publish results
|
|
|
|
2. 'event' - Nostr event from subscription
|
|
- Dispatched as 'ndkEvent' window event
|
|
- event.detail contains the Nostr event
|
|
|
|
3. 'eose' - End of stored events for subscription
|
|
- Dispatched as 'ndkEose' window event
|
|
- event.detail.subId contains subscription ID
|
|
|
|
4. 'signRequest' - Request to sign event/encrypt/decrypt
|
|
- Handled automatically by init-ndk.mjs
|
|
- Calls window.nostr methods and sends response
|
|
|
|
5. 'error' - Error from worker
|
|
- Logged to console automatically
|
|
|
|
6. 'relayActivity' - Relay read/write activity notification
|
|
- Dispatched as 'ndkRelayActivity' window event
|
|
- Used to animate relay status icons in footer
|
|
================================================================ */
|
|
|
|
/* ================================================================
|
|
DISTRIBUTED ARCHITECTURE NOTES
|
|
================================================================
|
|
Each page is independently accessible and self-contained:
|
|
|
|
1. Authentication persists via nostr-login-lite localStorage
|
|
- Login once on any page
|
|
- All other pages automatically authenticated
|
|
|
|
2. NDK SharedWorker is shared across all tabs/pages
|
|
- Single NDK instance manages all connections
|
|
- Subscriptions from all pages handled by one worker
|
|
- Events broadcast to all connected pages
|
|
|
|
3. Dexie cache is shared across all pages
|
|
- IndexedDB persists across sessions
|
|
- Cache-first queries are fast
|
|
- Reduces relay load
|
|
|
|
4. User settings are centralized and shared
|
|
- Worker hydrates kind 30078 (`d:user-settings`) on init
|
|
- Pages read via getUserSettings()
|
|
- Pages patch via patchUserSettings({ featureNamespace: ... })
|
|
- Pages subscribe via onUserSettings() for live updates
|
|
|
|
5. Each page can be distributed independently
|
|
- Copy template.html and customize
|
|
- No dependencies on other pages
|
|
- Works standalone or as part of suite
|
|
|
|
6. Message-based signer bridges worker and page
|
|
- Worker's NDK uses MessageBasedSigner
|
|
- Signer sends sign requests to page
|
|
- Page calls window.nostr.signEvent()
|
|
- Response sent back to worker
|
|
- NDK completes signing and publishing
|
|
|
|
7. Relay status visualization
|
|
- Footer left section shows connected relays
|
|
- Each relay has animated icon (HamburgerMorphing)
|
|
- Icons morph based on activity (read/write)
|
|
- Temporary animations show real-time activity
|
|
================================================================ */
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|