diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Submit option forms without inline handlers
Diffstat (limited to '')
-rw-r--r--assets/cgit.js18
1 file changed, 18 insertions, 0 deletions
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. */