1
0
mirror of https://github.com/MailHops/mailhops-plugin.git synced 2025-05-27 19:30:09 -07:00

Added forecast.io weather

Added map modal for links
This commit is contained in:
Andrew Van Tassel 2015-05-29 14:39:47 -06:00
parent 0ec1cc5e26
commit cc04f1ff6d
10 changed files with 139 additions and 103 deletions

View File

@ -10,7 +10,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added
- IPV6 support
- Language support for 'de','en','es','fr','ja','pt-BR','ru','zh-CN'
- What3Words, see README for adding and API key
- What3Words, gets the 3 words for the geo of the sender
- Forecast.IO, gets the weather from the sender, API key needs to be added in preferences
### Fixed
- Fix mismatch IP from Microsoft SMTP id in received header

View File

@ -1,11 +1,29 @@
# MailHops ![MailHops](chrome/content/images/mailhops32.png) Postbox Plugin
# MailHops Postbox Plugin
[www.MailHops.com](http://www.mailhops.com)
<img src="http://www.mailhops.com/images/logos/mailhops395.png" width="200" alt="MailHops logo" title="MailHops" align="right" />
MailHops is an email route API. It does two things:
1. Returns a route an email took based on the Received header IP addresses
2. Returns a map an email took based on the Received header IP addresses
The route will contain DNSBL lookup results, hostname lookup results and What3Words geo locations.
1. Edit files
2. Run [build.sh](build.sh) script
3. Open Postbox and goto Tools->Add-ons and "Install Add-on From File..."
4. Choose mailhops.xpi from build script
```bash
```sh
$ chmod +x build.sh
$ ./build.sh
```
## API
Host your own API
- [API](https://github.com/avantassel/mailhops-api)
## Plugins
- [Postbox](https://github.com/avantassel/mailhops-postbox)
- [Thunderbird](https://github.com/avantassel/mailhops-thunderbird)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1023 B

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -9,6 +9,7 @@ var mailHops =
msgURI: null,
resultTextDataPane: null,
resultTextDataPane2: null,
resultTextDataPane3: null,
resultContainerDataPane: null,
resultDetailsLink: null,
resultContainerDetails: null,
@ -46,6 +47,7 @@ mailHops.init = function()
mailHops.resultContainerDataPane = document.getElementById ( "mailhopsDataPane");
mailHops.resultTextDataPane = document.getElementById ( "mailhopsDataPaneText");
mailHops.resultTextDataPane2 = document.getElementById ( "mailhopsDataPaneText2");
mailHops.resultTextDataPane3 = document.getElementById ( "mailhopsDataPaneText3");
mailHops.resultDetailsLink = document.getElementById ( "mailhopsDataPaneDetailsLink");
mailHops.resultContainerDetails = document.getElementById ( "mailhopsDetailsContainer");
@ -105,6 +107,7 @@ mailHops.loadPref = function()
//get preferences
mailHops.options.lan = mailHops.getCharPref('mail.mailHops.lang','en');
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;
@ -122,18 +125,12 @@ mailHops.loadPref = function()
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;
//Hosting
mailHops.options.use_private = mailHops.getCharPref('mail.mailHops.use_private','false')=='true'?true:false;
mailHops.options.hosting = mailHops.getCharPref('mail.mailHops.hosting','personal');
mailHops.options.debug = mailHops.getCharPref('mail.mailHops.debug','false')=='true'?true:false;
mailHops.options.client_location = mailHops.getCharPref('mail.mailHops.client_location','');
if(mailHops.options.use_private)
mailHops.options.api_url = mailHops.getCharPref('mail.mailHops.api_url','http://api.mailhops.com');
else
mailHops.options.api_url='http://api.mailhops.com';
mailHops.options.api_url = mailHops.getCharPref('mail.mailHops.api_url','http://api.mailhops.com');
if(mailHops.options.client_location == ''){
mailHops.setClientLocation();
}
@ -573,14 +570,15 @@ mailHops.authExplainDNSBL_server = function(result){
};
mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
var displayText='';
var distanceText='';
var image='chrome://mailhops/content/images/local.png';
var city;
var state;
var countryName;
var gotFirst=false;
var secureToolTipText=false;
var displayText=''
, distanceText=''
, image='chrome://mailhops/content/images/local.png'
, city=null
, state=null
, countryName=null
, gotFirst=false
, secureToolTipText=false
, weather=null;
//remove child details
while(mailHops.resultDetails.firstChild) {
@ -639,13 +637,13 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
if(response.route[i].city && response.route[i].state){
label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].city+', '+response.route[i].state);
label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");');
}
else if(response.route[i].countryName){
label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].countryName);
label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");');
}
else
label.setAttribute('value','Hop #'+(i+1)+' Private');
}
else if(response.route[i].countryName){
label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].countryName);
label.setAttribute('onclick','mailHops.launchWhoIs("'+response.route[i].ip+'");');
}
else
label.setAttribute('value','Hop #'+(i+1)+' Private');
//build tooltip
var tiptext = response.route[i].ip;
@ -664,6 +662,11 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
//append details
mailHops.resultDetails.appendChild(label);
//append weather
if(!weather && response.route[i].weather){
weather = response.route[i].weather;
}
if(mailHops.options.show_secure){
//reset the tooltip
secureToolTipText=mailHops.getSecureTrans(response.route[i].ip);
@ -750,6 +753,14 @@ mailHops.displayResult = function ( header_route, response, meta, lookup_url ){
} else {
mailHops.resultTextDataPane2.style.display = 'none';
}
//set weather of sender
if(weather){
mailHops.resultTextDataPane3.style.display = 'block';
mailHops.resultTextDataPane3.value = weather.summary+' '+Math.round(weather.temp)+'\u00B0';
mailHops.resultTextDataPane3.style.backgroundImage = 'url('+mailHops.getWeatherIcon(weather.icon)+')';
}
//show the detail link
mailHops.resultDetailsLink.style.display = 'block';
mailHops.resultMapLink.style.display = 'block';
@ -773,14 +784,6 @@ mailHops.getSecureTrans = function(ip){
return false;
};
mailHops.isDay = function(){
var d = new Date();
if(d.getHours()>7 && d.getHours()<19)
return true;
else
return false;
};
//display the connection error message
mailHops.displayError = function(data){
mailHops.resultMapLink.removeAttribute("route");
@ -800,6 +803,9 @@ mailHops.displayError = function(data){
mailHops.resultTextDataPane2.value = '';
mailHops.resultTextDataPane2.style.backgroundImage = '';
mailHops.resultTextDataPane2.setAttribute('tooltiptext','');
mailHops.resultTextDataPane3.style.display = 'none';
mailHops.resultTextDataPane3.value = '';
};
mailHops.getErrorTitle = function(error_code){
@ -831,6 +837,9 @@ mailHops.clearRoute = function(){
mailHops.resultTextDataPane2.style.backgroundImage = '';
mailHops.resultTextDataPane2.setAttribute('tooltiptext','');
mailHops.resultTextDataPane3.style.display = 'none';
mailHops.resultTextDataPane3.value = '';
//remove child details
while(mailHops.resultDetails.firstChild) {
mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild);
@ -924,7 +933,10 @@ mailHops.lookupRoute = function(header_route){
//import nativeJSON
var nativeJSON = Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON);
var lookupURL = mailHops.options.api_url+'/v1/lookup/?pb&app='+mailHops.appVersion+'&r='+String(header_route)+'&l='+mailHops.options.lan;
var lookupURL = mailHops.options.api_url+'/v1/lookup/?pb&app='+mailHops.appVersion+'&r='+String(header_route)+'&l='+mailHops.options.lan+'&u='+mailHops.options.unit;
if(mailHops.options.fkey != '')
lookupURL += '&fkey='+mailHops.options.fkey;
if(mailHops.options.debug)
LOG(lookupURL);
@ -1004,10 +1016,36 @@ mailHops.launchMap = function(route){
if(route != '') {
var lookupURL=mailHops.options.api_url+'/v1/map/?pb&app='+mailHops.appVersion+'&l='+mailHops.options.lan+'&u='+mailHops.options.unit+'&r='+String(route);
if(mailHops.options.fkey != '')
lookupURL += '&fkey='+mailHops.options.fkey;
window.openDialog("chrome://mailhops/content/mailhopsMap.xul","MailHops",'toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,close=yes,width=1024,height=768,resizable=yes', {src: lookupURL});
}
};
// weather.style.backgroundImage = 'url(chrome://mailhops/content/images/weather
mailHops.getWeatherIcon = function(icon){
var forecast_icons = {'clear-day': {'day':'sun', 'night':'sun'}
, 'clear-night': {'day':'clear_night', 'night':'clear_night'}
, 'rain': {'day':'rain','night':'rain'}
, 'snow': {'day':'snow','night':'snow'}
, 'sleet': {'day':'rain','night':'rain'}
, 'wind': {'day':'clouds','night':'clouds'}
, 'fog': {'day':'clouds','night':'clouds'}
, 'cloudy': {'day':'cloudy','night':'cloudy_night'}
, 'partly-cloudy-day': {'day':'cloudy','night':'cloudy'}
, 'partly-cloudy-night': {'day':'cloudy_night','night':'cloudy_night'}
, 'hail': {'day':'rain','night':'rain'}
, 'thunderstorm': {'day':'thunderstorm','night':'thunderstorm'}
, 'tornado': {'day':'thunderstorm','night':'thunderstorm'}
};
var hr = (new Date).getHours();
var time = (hr >= 4 && hr <= 18)?'day':'night';
return 'chrome://mailhops/content/images/weather/'+forecast_icons[icon][time]+'.png';
};
mailHops.saveResults = function(results){
if(!mailHops.msgURI)

View File

@ -18,7 +18,8 @@
<vbox id="mailhopsDataPane" flex="1">
<label id="mailhopsDataPaneText" class="dataPaneAddressitem" tooltiptext=""></label>
<label id="mailhopsDataPaneText2" class="dataPaneAddressitem" tooltiptext=""></label>
<label id="mailhopsDataPaneText2" class="dataPaneAddressitem" tooltiptext=""></label>
<label id="mailhopsDataPaneText3" class="dataPaneAddressitem" tooltiptext=""></label>
</vbox>
<hbox class="mailHopsLinkContainer">

View File

@ -5,20 +5,16 @@ if (!pref)
var mailHopPreferences =
{
use_private: null,
api_url: null,
fkey: '', //forecast.io api key
hosting: null,
loadPreferences: function()
{
this.use_private = document.getElementById("mailhop.use_private");
this.api_url = document.getElementById("mailhop.api_url");
this.hosting = document.getElementById("mailhop.hosting");
this.fkey = document.getElementById("mailhop.fkey");
if(pref.getCharPref("mail.mailHops.lang",'en')=='en')
document.getElementById("mailhop.lang").selectedIndex = 0;
else
@ -35,7 +31,7 @@ var mailHopPreferences =
else
document.getElementById("mailhop.show_details").checked = false;
if(pref.getCharPref("mail.mailHops.show_meta",'false')=='true')
if(pref.getCharPref("mail.mailHops.show_meta",'true')=='true')
document.getElementById("mailhop.show_meta").checked = true;
else
document.getElementById("mailhop.show_meta").checked = false;
@ -51,12 +47,12 @@ var mailHopPreferences =
document.getElementById("mailhop.show_auth").checked = false;
//Details Options
if(pref.getCharPref("mail.mailHops.show_host",'false')=='true')
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",'false')=='true')
if(pref.getCharPref("mail.mailHops.show_secure",'true')=='true')
document.getElementById("mailhop.show_secure").checked = true;
else
document.getElementById("mailhop.show_secure").checked = false;
@ -82,27 +78,14 @@ var mailHopPreferences =
else
document.getElementById("mailhop.show_dnsbl").checked = false;
//Hosting Options
if(pref.getCharPref("mail.mailHops.hosting",'personal')=='personal')
document.getElementById("mailhop.hosting").selectedIndex = 0;
else if(pref.getCharPref("mail.mailHops.hosting",'personal')=='edu')
document.getElementById("mailhop.hosting").selectedIndex = 1;
else
document.getElementById("mailhop.hosting").selectedIndex = 2;
if(pref.getCharPref("mail.mailHops.use_private",'false')=='true'){
document.getElementById("mailhop.use_private").checked = true;
this.api_url.removeAttribute("disabled");
}
else
document.getElementById("mailhop.use_private").checked = false;
if(pref.getCharPref("mail.mailHops.debug",'true')=='true')
document.getElementById("mailhop.debug").checked = true;
else
document.getElementById("mailhop.debug").checked = false;
this.api_url.value = pref.getCharPref("mail.mailHops.api_url",'http://api.mailhops.com');
this.fkey.value = pref.getCharPref("mail.mailHops.fkey",'');
ResetLocation(document.getElementById("mailhop.refresh_location"));
@ -120,25 +103,13 @@ var mailHopPreferences =
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_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.use_private", String(document.getElementById("mailhop.use_private").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.hosting", document.getElementById("mailhop.hosting").selectedItem.value) ;
pref.setCharPref("mail.mailHops.api_url", String(document.getElementById("mailhop.api_url").value)) ;
pref.setCharPref("mail.mailHops.fkey", String(document.getElementById("mailhop.fkey").value)) ;
}
}
function ChangePrivate(item){
if(item.checked){
mailHopPreferences.api_url.removeAttribute("disabled");
mailHopPreferences.api_url.focus();
}
else{
mailHopPreferences.api_url.setAttribute("disabled","true");
mailHopPreferences.api_url.value='http://api.mailhops.com';
}
}
function TestConnection(e){
e.style.backgroundImage = 'url(chrome://mailhops/content/images/loader.gif)';

View File

@ -18,7 +18,7 @@
<tabs>
<tab label="Defaults"/>
<tab label="Display"/>
<tab label="Hosting"/>
<tab label="API &amp; Hosting"/>
<tab label="Current Location"/>
</tabs>
<tabpanels>
@ -38,25 +38,25 @@
</groupbox>
<groupbox>
<caption label="Default Unit"/>
<caption label="Default Units"/>
<radiogroup id="mailhop.unit">
<radio value="mi" label="Miles" selected="true"/>
<radio value="km" label="Kilometers"/>
<radio value="mi" label="Miles and ºF" selected="true"/>
<radio value="km" label="Kilometers and ºC"/>
</radiogroup>
</groupbox>
</tabpanel>
<tabpanel>
<tabpanel>
<groupbox>
<caption label="Display Boxes"/>
<checkbox id="mailhop.show_details" label="Show Details" checked="false"/>
<checkbox id="mailhop.show_details" label="Show Details" 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="false"/>
<checkbox id="mailhop.show_meta" label="Show Meta" checked="true"/>
</groupbox>
<groupbox>
<caption label="Details Options"/>
<label class="mailhopsHostPref"><checkbox id="mailhop.show_host" label="Show Host" checked="false"/></label>
<label class="mailhopsSecurePref"><checkbox id="mailhop.show_secure" label="Show Secure Transmission" checked="false"/></label>
<label class="mailhopsHostPref"><checkbox id="mailhop.show_host" label="Show Host" checked="true"/></label>
<label class="mailhopsSecurePref"><checkbox id="mailhop.show_secure" label="Show Secure Transmission" checked="true"/></label>
</groupbox>
<groupbox>
<caption label="Authentication Options"/>
@ -73,17 +73,22 @@
<description>
MailHops API is also available for download if you would like to host your own.
</description>
<radiogroup id="mailhop.hosting">
<radio value="personal" label="Personal (Free)" selected="true"/>
<radio value="edu" label="Educational (Free)"/>
<radio value="business" label="Business (Not-Free)"/>
</radiogroup>
<checkbox id="mailhop.use_private" label="Yes, I Agree to MailHops terms of use for hosting my own MailHops API." checked="false" oncommand="ChangePrivate(this);"/>
<checkbox id="mailhop.debug" label="Debug" checked="false"/>
<label class="text-link plain" value="MailHops Terms of Use" href="http://www.mailhops.com/terms"/>
<textbox id="mailhop.api_url" value="http://api.mailhops.com" disabled="true"/>
<textbox id="mailhop.api_url" value="http://api.mailhops.com"/>
<label class="text-link plain act" onclick="TestConnection(this);" value="Test Connection" />
<label class="text-link plain act" onclick="ResetConnection();" value="Reset Connection" />
<checkbox id="mailhop.debug" label="Debug" checked="false"/>
<description>
MailHops API uses Forecast.IO to get the weather of the sender, register for an API Key to enable this feature.
</description>
<textbox id="mailhop.fkey" value=""/>
<label class="text-link plain" value="Forecast.IO" href="https://developer.forecast.io/"/>
</groupbox>
</tabpanel>
@ -105,4 +110,4 @@
</tabbox>
</vbox>
</dialog>
</dialog>

View File

@ -12,6 +12,10 @@
padding-right: 14px;
}
button {
padding: 10px;
}
#mailhopsDataPaneDetailsLink.active{
color: #FFF;
margin-left: 10px;
@ -50,7 +54,7 @@
word-wrap: break-word;
}
.mailhopsHost, .mailhopsSecureHost, .mailhopsSecure, .mailhopsW3w {
.mailhopsWeather, .mailhopsHost, .mailhopsSecureHost, .mailhopsSecure, .mailhopsW3w {
margin-left: 30px;
padding-bottom: 2px;
}

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:type>2</em:type>
@ -13,7 +12,6 @@
<em:iconURL>chrome://mailhops/content/images/mailhops32.png</em:iconURL>
<em:homepageURL>http://mailhops.com</em:homepageURL>
<em:creator>Andrew Van Tassel</em:creator>
<em:developer>Andrew Van Tassel</em:developer>
<em:optionsURL>chrome://mailhops/content/preferences.xul</em:optionsURL>
<em:updateURL>https://dl.dropbox.com/u/1533417/mailhops_update.rdf</em:updateURL>
@ -54,7 +52,7 @@
<Description>
<em:locale>fr</em:locale>
<em:name>MailHops</em:name>
<em:description>MailHops mappe la route un email parcouru pour arriver à vous . Utilisation GeoIP il affiche aussi la distance parcourue avec le lieu (ville , état et pays ) de l'expéditeur .</em:description>
<em:description>MailHops mappe la route un email parcouru pour arriver à vous . Utilisation GeoIP il affiche aussi la distance parcourue avec le lieu (ville , état et pays ) de l'expéditeur.</em:description>
</Description>
</em:localized>
@ -70,7 +68,7 @@
<Description>
<em:locale>pt-BR</em:locale>
<em:name>MailHops</em:name>
<em:description>MailHops mapeia a rota um e-mail viajou para chegar até você . Usando GeoIP ele também exibe a distância percorrida , juntamente com a localização (cidade , estado e país ) do remetente .</em:description>
<em:description>MailHops mapeia a rota um e-mail viajou para chegar até você . Usando GeoIP ele também exibe a distância percorrida , juntamente com a localização (cidade , estado e país ) do remetente.</em:description>
</Description>
</em:localized>
@ -78,7 +76,7 @@
<Description>
<em:locale>ru</em:locale>
<em:name>MailHops</em:name>
<em:description>MailHops отображает маршрутэлектронной почты , пройденное , чтобы добраться до вас. Использование GeoIP также отображает расстояние вместе с места (город, штат и страна ) отправителя .</em:description>
<em:description>MailHops отображает маршрутэлектронной почты , пройденное , чтобы добраться до вас. Использование GeoIP также отображает расстояние вместе с места (город, штат и страна ) отправителя.</em:description>
</Description>
</em:localized>

Binary file not shown.