1
0
mirror of https://github.com/MailHops/mailhops-plugin.git synced 2025-05-17 14:50:08 -07:00

Moved MailHops to a notification bar

This commit is contained in:
Andrew Van Tassel 2016-12-26 11:28:59 -07:00
parent f903960c99
commit 06be6f05e7
15 changed files with 635 additions and 163 deletions

View File

@ -10,7 +10,9 @@ locale mailhops ru jar:chrome/mailhops.jar!/locale/ru/
locale mailhops zh-CN jar:chrome/mailhops.jar!/locale/zh-CN/ locale mailhops zh-CN jar:chrome/mailhops.jar!/locale/zh-CN/
# Postbox # Postbox
overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://mailhops/content/pb-overlay.xul application=postbox@postbox-inc.com # overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://mailhops/content/pb-overlay.xul application=postbox@postbox-inc.com
overlay chrome://messenger/content/mailWindowOverlay.xul chrome://mailhops/content/msgNotificationBar.xul application=postbox@postbox-inc.com
# Thunberbird # Thunberbird
overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://mailhops/content/tb-overlay.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6} # overlay chrome://messenger/content/msgHdrViewOverlay.xul chrome://mailhops/content/tb-overlay.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}
overlay chrome://messenger/content/mailWindowOverlay.xul chrome://mailhops/content/msgNotificationBar.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -39,7 +39,7 @@ mailHops.init = function() {
//load preferences //load preferences
mailHops.loadPref(); mailHops.loadPref();
document.getElementById("mailhopsDataPanePrefsLink").addEventListener("click", function () { document.getElementById("mailhopsLogo").addEventListener("click", function () {
window.openDialog("chrome://mailhops/content/preferences.xul","","chrome, dialog, modal, centerscreen").focus(); window.openDialog("chrome://mailhops/content/preferences.xul","","chrome, dialog, modal, centerscreen").focus();
}); });
@ -63,7 +63,6 @@ mailHops.loadPref = function()
mailHops.options.show_details = mailHops.getCharPref('mail.mailHops.show_details','true')=='true'?true:false; 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_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; mailHops.options.show_auth = mailHops.getCharPref('mail.mailHops.show_auth','true')=='true'?true:false;
mailHops.options.show_lists = mailHops.getCharPref('mail.mailHops.show_lists','true')=='true'?true:false;
//Details options //Details options
mailHops.options.show_host = mailHops.getCharPref('mail.mailHops.show_host','true')=='true'?true:false; mailHops.options.show_host = mailHops.getCharPref('mail.mailHops.show_host','true')=='true'?true:false;
@ -174,8 +173,7 @@ mailHops.getRoute = function(){
var headXMimeOLE = (mailHops.options.show_auth && mailHops.options.show_mailer) ? mailHops.headers.extractHeader ( "X-MimeOLE" , 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 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 headAuth = mailHops.options.show_auth ? mailHops.headers.extractHeader ( "Authentication-Results" , false ) : null;
//lists box var headListUnsubscribe = mailHops.headers.extractHeader ( "List-Unsubscribe" , false ) ;
var headListUnsubscribe = mailHops.options.show_lists ? mailHops.headers.extractHeader ( "List-Unsubscribe" , false ) : null;
var all_ips = new Array(); var all_ips = new Array();
var rline = '',firstDate=headDate,lastDate; var rline = '',firstDate=headDate,lastDate;
@ -183,9 +181,7 @@ mailHops.getRoute = function(){
mailHops.message.secure = []; mailHops.message.secure = [];
mailHops.message.time = null; mailHops.message.time = null;
if(mailHops.options.show_lists){
mailHopsDisplay.lists( headListUnsubscribe ); mailHopsDisplay.lists( headListUnsubscribe );
}
if(mailHops.options.show_auth){ if(mailHops.options.show_auth){
mailHopsDisplay.auth( headXMailer, headUserAgent, headXMimeOLE, headAuth, headReceivedSPF ); mailHopsDisplay.auth( headXMailer, headUserAgent, headXMimeOLE, headAuth, headReceivedSPF );

View File

@ -0,0 +1,348 @@
var mailHopsDisplay =
{
resultBox: null,
resultText: null,
resultDetails: null,
container: null,
mailhopsDataPaneSPF: null,
mailhopsDataPaneDKIM: null,
mailhopsDataPaneMailer: null,
mailhopsDataPaneDNSBL: null,
mailhopsResultWeather: null,
mailhopsUnsubscribe: null,
options: null,
init: function(options){
this.options = options;
this.container = document.getElementById("mailhopsBox");
this.resultBox = document.getElementById("mailhopsResult");
this.resultText = document.getElementById("mailhopsResultText");
this.mailhopsResultWeather = document.getElementById("mailhopsResultWeather");
this.resultDetails = document.getElementById("mailhopsDataPaneDetails");
//auth
this.mailhopsDataPaneSPF = document.getElementById("mailhopsDataPaneSPF");
this.mailhopsDataPaneDKIM = document.getElementById("mailhopsDataPaneDKIM");
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 () {
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 );
});
},
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<listArr.length;h++){
href = listArr[h].replace('<','').replace('>','');
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<headerAuthArr.length;h++){
if(headerAuthArr[h].indexOf('dkim=')!=-1){
dkim_result = headerAuthArr[h];
if(header_spf)
break;
}
if(!header_spf && headerAuthArr[h].indexOf('spf=')!=-1){
spf_result = headerAuthArr[h];
if(dkim_result)
break;
}
}
if(this.options.show_dkim && dkim_result){
dkim_result=dkim_result.replace(/^\s+/,"");
var dkimArr=dkim_result.split(' ');
this.mailhopsDataPaneDKIM.setAttribute('value','DKIM: '+dkimArr[0].replace('dkim=',''));
this.mailhopsDataPaneDKIM.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/'+dkimArr[0].replace('dkim=','')+'.png)';
this.mailhopsDataPaneDKIM.setAttribute('tooltiptext',dkim_result+'\n'+mailHopsUtils.dkim(dkimArr[0].replace('dkim=','')));
this.mailhopsDataPaneDKIM.style.display='block';
} else {
this.mailhopsDataPaneDKIM.style.display='none';
}
if(this.options.show_spf && spf_result){
spf_result=spf_result.replace(/^\s+/,"");
var spfArr=spf_result.split(' ');
this.mailhopsDataPaneSPF.setAttribute('value','SPF: '+spfArr[0].replace('spf=',''));
this.mailhopsDataPaneSPF.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/'+spfArr[0].replace('spf=','')+'.png)';
this.mailhopsDataPaneSPF.setAttribute('tooltiptext',spf_result+'\n'+mailHopsUtils.spf(spfArr[0].replace('spf=','')));
this.mailhopsDataPaneSPF.style.display='block';
}
} else {
this.mailhopsDataPaneDKIM.style.display='none';
}
//X-Mailer, User-Agent or X-MimeOLE
if(header_xmailer){
this.mailhopsDataPaneMailer.style.backgroundImage = 'url(chrome://mailhops/content/images/email.png)';
if(header_xmailer.indexOf('(')!=-1)
this.mailhopsDataPaneMailer.setAttribute('value',header_xmailer.substring(0,header_xmailer.indexOf('(')));
else if(header_xmailer.indexOf('[')!=-1)
this.mailhopsDataPaneMailer.setAttribute('value',header_xmailer.substring(0,header_xmailer.indexOf('[')));
else
this.mailhopsDataPaneMailer.setAttribute('value',header_xmailer);
this.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmailer);
this.mailhopsDataPaneMailer.style.display='block';
} else if(header_useragent){
this.mailhopsDataPaneMailer.style.backgroundImage = 'url(chrome://mailhops/content/images/email.png)';
if(header_useragent.indexOf('(')!=-1)
this.mailhopsDataPaneMailer.setAttribute('value',header_useragent.substring(0,header_useragent.indexOf('(')));
else if(header_useragent.indexOf('[')!=-1)
this.mailhopsDataPaneMailer.setAttribute('value',header_useragent.substring(0,header_useragent.indexOf('[')));
else
this.mailhopsDataPaneMailer.setAttribute('value',header_useragent);
this.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_useragent);
this.mailhopsDataPaneMailer.style.display='block';
} else if(header_xmimeole){
this.mailhopsDataPaneMailer.style.backgroundImage = 'url(chrome://mailhops/content/images/email.png)';
if(header_xmimeole.indexOf('(')!=-1)
header_xmimeole = header_xmimeole.substring(0,header_xmimeole.indexOf('('));
else if(header_xmimeole.indexOf('[')!=-1)
header_xmimeole = header_xmimeole.substring(0,header_xmimeole.indexOf('['));
if(header_xmimeole.indexOf('Produced By ')!=-1)
this.mailhopsDataPaneMailer.setAttribute('value',header_xmimeole.replace('Produced By ',''));
else
this.mailhopsDataPaneMailer.setAttribute('value',header_xmimeole);
this.mailhopsDataPaneMailer.setAttribute('tooltiptext',header_xmimeole);
this.mailhopsDataPaneMailer.style.display='block';
} else {
this.mailhopsDataPaneMailer.style.display='none';
}
},
error: function(status,data){
this.container.removeAttribute("route");
if(data && data.error){
this.resultText.setAttribute('value', status+': '+data.error.message);
this.resultText.setAttribute('tooltiptext',data.error.message);
} else {
this.resultText.setAttribute('value', ' Service Unavailable.');
this.resultText.setAttribute('tooltiptext',' Could not connect to MailHops API.');
}
},
clear: function(no_ips){
this.mailhopsDataPaneDNSBL.style.display = 'none';
this.mailhopsResultWeather.style.display = 'none';
this.resultText.removeAttribute('data-route');
this.resultText.style.backgroundImage = '';
//remove child details
while(this.resultDetails.firstChild) {
this.resultDetails.removeChild(this.resultDetails.firstChild);
}
if(no_ips)
this.resultText.value = ' Looks like a local message';
else
this.resultText.value = ' Looking Up Route...';
},
route: function ( header_route, message, response, meta, lookup_url ){
var displayText=''
, distanceText=''
, image='chrome://mailhops/content/images/local.png'
, weatherRoute=null
, first=null;
//remove child details
while(this.resultDetails.firstChild) {
this.resultDetails.removeChild(this.resultDetails.firstChild);
}
if(response && response.route && response.route.length){
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<response.route.length;i++){
//get the first hop location
if(!first && !response.route[i].private && !response.route[i].client){
first = response.route[i];
if(!!response.route[i].countryCode)
image='chrome://mailhops/content/images/flags/'+response.route[i].countryCode.toLowerCase()+'.png';
this.resultText.setAttribute('tooltiptext','View Map');
}
var menuitem = document.createElement('menuitem');
var label = '';
menuitem.setAttribute('class','menuitem-iconic');
if(response.route[i].countryCode)
menuitem.setAttribute('image','chrome://mailhops/content/images/flags/'+response.route[i].countryCode.toLowerCase()+'.png');
else
menuitem.setAttribute('image','chrome://mailhops/content/images/local.png');
if(response.route[i].city){
if(response.route[i].city && response.route[i].state)
label='Hop #'+(i+1)+' '+response.route[i].city+', '+response.route[i].state;
else
label='Hop #'+(i+1)+' '+response.route[i].city+', '+response.route[i].countryCode;
menuitem.setAttribute('tooltiptext','Click for WhoIs');
menuitem.setAttribute('data-ip',response.route[i].ip);
menuitem.addEventListener("click", function () {
mailHopsUtils.launchWhoIs(this.getAttribute('data-ip'));
}
, false);
} else if(response.route[i].countryName){
label='Hop #'+(i+1)+' '+response.route[i].countryName;
menuitem.setAttribute('tooltiptext','Click for WhoIs');
menuitem.setAttribute('data-ip',response.route[i].ip);
menuitem.addEventListener("click", function () {
mailHopsUtils.launchWhoIs(this.getAttribute('data-ip'));
}
, false);
} else {
label='Hop #'+(i+1)+' Private';
}
label+=' '+response.route[i].ip;
if(response.route[i].host)
label+=' '+response.route[i].host;
if(response.route[i].whois && response.route[i].whois.descr)
label+=' '+response.route[i].whois.descr;
if(response.route[i].whois && response.route[i].whois.netname)
label+=' '+response.route[i].whois.netname;
menuitem.setAttribute('label',label);
//append weather
if(!weatherRoute && !!response.route[i].weather){
weatherRoute = response.route[i];
}
//append details
this.resultDetails.appendChild(menuitem);
//auth & dnsbl
if(!response.route[i].private && response.route[i].dnsbl && response.route[i].dnsbl.listed){
this.mailhopsDataPaneDNSBL.setAttribute('value','Blacklisted '+mailHopsUtils.dnsbl(response.route[i].dnsbl.record,true));
this.mailhopsDataPaneDNSBL.setAttribute('data-ip',response.route[i].ip);
if(response.route[i].dnsbl.record)
this.mailhopsDataPaneDNSBL.setAttribute('tooltiptext','Click for more details.\n'+mailHopsUtils.dnsbl(response.route[i].dnsbl.record));
else
this.mailhopsDataPaneDNSBL.setAttribute('tooltiptext','Click for more details.');
this.mailhopsDataPaneDNSBL.style.backgroundImage = 'url(chrome://mailhops/content/images/auth/bomb.png)';
this.mailhopsDataPaneDNSBL.style.display = 'block';
}
}
}
//set weather of sender
if(weatherRoute){
this.mailhopsResultWeather.style.display = 'block';
this.mailhopsResultWeather.setAttribute('tooltiptext','Weather');
this.mailhopsResultWeather.value = weatherRoute.weather.summary+' '+Math.round(weatherRoute.weather.temp)+'\u00B0';
this.mailhopsResultWeather.style.backgroundImage = 'url('+mailHopsUtils.getWeatherIcon(weatherRoute.weather.icon)+')';
if(weatherRoute.coords)
this.mailhopsResultWeather.setAttribute('href','https://darksky.net/forecast/'+weatherRoute.coords[1]+','+weatherRoute.coords[0]);
else if(weatherRoute.lat)
this.mailhopsResultWeather.setAttribute('href','https://darksky.net/forecast/'+weatherRoute.lat+','+weatherRoute.lng);
}
if(image.indexOf('local')!=-1) {
displayText = ' Local message.';
} else {
if(!!first){
if(!!first.city && !!first.state)
displayText = first.city+', '+first.state;
else if(!!first.city)
displayText = first.city+', '+first.countryCode;
else if(!!first.countryName)
displayText = first.countryName;
}
if(response.distance){
if(this.options.unit=='km' && response.distance.kilometers > 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)+' 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+')';
}//end route
};

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE overlay SYSTEM "chrome://mailhops/locale/strings.dtd" >
<?xml-stylesheet href="chrome://mailhops/skin/mh-notification-styles.css" type="text/css"?>
<overlay id="mailhopsNotificationOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/x-javascript" src="chrome://mailhops/content/utils.js"/>
<script type="application/x-javascript" src="chrome://mailhops/content/msgNotificationBar.js"/>
<script type="application/x-javascript" src="chrome://mailhops/content/mailhops.js"/>
<rows id="msgNotificationBar">
<row id="mailhopsNoficationBox" collapsed="false">
<image id="mailhopsLogo" src="chrome://mailhops/content/images/mailhops32.png" width="32" height="32" tooltiptext="&mailhops_route_nav_options_label;"/>
<hbox id="mailhopsResult" flex="1">
<label id="mailhopsResultText" class="text-link"></label>
<label id="mailhopsResultWeather" class="text-link"></label>
<button type="menu" class="msgHeaderView-button msgHeaderView-flat-button" label="hops" tooltiptext="Click to view route.">
<menupopup id="mailhopsDataPaneDetails">
</menupopup>
</button>
<button id="mailhopsDataPaneRefreshLink" class="msgHeaderView-button msgHeaderView-flat-button" label="&mailhops_route_nav_refresh_label;"></button>
<label id="mailhopsDataPaneMailer" class="auth-item" value="" tooltiptext="Mailer"></label>
<label id="mailhopsDataPaneSPF" class="auth-item" value="" tooltiptext="SPF"></label>
<label id="mailhopsDataPaneDKIM" class="auth-item" value="" tooltiptext="DKIM"></label>
<label id="mailhopsDataPaneDNSBL" class="text-link auth-item" value="" tooltiptext="DNSBL"></label>
<label id="mailhopsUnsubscribe" class="text-link unsubscribe" value="Unsubscribe" tooltiptext="Unsubscribe"></label>
</hbox>
</row>
</rows>
</overlay>

