From a5bcb7fa8d9223e5f33f9f17e96c8df112484111 Mon Sep 17 00:00:00 2001 From: Andrew Van Tassel Date: Fri, 6 Jan 2017 17:10:21 -0700 Subject: [PATCH] Added display style options --- CHANGELOG.md | 22 ++++++ chrome/content/mailhops.js | 35 ++++----- chrome/content/msgNotificationBar.js | 20 ++++- chrome/content/preferences.js | 86 +++++++++------------- chrome/content/preferences.xul | 47 ++++++++---- chrome/skin/classic/msgNotificationBar.css | 18 ++++- install.rdf | 2 +- 7 files changed, 137 insertions(+), 93 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1057a55..0fb08d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Change Log +## 3.0.1 - 2017-01-07 + +### Added +- Display styles in settings to customize MailHops bar background color, font color and font size + +### Removed +- Display show options, data is now always shown for: + - Unsubscribe link + - Mailer + - DKIM + - SPF + - DNSBL + +## 3.0.0 - 2016-12-26 + +### Added +- MailHops Bar for matching styles across supported mail clients + +### Removed +- Thunderbird specific styles and MailHops bar from the header +- Postbox specific styles and MailHops sidebar display + ## 2.0.0 - 2016-10-10 ### Added diff --git a/chrome/content/mailhops.js b/chrome/content/mailhops.js index c0399b8..9a58dfb 100644 --- a/chrome/content/mailhops.js +++ b/chrome/content/mailhops.js @@ -9,12 +9,15 @@ var mailHops = msgURI: null, isLoaded: false, options: { - 'version':'MailHops Plugin 3.0.0', + 'version':'MailHops Plugin 3.0.1', 'lan':'en', 'unit':'mi', 'api_http':'https://', 'api_host':'api.mailhops.com', 'debug':false, + 'bar_color': '#5E7A9B', + 'font_color': '#FFF', + 'font_size': '14px', 'country_tag':false, 'travel_time_junk':false, 'country_filter':[] @@ -59,20 +62,12 @@ mailHops.loadPref = function() mailHops.options.unit = mailHops.getCharPref('mail.mailHops.unit','mi'); mailHops.options.fkey = mailHops.getCharPref('mail.mailHops.fkey','');//forecast.io api_key - //Display Boxes - mailHops.options.show_details = mailHops.getCharPref('mail.mailHops.show_details','true')=='true'?true:false; - mailHops.options.show_meta = mailHops.getCharPref('mail.mailHops.show_meta','true')=='true'?true:false; - mailHops.options.show_auth = mailHops.getCharPref('mail.mailHops.show_auth','true')=='true'?true:false; + //Display + mailHops.options.bar_color = mailHops.getCharPref('mail.mailHops.bar_color','#5E7A9B'); - //Details options - mailHops.options.show_host = mailHops.getCharPref('mail.mailHops.show_host','true')=='true'?true:false; - mailHops.options.show_secure = mailHops.getCharPref('mail.mailHops.show_secure','true')=='true'?true:false; + mailHops.options.font_color = mailHops.getCharPref('mail.mailHops.font_color','#FFF'); - //Auth options - mailHops.options.show_dkim = mailHops.getCharPref('mail.mailHops.show_dkim','true')=='true'?true:false; - mailHops.options.show_spf = mailHops.getCharPref('mail.mailHops.show_spf','true')=='true'?true:false; - mailHops.options.show_mailer = mailHops.getCharPref('mail.mailHops.show_mailer','true')=='true'?true:false; - mailHops.options.show_dnsbl = mailHops.getCharPref('mail.mailHops.show_dnsbl','true')=='true'?true:false; + mailHops.options.font_size = mailHops.getCharPref('mail.mailHops.font_size','14px'); mailHops.options.debug = mailHops.getCharPref('mail.mailHops.debug','false')=='true'?true:false; @@ -168,11 +163,11 @@ mailHops.getRoute = function(){ var headXReceived = mailHops.headers.extractHeader ( "X-Received" , false ); var headXOrigIP = mailHops.headers.extractHeader ( "X-Originating-IP" , false ); // auth box - var headXMailer = (mailHops.options.show_auth && mailHops.options.show_mailer) ? mailHops.headers.extractHeader ( "X-Mailer" , false ) : null; - var headUserAgent = (mailHops.options.show_auth && mailHops.options.show_mailer) ? mailHops.headers.extractHeader ( "User-Agent" , false ) : null; - var headXMimeOLE = (mailHops.options.show_auth && mailHops.options.show_mailer) ? mailHops.headers.extractHeader ( "X-MimeOLE" , false ) : null; - var headReceivedSPF = (mailHops.options.show_auth && mailHops.options.show_spf) ? mailHops.headers.extractHeader ( "Received-SPF" , false ) : null; - var headAuth = mailHops.options.show_auth ? mailHops.headers.extractHeader ( "Authentication-Results" , false ) : null; + var headXMailer = mailHops.headers.extractHeader ( "X-Mailer" , false ); + var headUserAgent = mailHops.headers.extractHeader ( "User-Agent" , false ); + var headXMimeOLE = mailHops.headers.extractHeader ( "X-MimeOLE" , false ); + var headReceivedSPF = mailHops.headers.extractHeader ( "Received-SPF" , false ); + var headAuth = mailHops.headers.extractHeader ( "Authentication-Results" , false ); var headListUnsubscribe = mailHops.headers.extractHeader ( "List-Unsubscribe" , false ) ; var all_ips = new Array(); @@ -183,9 +178,7 @@ mailHops.getRoute = function(){ mailHopsDisplay.lists( headListUnsubscribe ); - if(mailHops.options.show_auth){ - mailHopsDisplay.auth( headXMailer, headUserAgent, headXMimeOLE, headAuth, headReceivedSPF ); - } + mailHopsDisplay.auth( headXMailer, headUserAgent, headXMimeOLE, headAuth, headReceivedSPF ); //loop through the received headers and parse for IP addresses if (!!headReceived){ diff --git a/chrome/content/msgNotificationBar.js b/chrome/content/msgNotificationBar.js index ed79f0c..8e35548 100644 --- a/chrome/content/msgNotificationBar.js +++ b/chrome/content/msgNotificationBar.js @@ -20,6 +20,7 @@ var mailHopsDisplay = this.resultBox = document.getElementById("mailhopsResult"); this.resultText = document.getElementById("mailhopsResultText"); this.mailhopsResultWeather = document.getElementById("mailhopsResultWeather"); + this.mailhopsUnsubscribe = document.getElementById("mailhopsUnsubscribe"); this.resultDetails = document.getElementById("mailhopsDataPaneDetails"); //auth this.mailhopsDataPaneSPF = document.getElementById("mailhopsDataPaneSPF"); @@ -27,7 +28,6 @@ var mailHopsDisplay = this.mailhopsDataPaneMailer = document.getElementById("mailhopsDataPaneMailer"); this.mailhopsDataPaneDNSBL = document.getElementById("mailhopsDataPaneDNSBL"); - this.mailhopsUnsubscribe = document.getElementById("mailhopsUnsubscribe"); //event listner for route click to launch map this.mailhopsDataPaneDNSBL.addEventListener("click", function () { @@ -42,6 +42,24 @@ var mailHopsDisplay = else if(this.hasAttribute('data-route')) mailHopsUtils.launchMap( String(this.getAttribute('data-route')), options ); }); + + if(!!options.bar_color) + document.getElementById("mailhopsNoficationBox").style.background = options.bar_color; + else + document.getElementById("mailhopsNoficationBox").style.background = ''; + + if(!!options.font_size) + document.getElementById("mailhopsNoficationBox").style.fontSize = options.font_size; + + if(!!options.font_color){ + this.resultText.style.color = options.font_color; + this.mailhopsResultWeather.style.color = options.font_color; + this.mailhopsUnsubscribe.style.color = options.font_color; + this.mailhopsDataPaneSPF.style.color = options.font_color; + this.mailhopsDataPaneDKIM.style.color = options.font_color; + this.mailhopsDataPaneMailer.style.color = options.font_color; + this.mailhopsDataPaneDNSBL.style.color = options.font_color; + } }, lists: function( header_unsubscribe ){ diff --git a/chrome/content/preferences.js b/chrome/content/preferences.js index 0372ccd..8d0aaa1 100644 --- a/chrome/content/preferences.js +++ b/chrome/content/preferences.js @@ -9,7 +9,8 @@ var mailHopPreferences = { valid_api_key: false, fkey: '', //forecast.io api key country_filter: [], - + previewBar: null, + loadPreferences: function(){ this.api_host = document.getElementById("mailhop.api_host"); @@ -20,6 +21,8 @@ var mailHopPreferences = { this.fkey = document.getElementById("mailhop.fkey"); + this.previewBar = document.getElementById("display_preview"); + document.getElementById("mailhop.lang").value = pref.getCharPref("mail.mailHops.lang",'en'); document.getElementById("mailhop.map_provider").value = pref.getCharPref("mail.mailHops.map_provider",'OpenStreetMap.Mapnik'); @@ -29,48 +32,15 @@ var mailHopPreferences = { else document.getElementById("mailhop.unit").selectedIndex = 1; - //Display Box Options - if(pref.getCharPref("mail.mailHops.show_meta",'true')=='true') - document.getElementById("mailhop.show_meta").checked = true; - else - document.getElementById("mailhop.show_meta").checked = false; + //Display Box styles + document.getElementById("mailhop.bar_color").value = pref.getCharPref("mail.mailHops.bar_color",'#5E7A9B'); + document.getElementById("mailhop.font_color").value = pref.getCharPref("mail.mailHops.font_color",'#FFF'); + document.getElementById("mailhop.font_size").value = pref.getCharPref("mail.mailHops.font_size",'14px'); - if(pref.getCharPref("mail.mailHops.show_auth",'true')=='true') - document.getElementById("mailhop.show_auth").checked = true; - else - document.getElementById("mailhop.show_auth").checked = false; - - //Details Options - if(pref.getCharPref("mail.mailHops.show_host",'true')=='true') - document.getElementById("mailhop.show_host").checked = true; - else - document.getElementById("mailhop.show_host").checked = false; - - if(pref.getCharPref("mail.mailHops.show_secure",'true')=='true') - document.getElementById("mailhop.show_secure").checked = true; - else - document.getElementById("mailhop.show_secure").checked = false; - - //Auth Options - if(pref.getCharPref("mail.mailHops.show_spf",'true')=='true') - document.getElementById("mailhop.show_spf").checked = true; - else - document.getElementById("mailhop.show_spf").checked = false; - - if(pref.getCharPref("mail.mailHops.show_dkim",'true')=='true') - document.getElementById("mailhop.show_dkim").checked = true; - else - document.getElementById("mailhop.show_dkim").checked = false; - - if(pref.getCharPref("mail.mailHops.show_mailer",'true')=='true') - document.getElementById("mailhop.show_mailer").checked = true; - else - document.getElementById("mailhop.show_mailer").checked = false; - - if(pref.getCharPref("mail.mailHops.show_dnsbl",'true')=='true') - document.getElementById("mailhop.show_dnsbl").checked = true; - else - document.getElementById("mailhop.show_dnsbl").checked = false; + //Update styles + this.previewBar.style.background = document.getElementById("mailhop.bar_color").value; + this.previewBar.style.color = document.getElementById("mailhop.font_color").value; + this.previewBar.style.fontSize = document.getElementById("mailhop.font_size").value; if(pref.getCharPref("mail.mailHops.debug",'true')=='true') document.getElementById("mailhop.debug").checked = true; @@ -118,19 +88,24 @@ var mailHopPreferences = { mailHopsUtils.launchExternalURL('https://darksky.net'); }); this.saveAPIKey(); + + document.getElementById("mailhop.bar_color").addEventListener("input", function () { + this.previewBar.style.background = this.value; + }); + document.getElementById("mailhop.font_color").addEventListener("input", function () { + this.previewBar.style.color = this.value; + }); + document.getElementById("mailhop.font_size").addEventListener("input", function () { + this.previewBar.style.fontSize = this.value; + }); }, savePreferences: function() { pref.setCharPref("mail.mailHops.lang", document.getElementById("mailhop.lang").selectedItem.value); pref.setCharPref("mail.mailHops.map_provider", document.getElementById("mailhop.map_provider").selectedItem.value); pref.setCharPref("mail.mailHops.unit", document.getElementById("mailhop.unit").selectedItem.value); - pref.setCharPref("mail.mailHops.show_meta", String(document.getElementById("mailhop.show_meta").checked)); - pref.setCharPref("mail.mailHops.show_host", String(document.getElementById("mailhop.show_host").checked)); - pref.setCharPref("mail.mailHops.show_secure", String(document.getElementById("mailhop.show_secure").checked)); - pref.setCharPref("mail.mailHops.show_spf", String(document.getElementById("mailhop.show_spf").checked)); - pref.setCharPref("mail.mailHops.show_dkim", String(document.getElementById("mailhop.show_dkim").checked)); - pref.setCharPref("mail.mailHops.show_mailer", String(document.getElementById("mailhop.show_mailer").checked)); - pref.setCharPref("mail.mailHops.show_dnsbl", String(document.getElementById("mailhop.show_dnsbl").checked)); - pref.setCharPref("mail.mailHops.show_auth", String(document.getElementById("mailhop.show_auth").checked)); + pref.setCharPref("mail.mailHops.bar_color", String(document.getElementById("mailhop.bar_color").value)); + pref.setCharPref("mail.mailHops.font_color", String(document.getElementById("mailhop.font_color").value)); + pref.setCharPref("mail.mailHops.font_size", String(document.getElementById("mailhop.font_size").value)); pref.setCharPref("mail.mailHops.debug", String(document.getElementById("mailhop.debug").checked)); //API vars @@ -256,5 +231,14 @@ var mailHopPreferences = { this.api_http.value=="https://"; this.api_http.selectedIndex = 0; this.api_host.value='api.mailhops.com'; - } + }, + + ResetDisplay: function(){ + document.getElementById("mailhop.bar_color").value = '#5E7A9B'; + document.getElementById("mailhop.font_color").value = '#FFF'; + document.getElementById("mailhop.font_size").value = '14px'; + this.previewBar.style.background = document.getElementById("mailhop.bar_color").value; + this.previewBar.style.color = document.getElementById("mailhop.font_color").value; + this.previewBar.style.fontSize = document.getElementById("mailhop.font_size").value; + } }; diff --git a/chrome/content/preferences.xul b/chrome/content/preferences.xul index a3d6e98..d466059 100644 --- a/chrome/content/preferences.xul +++ b/chrome/content/preferences.xul @@ -480,22 +480,37 @@ - - - - - - - - - - - - - - - - + + + + + MailHops Bar + +
+ + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/chrome/skin/classic/msgNotificationBar.css b/chrome/skin/classic/msgNotificationBar.css index d85b66c..4fa7bfd 100644 --- a/chrome/skin/classic/msgNotificationBar.css +++ b/chrome/skin/classic/msgNotificationBar.css @@ -37,7 +37,6 @@ line-height: 24px; font-weight: normal; background: #5E7A9B; - border-bottom: 1px solid #355069; } #mailhopsNoficationBox #mailhopsDataPanePrefsLink { @@ -47,11 +46,24 @@ right: 0; } -#mailhopsNoficationBox #mailhopsLogo, #mailhopsNoficationBox #mailhopsResultWeather, #mailhopsNoficationBox #mailhopsResultText{ - cursor: pointer; +#mailhopsNoficationBox #mailhopsLogo, +#mailhopsNoficationBox #mailhopsResultText, +#mailhopsNoficationBox #mailhopsResultWeather, +#mailhopsNoficationBox #mailhopsUnsubscribe, +#mailhopsNoficationBox #mailhopsDataPaneDNSBL, +#mailhopsNoficationBox #mailhopsDataPaneDKIM, +#mailhopsNoficationBox #mailhopsDataPaneSPF, +#mailhopsNoficationBox #mailhopsDataPaneMailer { color: #fff; } +#mailhopsNoficationBox #mailhopsLogo, +#mailhopsNoficationBox #mailhopsResultText, +#mailhopsNoficationBox #mailhopsResultWeather, +#mailhopsNoficationBox #mailhopsUnsubscribe { + cursor: pointer; +} + #mailhopsNoficationBox .unsubscribe { color: #CCC; } diff --git a/install.rdf b/install.rdf index 28c42e7..f55cb33 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@ 2 thunderbird@mailhops.com - 3.0.0 + 3.0.1 MailHops MailHops maps the route an email took to get to you. Displaying the senders location, weather, user-agent and authentication used.