From 6263f1d2e05b73d0358779b7b8d99c8251480386 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 19 Jul 2026 15:34:16 -1000 Subject: Submit option forms without inline handlers --- assets/cgit.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'assets') diff --git a/assets/cgit.js b/assets/cgit.js index 2164c1a..4e0ac70 100644 --- a/assets/cgit.js +++ b/assets/cgit.js @@ -73,6 +73,24 @@ document.addEventListener("DOMContentLoaded", function() { })(); +/* Selects marked data-autosubmit reload the page with the new setting. + * Wired here instead of inline onchange handlers, which a strict + * Content-Security-Policy blocks. Without scripting the forms keep + * their noscript reload button. */ + +(function () { + +document.addEventListener("DOMContentLoaded", function () { + var i, els = document.querySelectorAll("select[data-autosubmit]"); + + for (i = 0; i < els.length; i++) + els[i].addEventListener("change", function () { + this.form.submit(); + }); +}, false); + +})(); + /* Colour theme toggle: cycles auto -> light -> dark and remembers the * choice. "auto" leaves the page following the system preference via CSS. */ -- cgit v2.8.0