View File

@ -7,6 +7,7 @@ var mailHopsDisplay =
resultContainerDetails: null, resultContainerDetails: null,
resultDetails: null, resultDetails: null,
resultMapLink: null, resultMapLink: null,
resultSlackLink: null,
mailhopsDataPaneSPF: null, mailhopsDataPaneSPF: null,
mailhopsDataPaneDKIM: null, mailhopsDataPaneDKIM: null,
mailhopsDataPaneMailer: null, mailhopsDataPaneMailer: null,
@ -30,6 +31,7 @@ var mailHopsDisplay =
this.resultDetails = document.getElementById ( "mailhopsDataPaneDetails"); this.resultDetails = document.getElementById ( "mailhopsDataPaneDetails");
this.resultMeta = document.getElementById ( "mailhopsDataPaneMeta"); this.resultMeta = document.getElementById ( "mailhopsDataPaneMeta");
this.resultMapLink = document.getElementById ( "mailhopsDataPaneMapLink"); this.resultMapLink = document.getElementById ( "mailhopsDataPaneMapLink");
this.resultSlackLink = document.getElementById ( "mailhopsDataPaneSlackLink");
//auth //auth
this.mailhopsAuthContainer = document.getElementById ( "dataPaneMailHopsAuthContainer"); this.mailhopsAuthContainer = document.getElementById ( "dataPaneMailHopsAuthContainer");
@ -58,16 +60,16 @@ var mailHopsDisplay =
mailHopsUtils.launchSpamHausURL(this.getAttribute('data-ip')); mailHopsUtils.launchSpamHausURL(this.getAttribute('data-ip'));
}); });
this.resultSlackLink.addEventListener("click", function () {
mailHopsUtils.postToWebhook( String(this.getAttribute("data-api_url")), options );
});
//display auth //display auth
if(!this.options.show_auth) if(!this.options.show_auth)
this.displayResultAuth(headXMailer,headUserAgent,headXMimeOLE,headAuth,headReceivedSPF); this.displayResultAuth(headXMailer,headUserAgent,headXMimeOLE,headAuth,headReceivedSPF);
else else
this.mailhopsAuthContainer.style.display='none'; this.mailhopsAuthContainer.style.display='none';
//display unsubscribe link
if(!this.options.show_lists)
this.mailhopsListContainer.style.display='none';
}, //end init }, //end init
lists: function( header_unsubscribe ){ lists: function( header_unsubscribe ){
@ -392,7 +394,7 @@ var mailHopsDisplay =
} }
} }
//append host // append host
if(this.options.show_host && response.route[i].host){ if(this.options.show_host && response.route[i].host){
var host = document.createElement('label'); var host = document.createElement('label');
host.setAttribute('value',response.route[i].host); host.setAttribute('value',response.route[i].host);
@ -403,7 +405,7 @@ var mailHopsDisplay =
this.resultDetails.appendChild(host); this.resultDetails.appendChild(host);
} }
//auth & dnsbl // auth & dnsbl
if(!response.route[i].private && response.route[i].dnsbl && response.route[i].dnsbl.listed){ if(!response.route[i].private && response.route[i].dnsbl && response.route[i].dnsbl.listed){
this.mailhopsDataPaneDNSBL.setAttribute('value','Blacklisted '+mailHopsUtils.dnsbl(response.route[i].dnsbl.record,true)); this.mailhopsDataPaneDNSBL.setAttribute('value','Blacklisted '+mailHopsUtils.dnsbl(response.route[i].dnsbl.record,true));
this.mailhopsDataPaneDNSBL.setAttribute('data-ip',response.route[i].ip); this.mailhopsDataPaneDNSBL.setAttribute('data-ip',response.route[i].ip);
@ -468,10 +470,13 @@ var mailHopsDisplay =
distanceText += ' in '+Math.round(message.time/60/60)+' hrs.'; distanceText += ' in '+Math.round(message.time/60/60)+' hrs.';
} }
if(header_route) if(header_route){
this.resultMapLink.setAttribute("data-route", header_route); this.resultMapLink.setAttribute("data-route", header_route);
else this.resultSlackLink.setAttribute("data-api_url", lookup_url.replace('lookup','map'));
} else {
this.resultMapLink.removeAttribute("data-route"); this.resultMapLink.removeAttribute("data-route");
this.resultSlackLink.removeAttribute("data-api_url");
}
this.resultTextDataPane.style.backgroundImage = 'url('+image+')'; this.resultTextDataPane.style.backgroundImage = 'url('+image+')';
this.resultTextDataPane.value = displayText; this.resultTextDataPane.value = displayText;

