var mailHopsDisplay = { resultBox: null, resultText: null, resultDetails: null, mailhopsDataPaneHops: null, mailhopsDataPaneSPF: null, mailhopsDataPaneDKIM: null, mailhopsDataPaneMailer: null, mailhopsDataPaneDNSBL: null, mailhopsResultWeather: null, mailhopsUnsubscribe: null, mailHopsAccountMessage: null, mhBox: null, options: null, init: function(options, reload){ this.options = options; this.mhBox = document.getElementById("mailhopsNoficationBox"); this.mhNoteBox = document.getElementById("mailhopsNotification"); 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"); this.mailHopsAccountMessage = document.getElementById("mailHopsAccountMessage"); this.mailhopsDataPaneHops = document.getElementById("mailhopsDataPaneHops"); //auth this.mailhopsDataPaneSPF = document.getElementById("mailhopsDataPaneSPF"); this.mailhopsDataPaneDKIM = document.getElementById("mailhopsDataPaneDKIM"); this.mailhopsDataPaneMailer = document.getElementById("mailhopsDataPaneMailer"); this.mailhopsDataPaneDNSBL = document.getElementById("mailhopsDataPaneDNSBL"); //wait for message to be selected before showing if (!reload && this.mhBox) this.mhBox.style.display = 'none'; //event listner for route click to launch map this.mailhopsDataPaneDNSBL.addEventListener("click", function () { if(this.hasAttribute('data-ip')) mailHopsUtils.launchSpamHausURL( this.getAttribute('data-ip') ); }); this.resultText.addEventListener("click", function () { if(this.value.indexOf('Rate Limit')!==-1) window.openDialog("chrome://mailhops/content/preferences.xul","","chrome, dialog, modal, centerscreen").focus(); else if(this.hasAttribute('data-route')) mailHopsUtils.launchMap( String(this.getAttribute('data-route')), options ); }); this.mailhopsResultWeather.addEventListener("click", function () { mailHopsUtils.launchExternalURL(this.getAttribute('href')); }); this.mailHopsAccountMessage.addEventListener("click", function () { mailHopsUtils.launchExternalURL(this.getAttribute('href')); this.style.display = 'none'; }); this.mailhopsDataPaneHops.addEventListener("click", function () { this.parentElement.classList.toggle('active'); if(mailHopsDisplay.resultDetails.style.display !== 'block') mailHopsDisplay.resultDetails.style.display = 'block'; else mailHopsDisplay.resultDetails.style.display = 'none'; }); this.mailhopsUnsubscribe.addEventListener("click", function () { if(this.getAttribute('href')) mailHopsUtils.launchExternalURL(this.getAttribute('href')); }); if(!!options.bar_color) this.mhNoteBox.style.background = options.bar_color; else this.mhNoteBox.style.background = ''; if(!!options.font_size) this.mhNoteBox.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 ){ this.mailhopsUnsubscribe.style.display='none'; if(header_unsubscribe){ this.mailhopsUnsubscribe.style.display=''; var listArr=header_unsubscribe.split(','); var href=''; if(listArr.length){ for(var h=0;h',''); if(href.indexOf('mailto:')!=-1){ if(href.toLowerCase().indexOf('subject=')==-1){ if(href.indexOf('?')==-1) href+='?subject=Unsubscribe'; else href+='&subject=Unsubscribe'; } } this.mailhopsUnsubscribe.setAttribute('href',href); } } } }, auth: function( header_xmailer, header_useragent, header_xmimeole, header_auth, header_spf ){ //SPF if(header_spf){ header_spf=header_spf.replace(/^\s+/,""); var headerSPFArr=header_spf.split(' '); this.mailhopsDataPaneSPF.setAttribute('value','SPF: '+headerSPFArr[0]); this.mailhopsDataPaneSPF.style.backgroundImage = "url('chrome://mailhops/content/images/auth/"+headerSPFArr[0]+".png')"; this.mailhopsDataPaneSPF.setAttribute('tooltiptext',header_spf+'\n'+mailHopsUtils.spf(headerSPFArr[0])); this.mailhopsDataPaneSPF.style.display='block'; } else { this.mailhopsDataPaneSPF.style.display='none'; } //Authentication-Results //http://tools.ietf.org/html/rfc5451 if(header_auth){ var headerAuthArr=header_auth.split(';'); var dkim_result; var spf_result; for(var h=0;h 0) distanceText = mailHopsUtils.addCommas(Math.round(response.distance.kilometers))+' km traveled'; else if(response.distance.miles > 0) distanceText = mailHopsUtils.addCommas(Math.round(response.distance.miles))+' mi traveled'; } else if(displayText=='') displayText = ' Local message.'; } if(!!message.time && message.time >= 0){ message.time = message.time/1000; if(message.time < 60) distanceText += ' in '+message.time+' sec.'; else if(message.time < 3600) //something is wrong if it takes this long distanceText += ' in '+Math.round(message.time/60)+' min.'; else //something is wrong if it takes this long distanceText += ' in '+Math.round(message.time/60/60)+' hr.'; } if(header_route) this.resultText.setAttribute("data-route", header_route); else this.resultText.removeAttribute("data-route"); this.resultText.setAttribute('value', displayText+' ( '+distanceText+' )'); this.resultText.style.backgroundImage = "url('"+image+"')"; if(meta && meta.message){ this.mailHopsAccountMessage.style.display = 'inline'; if(meta.message.text) this.mailHopsAccountMessage.value = meta.message.text; if(meta.message.url) this.mailHopsAccountMessage.setAttribute('href', meta.message.url); } else { this.mailHopsAccountMessage.style.display = 'none'; } }, //end route toggleMailHopsBar: function(show){ if(show && this.mhBox.style.display == 'none') this.mhBox.style.display = ''; else if(!show && this.mhBox.style.display == '') this.mhBox.style.display = 'none'; } };