var mailHopsDisplay = { resultTextDataPane: null, resultTextDataPane2: null, resultTextDataPane3: null, resultContainerDataPane: null, resultContainerDetails: null, resultDetails: null, resultMapLink: 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"); //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')); }); //display auth if(!this.options.show_auth) this.displayResultAuth(headXMailer,headUserAgent,headXMimeOLE,headAuth,headReceivedSPF); else this.mailhopsAuthContainer.style.display='none'; //display unsubscribe link if(!this.options.show_lists) this.mailhopsListContainer.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){ if(this.options.client_location){ var client_location = JSON.parse(this.options.client_location); //get distance from last route to client_location and add to response.distance.miles or kilometers if(!response.route[response.route.length-1]['private']){ if(this.options.unit=='km') response.distance.kilometers += mailHopsUtils.getDistance(response.route[response.route.length-1],client_location.route[0],this.options.unit); else response.distance.miles += mailHopsUtils.getDistance(response.route[response.route.length-1],client_location.route[0],this.options.unit); } //push client location to the end of the route response.route.push(client_location.route[0]); } for(var i=0; i 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(header_route) this.resultMapLink.setAttribute("data-route", header_route); else this.resultMapLink.removeAttribute("data-route"); this.resultTextDataPane.style.backgroundImage = 'url('+image+')'; this.resultTextDataPane.value = displayText; this.resultTextDataPane.setAttribute('tooltiptext',displayText+' '+distanceText); if(distanceText){ this.resultTextDataPane2.style.display = 'block'; this.resultTextDataPane2.value = distanceText; this.resultTextDataPane2.setAttribute('tooltiptext',displayText+' '+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 };