Files
supermarket/internal/web/static/app.js
T
davidandClaude Opus 5.5 d039484a4a Phase 0: turn Supermarket into a Dockerized local web app
Replace the old Go TUI with a web app (port 8470) that runs in a
container as a CoreDesktop sibling:

- cmd/supermarket server with htmx web UI: dashboard, company profile,
  inventory (partners/competitors), AI and credential settings, and a
  Core & Hermes page
- SQLite storage and a secrets store under ~/.local/share/supermarket
- AI providers (Anthropic, OpenAI-compatible) behind one interface
- MCP server and a Hermes bridge to the Federated Core MCP hub
- Import of the old Coremarketing TUI's state
- install.sh / update.sh / lib.sh, Dockerfile, compose.yaml, the
  bin/supermarket launcher and hermes/setup.sh

Posting is not wired back up yet; that comes in Phase 1. See PLAN.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 08:38:09 -07:00

52 lines
1.8 KiB
JavaScript

// Small behaviours for Supermarket's pages. Loaded as a file because the
// Content-Security-Policy allows no inline scripts.
(function () {
"use strict";
// Show the fields for the chosen AI provider ([data-show-for]).
function syncProvider() {
var chosen = document.querySelector('input[data-toggle="provider"]:checked');
if (!chosen) return;
document.querySelectorAll("[data-show-for]").forEach(function (el) {
el.hidden = el.getAttribute("data-show-for") !== chosen.value;
});
}
document.addEventListener("change", function (e) {
if (e.target.matches('input[data-toggle="provider"]')) syncProvider();
});
document.addEventListener("click", function (e) {
// Copy a <pre>'s text: <button data-copy="id-of-pre">
var copy = e.target.closest("[data-copy]");
if (copy) {
var src = document.getElementById(copy.getAttribute("data-copy"));
if (src && navigator.clipboard) {
navigator.clipboard.writeText(src.textContent).then(function () {
var label = copy.textContent;
copy.textContent = "Copied";
setTimeout(function () { copy.textContent = label; }, 1500);
});
}
return;
}
// Fill a field from a list: <button data-fill="field-name" data-value="v">
var fill = e.target.closest("[data-fill]");
if (fill) {
var field = document.querySelector('[name="' + fill.getAttribute("data-fill") + '"]');
if (field) {
field.value = fill.getAttribute("data-value");
field.focus();
}
}
});
// Ask before submitting a form with data-confirm.
document.addEventListener("submit", function (e) {
var msg = e.target.getAttribute("data-confirm");
if (msg && !window.confirm(msg)) e.preventDefault();
});
document.addEventListener("DOMContentLoaded", syncProvider);
})();