summaryrefslogtreecommitdiff
path: root/src/jwebmail/static/src
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2024-04-10 19:05:10 +0200
committerJannis M. Hoffmann <jannis@fehcom.de>2024-04-10 19:05:10 +0200
commitb73ed6ebd3cca86de065549cfb0d109a1d0461c5 (patch)
tree72e601618b215599cc6646bd2c6df058b053406f /src/jwebmail/static/src
parentf06e7e51f84e9260410108ed527f3c8cbe28fbdd (diff)
split js files and do local time conversion
Diffstat (limited to 'src/jwebmail/static/src')
-rw-r--r--src/jwebmail/static/src/dh-select-all-mails.js11
-rw-r--r--src/jwebmail/static/src/dh-submit-sort-on-change.js12
-rw-r--r--src/jwebmail/static/src/dh-toggle-navbar.js13
-rw-r--r--src/jwebmail/static/src/displayheaders.js35
-rw-r--r--src/jwebmail/static/src/localtime.js5
-rw-r--r--src/jwebmail/static/src/multipart-alt-tabs.js (renamed from src/jwebmail/static/src/rendermail.js)0
6 files changed, 41 insertions, 35 deletions
diff --git a/src/jwebmail/static/src/dh-select-all-mails.js b/src/jwebmail/static/src/dh-select-all-mails.js
new file mode 100644
index 0000000..73f8ff3
--- /dev/null
+++ b/src/jwebmail/static/src/dh-select-all-mails.js
@@ -0,0 +1,11 @@
+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() {
+ document.getElementById("check-all").addEventListener("click", check_all);
+});
diff --git a/src/jwebmail/static/src/dh-submit-sort-on-change.js b/src/jwebmail/static/src/dh-submit-sort-on-change.js
new file mode 100644
index 0000000..6d0ab6d
--- /dev/null
+++ b/src/jwebmail/static/src/dh-submit-sort-on-change.js
@@ -0,0 +1,12 @@
+function sort_select_submit() {
+ this.children[0].form.submit();
+}
+
+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);
+});
diff --git a/src/jwebmail/static/src/dh-toggle-navbar.js b/src/jwebmail/static/src/dh-toggle-navbar.js
new file mode 100644
index 0000000..1325516
--- /dev/null
+++ b/src/jwebmail/static/src/dh-toggle-navbar.js
@@ -0,0 +1,13 @@
+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');
+}
+
+document.addEventListener("DOMContentLoaded", function() {
+ document.getElementById("navbar-toggle").addEventListener("click", toggle_navbar);
+});
diff --git a/src/jwebmail/static/src/displayheaders.js b/src/jwebmail/static/src/displayheaders.js
deleted file mode 100644
index 3c0936a..0000000
--- a/src/jwebmail/static/src/displayheaders.js
+++ /dev/null
@@ -1,35 +0,0 @@
-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);
-});
-
diff --git a/src/jwebmail/static/src/localtime.js b/src/jwebmail/static/src/localtime.js
new file mode 100644
index 0000000..daa1455
--- /dev/null
+++ b/src/jwebmail/static/src/localtime.js
@@ -0,0 +1,5 @@
+document.querySelectorAll('time.jwm-tolocaltime').forEach($e => {
+ const dateTime = new Date($e.dateTime);
+ $e.innerHTML = new Intl.DateTimeFormat(document.documentElement.lang).
+ format(dateTime.toLocaleString());
+});
diff --git a/src/jwebmail/static/src/rendermail.js b/src/jwebmail/static/src/multipart-alt-tabs.js
index 1331913..1331913 100644
--- a/src/jwebmail/static/src/rendermail.js
+++ b/src/jwebmail/static/src/multipart-alt-tabs.js