Files
webhooker/static/js/app.js
sneak e3e632676c
All checks were successful
check / check (push) Successful in 3m40s
Clarify web UI terminology and copy the entrypoint URL (refs #57)
Terminology: the nav labelled its link Sources while every heading said
Webhooks. Both nav links and the sources list page title now say
Webhooks, matching the product name and the database.Webhook model. The
/sources and /source/{id} routes are deliberately unchanged; renaming
them would break existing bookmarks for no gain, since the URL is not
what a user reads.

Profile: the "Settings" column held only placeholder copy promising
settings that would appear later. Password change is the only real
account setting and it already has its own card below, so the column is
removed and the two-column grid collapses to the single remaining one.

Entrypoint URL copy button as progressive enhancement. The button is
rendered with the hidden attribute and a data-copy-target naming the
element that holds the URL. app.js reveals it only after confirming
both a resolvable target and a usable Clipboard API, so a browser
without either shows no dead control, and the URL is plain selectable
text in every case.

Template rendering assertions cover the nav labels, the absence of any
remaining user-visible "Sources", and the button's hidden-by-default
markup, so the copy cannot drift back silently.

Note on the retention copy: it is untouched here. The reaper treats a
non-positive RetentionDays as retain-forever, but on this branch no UI
path can produce one, so copy describing that would be false today. The
work belongs with the change that makes the value reachable.
2026-08-11 12:26:02 +00:00

63 lines
1.8 KiB
JavaScript

// Webhooker client-side JavaScript
console.log("Webhooker loaded");
// Copy-to-clipboard, as progressive enhancement.
//
// Markup renders each copy button with the `hidden` attribute and a
// `data-copy-target` pointing at the id of the element holding the
// text. This script reveals a button only once it has both a resolvable
// target and a usable Clipboard API, so a browser without either shows
// no button at all and the text stays selectable.
(function () {
"use strict";
var revertDelayMs = 2000;
function flash(button, message) {
var original = button.getAttribute("data-copy-label");
button.textContent = message;
window.setTimeout(function () {
button.textContent = original;
}, revertDelayMs);
}
function wire(button) {
var target = document.getElementById(
button.getAttribute("data-copy-target")
);
if (!target) {
return;
}
button.setAttribute("data-copy-label", button.textContent);
button.addEventListener("click", function () {
navigator.clipboard.writeText(target.textContent.trim()).then(
function () {
flash(button, "Copied");
},
function () {
flash(button, "Copy failed");
}
);
});
button.removeAttribute("hidden");
}
function init() {
if (!navigator.clipboard || !navigator.clipboard.writeText) {
return;
}
var buttons = document.querySelectorAll("[data-copy-target]");
for (var i = 0; i < buttons.length; i++) {
wire(buttons[i]);
}
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", init);
} else {
init();
}
})();