var mailHopsDisplay = { resultTextDataPane: null, resultTextDataPane2: null, resultTextDataPane3: null, resultContainerDataPane: null, resultContainerDetails: null, resultDetails: null, resultMapLink: null, resultSlackLink: null, mailhopsDataPaneSPF: null, mailhopsDataPaneDKIM: null, mailhopsDataPaneMailer: null, mailhopsDataPaneDNSBL: null, mailhopsListContainer: null, mailhopsAuthContainer: null, resultListDataPane: null, resultMeta: null, options: null, init: function(options){ this.options = options; this.resultContainerDataPane = document.getElementById ( "mailhopsDataPane"); this.resultTextDataPane = document.getElementById ( "mailhopsDataPaneText"); this.resultTextDataPane2 = document.getElementById ( "mailhopsDataPaneText2"); this.resultTextDataPane3 = document.getElementById ( "mailhopsDataPaneText3"); this.resultContainerDetails = document.getElementById ( "mailhopsDetailsContainer"); this.resultDetails = document.getElementById ( "mailhopsDataPaneDetails"); this.resultMeta = document.getElementById ( "mailhopsDataPaneMeta"); this.resultMapLink = document.getElementById ( "mailhopsDataPaneMapLink"); this.resultSlackLink = document.getElementById ( "mailhopsDataPaneSlackLink"); //auth this.mailhopsAuthContainer = document.getElementById ( "dataPaneMailHopsAuthContainer"); this.mailhopsDataPaneSPF = document.getElementById ( "mailhopsDataPaneSPF"); this.mailhopsDataPaneDKIM = document.getElementById ( "mailhopsDataPaneDKIM"); this.mailhopsDataPaneMailer = document.getElementById ( "mailhopsDataPaneMailer"); this.mailhopsDataPaneDNSBL = document.getElementById ( "mailhopsDataPaneDNSBL"); //list this.mailhopsListContainer = document.getElementById ( "dataPaneMailHopsListContainer"); this.resultListDataPane = document.getElementById ( "mailhopsListDataPane"); if(this.options.show_meta) document.getElementById('dataPaneMailHopsMetaContainer').style.display=''; else document.getElementById('dataPaneMailHopsMetaContainer').style.display='none'; //event listner for route click to launch map this.resultMapLink.addEventListener("click", function () { if(this.hasAttribute("data-route")) mailHopsUtils.launchMap( String(this.getAttribute("data-route")), options ); }); this.mailhopsDataPaneDNSBL.addEventListener("click", function () { if(this.hasAttribute('data-ip')) mailHopsUtils.launchSpamHausURL(this.getAttribute('data-ip')); }); this.resultSlackLink.addEventListener("click", function () { mailHopsUtils.postToWebhook( String(this.getAttribute("data-api_url")), options ); }); //display auth if(!this.options.show_auth) this.displayResultAuth(headXMailer,headUserAgent,headXMimeOLE,headAuth,headReceivedSPF); else this.mailhopsAuthContainer.style.display='none'; }, //end init lists: function( header_unsubscribe ){ while(this.resultListDataPane.firstChild) { this.resultListDataPane.removeChild(this.resultListDataPane.firstChild); } this.mailhopsListContainer.style.display=''; if(header_unsubscribe){ var listArr=header_unsubscribe.split(','); var href=''; if(listArr.length){ for(var h=0;h',''); var label = document.createElement('label'); label.setAttribute('class','text-link dataPaneURLitem'); if(href.indexOf('mailto:')!=-1){ label.setAttribute('value','Unsubscribe via Email'); if(href.toLowerCase().indexOf('subject=')==-1){ if(href.indexOf('?')==-1) href+='?subject=Unsubscribe'; else href+='&subject=Unsubscribe'; } } else{ label.setAttribute('value','Unsubscribe via Web'); } label.setAttribute('tooltiptext',href); label.setAttribute('href',href); this.resultListDataPane.appendChild(label); } } } }, auth: function( header_xmailer, header_useragent, header_xmimeole, header_auth, header_spf ){ this.mailhopsAuthContainer.style.display=''; //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 != null){ 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)+' hrs.'; } if(header_route){ this.resultMapLink.setAttribute("data-route", header_route); this.resultSlackLink.setAttribute("data-api_url", lookup_url.replace('lookup','map')); } else { this.resultMapLink.removeAttribute("data-route"); this.resultSlackLink.removeAttribute("data-api_url"); } this.resultTextDataPane.style.backgroundImage = 'url('+image+')'; this.resultTextDataPane.value = displayText; if(distanceText){ this.resultTextDataPane2.style.display = 'block'; this.resultTextDataPane2.value = ' ( '+distanceText+' )'; } else { this.resultTextDataPane2.style.display = 'none'; } //set weather of sender if(weather){ this.resultTextDataPane3.style.display = 'block'; this.resultTextDataPane3.setAttribute('tooltiptext',new Date(weather.time*1000)); this.resultTextDataPane3.value = weather.summary+' '+Math.round(weather.temp)+'\u00B0'; this.resultTextDataPane3.style.backgroundImage = 'url('+mailHopsUtils.getWeatherIcon(weather.icon)+')'; } //show the detail link this.resultMapLink.style.display = 'block'; this.resultContainerDetails.style.display = 'block'; } //end route };