// 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(); }); // Press / to search (unless typing somewhere already). document.addEventListener("keydown", function (e) { if (e.key !== "/" || e.ctrlKey || e.metaKey || e.altKey) return; var t = e.target; if (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)) return; var box = document.getElementById("search-box"); if (box) { e.preventDefault(); box.focus(); box.select(); } }); document.addEventListener("click", function (e) { // The menu on narrow screens. if (e.target.closest("[data-nav-toggle]")) { document.body.classList.toggle("nav-open"); return; } if (e.target.closest("[data-nav-close]")) { document.body.classList.remove("nav-open"); return; } // Copy a
's text: