Files
f1-circuits/guides/guides.js
T
jschoubben 09a83f6ad9 Guide Plex and Emby users step by step to the posters, at /guides/
People put the posters in their own libraries (one in an automated F1 library in Emby), and
the only help was the Kometa example page, written for developers. The guides are for people
who are not: numbered steps of one action each, the exact menus and buttons of Plex, Kometa and
Emby as their own documentation names them, boxes to copy, the pictures from the live API,
what to see after a step and what to do when it does not work. The technical details (routes,
options, the address version, a script and Emby's API) sit at the end of each.

guides/ holds the index, plex.html (a Plex TV library on the Personal Media Shows agent, Kometa
pointed at /kometa/formula-1-metadata.yml, its daily run) and emby.html (Kometa needs Plex, so:
Set Image from URL by hand, or picture files named as Emby's TV naming page reads them, and a
script that saves a whole season from the Kometa file). They use the example site's style
sheet; every example page's nav links them, and README.md lists them.

cdn-api.py serves guides/ at /guides/ beside /examples/, and the image copies it. A mount of a
directory the image lacks stops the service at its start, so tests/test_image.py holds that
every directory the app serves is copied by service/Dockerfile.
2026-11-30 12:46:36 +01:00

36 lines
1.1 KiB
JavaScript

/*
* The guides' one behaviour: a Copy button on every box of text to copy (`.copy`), copying the text of its
* `code` element. Without the script the text stays selectable by hand.
*/
(function () {
'use strict';
async function copy(text, button) {
let done = false;
try {
await navigator.clipboard.writeText(text);
done = true;
} catch {
const area = document.createElement('textarea');
area.value = text;
area.style.cssText = 'position:fixed;opacity:0';
document.body.append(area);
area.select();
try { done = document.execCommand('copy'); } catch { done = false; }
area.remove();
}
button.textContent = done ? 'Copied' : 'Select it and copy';
setTimeout(() => { button.textContent = 'Copy'; }, 1500);
}
for (const box of document.querySelectorAll('.copy')) {
const code = box.querySelector('code');
if (!code) continue;
const button = document.createElement('button');
button.type = 'button';
button.textContent = 'Copy';
button.addEventListener('click', () => copy(code.textContent, button));
box.append(button);
}
})();