From b6dd1ced702f261334f56ec5cc7a7a73274dc3a6 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 16 Jul 2026 19:33:52 -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 2.12.1