From 72ac705df235aeff35bf77e5409fc399b991e3e9 Mon Sep 17 00:00:00 2001 From: Mihai Moldovan Date: Wed, 17 Apr 2024 11:47:52 +0200 Subject: [PATCH] {content/preferences.html,js/{mailhops,preferences}.js}: prepare option for extra information. The current code only shows the basic auth status and a description of what it means. Some users (i.e., me) would like to see more information, typically the whole header part that is responsible for the decision, so prepare to show this information. This commit does NOT hook it up just yet. This will be done in a later commit. --- content/preferences.html | 16 ++++++++++++++++ js/mailhops.js | 6 +++++- js/preferences.js | 12 ++++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/content/preferences.html b/content/preferences.html index 046c6f4..9a5b8b1 100644 --- a/content/preferences.html +++ b/content/preferences.html @@ -136,6 +136,22 @@

Flag messages as junk if travel time takes longer than normal.

+
+
+ +
+ + +
+
+
+
+ + +
+
+

Show additional information in authentication results, typically contains more header content.

+
diff --git a/js/mailhops.js b/js/mailhops.js index d16d6f2..46e8822 100644 --- a/js/mailhops.js +++ b/js/mailhops.js @@ -18,8 +18,9 @@ class MailHops { theme: 'light', api_http: 'https://', api_host: 'api.Mailhops.com', - debug: false, travel_time_junk: false, + extrainfo: false, + debug: false, country_filter: [] } message = { @@ -68,6 +69,9 @@ class MailHops { if (data.travel_time_junk && data.travel_time_junk != 'off') { this.options.travel_time_junk = Boolean(data.travel_time_junk); } + if (data.extrainfo) { + this.options.extrainfo = Boolean(data.extrainfo); + } if (data.debug) { this.options.debug = Boolean(data.debug); } diff --git a/js/preferences.js b/js/preferences.js index daaae14..ab542ed 100644 --- a/js/preferences.js +++ b/js/preferences.js @@ -3,8 +3,9 @@ const MailHopPreferences = { valid_api_key: false, unit: 'mi', theme: 'light', - debug: false, travel_time_junk: false, + extrainfo: false, + debug: false, owm_key: '', //OpenWeatherMap.org api key countries: [], @@ -78,6 +79,7 @@ const MailHopPreferences = { this.theme = data.theme || 'light'; this.unit = data.unit || 'mi'; this.travel_time_junk = Boolean(data.travel_time_junk); + this.extrainfo = Boolean(data.extrainfo); this.debug = Boolean(data.debug); if (data.countries) { @@ -123,6 +125,11 @@ const MailHopPreferences = { else document.getElementById("travel_time_junk_off").setAttribute('checked', 'checked'); + if (this.extrainfo) + document.getElementById("extrainfo_on").setAttribute('checked', 'checked'); + else + document.getElementById("extrainfo_off").setAttribute('checked', 'checked'); + if (this.debug) document.getElementById("debug_on").setAttribute('checked', 'checked'); else @@ -209,6 +216,7 @@ const MailHopPreferences = { unit: document.querySelector('input[name="unit"]:checked').value, theme: document.querySelector('input[name="theme"]:checked').value, travel_time_junk: document.querySelector('input[name="travel_time_junk"]:checked').value == 'on' ? true : false, + extrainfo: document.querySelector('input[name="extrainfo"]:checked').value == 'on' ? true : false, debug: document.querySelector('input[name="debug"]:checked').value == 'on' ? true : false, countries: self.countries.join(','), }); @@ -318,4 +326,4 @@ const MailHopPreferences = { }; -MailHopPreferences.init(); \ No newline at end of file +MailHopPreferences.init();