summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/displayheaders.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/displayheaders.js b/src/displayheaders.js
new file mode 100644
index 0000000..3c0936a
--- /dev/null
+++ b/src/displayheaders.js
@@ -0,0 +1,35 @@
+function toggle_navbar() {
+ // Get the target from the "data-target" attribute
+ const target = this.dataset.target;
+ const $target = document.getElementById(target);
+
+ // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
+ this.classList.toggle('is-active');
+ $target.classList.toggle('is-active');
+}
+
+function sort_select_submit() {
+ this.children[0].form.submit();
+}
+
+function check_all() {
+ const setTo = this.checked;
+ const chkbox = document.getElementsByClassName('jwm-mail-checkbox');
+
+ for (const m of chkbox)
+ m.checked = setTo;
+}
+
+document.addEventListener("DOMContentLoaded", function() {
+ {
+ const sort_select = document.getElementById("sort");
+ const current_option_name = new URL(document.location).searchParams.get("sort");
+ if (current_option_name)
+ sort_select.value = current_option_name;
+ }
+
+ document.getElementById("sort-select").addEventListener("change", sort_select_submit);
+ document.getElementById("navbar-toggle").addEventListener("click", toggle_navbar);
+ document.getElementById("check-all").addEventListener("click", check_all);
+});
+