View File

@ -67,6 +67,16 @@
<vbox id="mailhopsDataPaneMeta" flex="1"></vbox> <vbox id="mailhopsDataPaneMeta" flex="1"></vbox>
</vbox> </vbox>
<vbox id="dataPaneMailHopsFunContainer" class="dataPaneBox">
<hbox flex="1" pack="start" align="center">
<label class="dataPaneHeader" crop="right" value="&mailhops_header_fun_label;"></label>
<separator class="dataPaneBoxSeparator" flex="1"></separator>
</hbox>
<hbox class="mailHopsLinkContainer">
<vbox><image id="mailhopsDataPaneSlackLink" src="chrome://mailhops/content/images/btn-add-to-slack-122x35.png" width="122" height="35" /></vbox>
</hbox>
</vbox>
</vbox> </vbox>
</overlay> </overlay>

View File

@ -35,11 +35,6 @@ var mailHopPreferences = {
else else
document.getElementById("mailhop.show_meta").checked = false; document.getElementById("mailhop.show_meta").checked = false;
if(pref.getCharPref("mail.mailHops.show_lists",'true')=='true')
document.getElementById("mailhop.show_lists").checked = true;
else
document.getElementById("mailhop.show_lists").checked = false;
if(pref.getCharPref("mail.mailHops.show_auth",'true')=='true') if(pref.getCharPref("mail.mailHops.show_auth",'true')=='true')
document.getElementById("mailhop.show_auth").checked = true; document.getElementById("mailhop.show_auth").checked = true;
else else
@ -135,7 +130,6 @@ var mailHopPreferences = {
pref.setCharPref("mail.mailHops.show_dkim", String(document.getElementById("mailhop.show_dkim").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_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_dnsbl", String(document.getElementById("mailhop.show_dnsbl").checked));
pref.setCharPref("mail.mailHops.show_lists", String(document.getElementById("mailhop.show_lists").checked));
pref.setCharPref("mail.mailHops.show_auth", String(document.getElementById("mailhop.show_auth").checked)); pref.setCharPref("mail.mailHops.show_auth", String(document.getElementById("mailhop.show_auth").checked));
pref.setCharPref("mail.mailHops.debug", String(document.getElementById("mailhop.debug").checked)); pref.setCharPref("mail.mailHops.debug", String(document.getElementById("mailhop.debug").checked));
@ -194,7 +188,7 @@ var mailHopPreferences = {
api_key = this.api_key.value.trim(), api_key = this.api_key.value.trim(),
self = this; self = this;
xmlhttp.open("GET", apiBase+accountURL,true); xmlhttp.open("GET", apiBase+accountURL, true);
xmlhttp.onreadystatechange=function() { xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState===4) { if (xmlhttp.readyState===4) {
try { try {

View File

@ -482,7 +482,6 @@
<groupbox flex="1"> <groupbox flex="1">
<caption label="Display Boxes"/> <caption label="Display Boxes"/>
<checkbox id="mailhop.show_auth" label="Show Auth" checked="true"/> <checkbox id="mailhop.show_auth" label="Show Auth" checked="true"/>
<checkbox id="mailhop.show_lists" label="Show Unsubscribe Links" checked="true"/>
<checkbox id="mailhop.show_meta" label="Show Meta" checked="true"/> <checkbox id="mailhop.show_meta" label="Show Meta" checked="true"/>
</groupbox> </groupbox>
<groupbox flex="1"> <groupbox flex="1">

View File

@ -64,7 +64,6 @@ switch(result){
default: default:
return ''; return '';
} }
}, },
dnsbl: function(result,abbr){ dnsbl: function(result,abbr){
@ -182,10 +181,10 @@ getDistance: function(from, to, unit) {
if(!from || !to || !from['lat'] || !to['lat']) if(!from || !to || !from['lat'] || !to['lat'])
return 0; return 0;
lat = parseFloat(from['lat']); var lat = parseFloat(from['lat']);
lon1 = parseFloat(from['lng']); var lon1 = parseFloat(from['lng']);
lat2 = parseFloat(to['lat']); var lat2 = parseFloat(to['lat']);
lon2 = parseFloat(to['lng']); var lon2 = parseFloat(to['lng']);
unit = unit || 'mi';//mi or km unit = unit || 'mi';//mi or km
lat *= (Math.PI/180); lat *= (Math.PI/180);
@ -193,12 +192,11 @@ getDistance: function(from, to, unit) {
lat2 *= (Math.PI/180); lat2 *= (Math.PI/180);
lon2 *= (Math.PI/180); lon2 *= (Math.PI/180);
dist = 2*Math.asin(Math.sqrt( Math.pow((Math.sin((lat-lat2)/2)),2) + Math.cos(lat)*Math.cos(lat2)*Math.pow((Math.sin((lon1-lon2)/2)),2))) * 6378.137; var dist = 2*Math.asin(Math.sqrt( Math.pow((Math.sin((lat-lat2)/2)),2) + Math.cos(lat)*Math.cos(lat2)*Math.pow((Math.sin((lon1-lon2)/2)),2))) * 6378.137;
if (unit == 'mi') { if (unit == 'mi') {
dist = (dist / 1.609344); dist = (dist / 1.609344);
} }
return dist; return dist;
}, },
@ -211,6 +209,19 @@ getDistance: function(from, to, unit) {
}; };
} }
return ''; return '';
} },
postToWebhook: function(mapUrl,options){
var slackUrl = 'https://hooks.slack.com/services/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';
var xhr = new XMLHttpRequest();
xhr.open("POST", slackUrl, false);
xhr.setRequestHeader("Content-type", "application/json");
xhr.onreadystatechange = function() {
if(xhr.readyState === 4 && xhr.status == 200) {
return JSON.parse(xmlhttp.responseText);
}
}
var payload = {"text":"MailHops <"+mapUrl+"|Map> "};
xhr.send(JSON.stringify(payload));
}
}; };

View File

@ -1,9 +1,9 @@
<!ENTITY mailhops_header_route_label "MailHops Route"> <!ENTITY mailhops_header_route_label "MailHops Route">
<!ENTITY mailhops_header_auth_label "MailHops Mailer/Auth"> <!ENTITY mailhops_header_auth_label "MailHops Mailer/Auth">
<!ENTITY mailhops_header_lists_label "MailHops Lists">
<!ENTITY mailhops_header_meta_label "MailHops Meta"> <!ENTITY mailhops_header_meta_label "MailHops Meta">
<!ENTITY mailhops_header_fun_label "MailHops Fun">
<!ENTITY mailhops_route_nav_map_label "map"> <!ENTITY mailhops_route_nav_map_label "map">
<!ENTITY mailhops_route_nav_details_label "details"> <!ENTITY mailhops_route_nav_details_label "details">
<!ENTITY mailhops_route_nav_refresh_label "refresh"> <!ENTITY mailhops_route_nav_refresh_label "refresh">
<!ENTITY mailhops_route_nav_options_label "options"> <!ENTITY mailhops_route_nav_options_label "Preferences">

View File

@ -2,6 +2,7 @@ mailhops_header_route_label=MailHops Route
mailhops_header_auth_label=MailHops/Auth mailhops_header_auth_label=MailHops/Auth
mailhops_header_lists_label=MailHops Lists mailhops_header_lists_label=MailHops Lists
mailhops_header_meta_label=MailHops Meta mailhops_header_meta_label=MailHops Meta
mailhops_header_fun_label=MailHops Fun
mailhops_route_nav_map_label=map mailhops_route_nav_map_label=map
mailhops_route_nav_details_label=details mailhops_route_nav_details_label=details
mailhops_route_nav_refresh_label=refresh mailhops_route_nav_refresh_label=refresh

View File

@ -0,0 +1,57 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
#mailhopsNoficationBox #mailhopsResultText { padding-left:20px; background-repeat: no-repeat; }
#mailhopsNoficationBox menuitem .menu-iconic-icon { width: 16px; height: 11px; }
#mailhopsNoficationBox .auth-item { display: none; background-repeat: no-repeat; padding-left: 18px; }
#mhTabs .act { padding-left: 20px; background-repeat: no-repeat; outline : none;}
#mailhopsResultWeather { display: none; background-repeat: no-repeat; padding-left: 18px; }
#mailHopsPreferences {
font-family: 'Raleway',Arial,sans-serif;
font-size: 14px;
}
#mailHopsPreferences textbox {
font-size: 14px;
padding: 5px;
color: #777;
}
#mailHopsPreferences tab {
font-size: 14px;
padding: 5px;
color: #333;
}
#mailhopsResult label {
margin-top: 8px;
}
#mailhopsNoficationBox {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 24px;
font-weight: normal;
background: #5E7A9B;
border-bottom: 1px solid #355069;
}
#mailhopsNoficationBox #mailhopsDataPanePrefsLink {
border-radius: 20px;
background-color: #CCC;
letter-spacing: .1em;
right: 0;
}
#mailhopsNoficationBox #mailhopsLogo, #mailhopsNoficationBox #mailhopsResultWeather, #mailhopsNoficationBox #mailhopsResultText{
cursor: pointer;
color: #fff;
}
#mailhopsNoficationBox .unsubscribe {
color: #CCC;
}

View File

@ -151,3 +151,7 @@ button {
.error:before { .error:before {
content: "\f111" content: "\f111"
} }
.mailhopsDataPaneSlackLink{
cursor: pointer;
}