mirror of
https://github.com/MailHops/mailhops-plugin.git
synced 2025-05-18 15:20:08 -07:00
Fixed styles and reload of datapane
This commit is contained in:
parent
8500b667bb
commit
724d266f9a
Binary file not shown.
Before Width: | Height: | Size: 723 B After Width: | Height: | Size: 1.6 KiB |
@ -1,8 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* @author: Andrew Van Tassel
|
* @author: Andrew Van Tassel
|
||||||
* @email: andrew@andrewvantassel.com
|
* @email: andrew@andrewvantassel.com
|
||||||
* @website: http://mailhops.com
|
* @website: http://mailhops.com*
|
||||||
* @TODO: cache result and display country flag in column
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var mailHops =
|
var mailHops =
|
||||||
@ -10,31 +9,61 @@ var mailHops =
|
|||||||
resultTextDataPane: null,
|
resultTextDataPane: null,
|
||||||
resultTextDataPane2: null,
|
resultTextDataPane2: null,
|
||||||
resultContainerDataPane: null,
|
resultContainerDataPane: null,
|
||||||
|
resultDetailsLink: null,
|
||||||
|
resultContainerDetails: null,
|
||||||
|
resultDetails: null,
|
||||||
|
resultMapLink: null,
|
||||||
isLoaded: false,
|
isLoaded: false,
|
||||||
|
showDetails: false,
|
||||||
map: 'goog',
|
map: 'goog',
|
||||||
unit: 'mi',
|
unit: 'mi',
|
||||||
appVersion: 'MailHops Postbox 0.4.7'
|
appVersion: 'MailHops Postbox 0.4.8'
|
||||||
}
|
}
|
||||||
|
|
||||||
mailHops.startLoading = function()
|
mailHops.init = function()
|
||||||
{
|
{
|
||||||
|
//load preferences
|
||||||
|
mailHops.loadPref();
|
||||||
|
|
||||||
mailHops.isLoaded = true;
|
mailHops.isLoaded = true;
|
||||||
|
|
||||||
mailHops.resultContainerDataPane = document.getElementById ( "mailhopsDataPane");
|
mailHops.resultContainerDataPane = document.getElementById ( "mailhopsDataPane");
|
||||||
mailHops.resultTextDataPane = document.getElementById ( "mailhopsDataPaneText");
|
mailHops.resultTextDataPane = document.getElementById ( "mailhopsDataPaneText");
|
||||||
mailHops.resultTextDataPane2 = document.getElementById ( "mailhopsDataPaneText2");
|
mailHops.resultTextDataPane2 = document.getElementById ( "mailhopsDataPaneText2");
|
||||||
|
|
||||||
//get preferences
|
mailHops.resultDetailsLink = document.getElementById ( "mailhopsDataPaneDetailsLink");
|
||||||
mailHops.map = mailHops.getCharPref('mail.mailHops.map','goog');
|
mailHops.resultContainerDetails = document.getElementById ( "mailhopsDetailsContainer");
|
||||||
mailHops.unit = mailHops.getCharPref('mail.mailHops.unit','mi');
|
mailHops.resultDetails = document.getElementById ( "mailhopsDataPaneDetails");
|
||||||
|
|
||||||
|
mailHops.resultMapLink = document.getElementById ( "mailhopsDataPaneMapLink");
|
||||||
|
|
||||||
//event listner for route click to launch map
|
//event listner for route click to launch map
|
||||||
mailHops.resultContainerDataPane.addEventListener("click", function () {
|
mailHops.resultMapLink.addEventListener("click", function () {
|
||||||
var route = this.getAttribute("route");
|
var route = this.getAttribute("route");
|
||||||
if(route)
|
if(route)
|
||||||
mailHops.launchMap(String(route));
|
mailHops.launchMap(String(route));
|
||||||
}
|
}
|
||||||
, false);
|
, false);
|
||||||
} ;
|
mailHops.resultDetailsLink.addEventListener("click", function () {
|
||||||
|
if(mailHops.resultContainerDetails.style.display=='none'){
|
||||||
|
mailHops.resultContainerDetails.style.display = 'block';
|
||||||
|
mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink active');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
mailHops.resultContainerDetails.style.display = 'none';
|
||||||
|
mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
mailHops.loadPref = function()
|
||||||
|
{
|
||||||
|
//get preferences
|
||||||
|
mailHops.map = mailHops.getCharPref('mail.mailHops.map','goog');
|
||||||
|
mailHops.unit = mailHops.getCharPref('mail.mailHops.unit','mi');
|
||||||
|
mailHops.showDetails = mailHops.getCharPref('mail.mailHops.show_details','false')=='true'?true:false;
|
||||||
|
};
|
||||||
|
|
||||||
mailHops.StreamListener =
|
mailHops.StreamListener =
|
||||||
{
|
{
|
||||||
@ -72,9 +101,9 @@ mailHops.StreamListener =
|
|||||||
{
|
{
|
||||||
mailHops.headers = Components.classes["@mozilla.org/messenger/mimeheaders;1"].createInstance ( Components.interfaces.nsIMimeHeaders ) ;
|
mailHops.headers = Components.classes["@mozilla.org/messenger/mimeheaders;1"].createInstance ( Components.interfaces.nsIMimeHeaders ) ;
|
||||||
mailHops.headers.initialize ( this.content , this.content.length ) ;
|
mailHops.headers.initialize ( this.content , this.content.length ) ;
|
||||||
mailHops.dispRoute() ;
|
mailHops.getRoute() ;
|
||||||
}
|
}
|
||||||
} ;
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loop through the header, find out if we have received-from headers
|
* loop through the header, find out if we have received-from headers
|
||||||
@ -96,11 +125,9 @@ mailHops.loadHeaderData = function()
|
|||||||
var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance ( Components.interfaces.nsIMessenger ) ;
|
var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance ( Components.interfaces.nsIMessenger ) ;
|
||||||
var msgService = messenger.messageServiceFromURI ( msgURI ) ;
|
var msgService = messenger.messageServiceFromURI ( msgURI ) ;
|
||||||
msgService.CopyMessage ( msgURI , mailHops.StreamListener , false , null , msgWindow , {} ) ;
|
msgService.CopyMessage ( msgURI , mailHops.StreamListener , false , null , msgWindow , {} ) ;
|
||||||
} ;
|
};
|
||||||
|
|
||||||
mailHops.dispRoute = function()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
mailHops.getRoute = function(){
|
||||||
//IP regex
|
//IP regex
|
||||||
var regexIp=/(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}$/;
|
var regexIp=/(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}$/;
|
||||||
var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}/g;
|
var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)(\/(?:[012]\d?|3[012]?|[456789])){0,1}/g;
|
||||||
@ -149,7 +176,6 @@ var regexAllIp = /(1\d{0,2}|2(?:[0-4]\d{0,1}|[6789]|5[0-5]?)?|[3-9]\d?|0)\.(1\d{
|
|||||||
};
|
};
|
||||||
//another ip check, dates will throw off the regex
|
//another ip check, dates will throw off the regex
|
||||||
mailHops.testIP = function(ip,header){
|
mailHops.testIP = function(ip,header){
|
||||||
|
|
||||||
var retval;
|
var retval;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -174,18 +200,60 @@ mailHops.testIP = function(ip,header){
|
|||||||
retval = true;
|
retval = true;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mailHops.displayResult = function ( image, distance, city, state, countryName, route )
|
mailHops.displayResult = function ( header_route, response ){
|
||||||
{
|
|
||||||
var displayText='';
|
var displayText='';
|
||||||
var distanceText='';
|
var distanceText='';
|
||||||
|
var image= 'chrome://mailhops/content/images/local.png';
|
||||||
|
var city;
|
||||||
|
var state;
|
||||||
|
var countryName;
|
||||||
|
var gotFirst=false;
|
||||||
|
|
||||||
if(image.indexOf('error')!=-1) {
|
//remove child details
|
||||||
displayText = ' There was a problem connecting to MailHops.';
|
while(mailHops.resultDetails.firstChild) {
|
||||||
|
mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild);
|
||||||
}
|
}
|
||||||
else if(image.indexOf('local')!=-1) {
|
|
||||||
|
for(var i=0; i<response.route.length;i++){
|
||||||
|
//get the first hop location
|
||||||
|
if(!gotFirst && !response.route[i].private && !response.route[i].client){
|
||||||
|
if(response.route[i].countryCode)
|
||||||
|
image='chrome://mailhops/content/images/flags/'+response.route[i].countryCode.toLowerCase()+'.png';
|
||||||
|
if(response.route[i].city)
|
||||||
|
city=response.route[i].city;
|
||||||
|
if(response.route[i].state)
|
||||||
|
state=response.route[i].state;
|
||||||
|
if(response.route[i].countryName)
|
||||||
|
countryName=response.route[i].countryName;
|
||||||
|
gotFirst=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var label = document.createElement('label');
|
||||||
|
if(response.route[i].countryCode)
|
||||||
|
label.style.backgroundImage = 'url(chrome://mailhops/content/images/flags/'+response.route[i].countryCode.toLowerCase()+'.png)';
|
||||||
|
else
|
||||||
|
label.style.backgroundImage = 'url(chrome://mailhops/content/images/local.png)';
|
||||||
|
label.setAttribute('class','dataPaneAddressitem mailhopsDetail');
|
||||||
|
if(response.route[i].city && response.route[i].state)
|
||||||
|
label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].city+', '+response.route[i].state);
|
||||||
|
else if(response.route[i].countryName)
|
||||||
|
label.setAttribute('value','Hop #'+(i+1)+' '+response.route[i].countryName);
|
||||||
|
else
|
||||||
|
label.setAttribute('value','Hop #'+(i+1)+' Private');
|
||||||
|
|
||||||
|
if(response.route[i].host)
|
||||||
|
label.setAttribute('tooltiptext',response.route[i].ip+', '+response.route[i].host);
|
||||||
|
else
|
||||||
|
label.setAttribute('tooltiptext',response.route[i].ip);
|
||||||
|
|
||||||
|
//append details
|
||||||
|
mailHops.resultDetails.appendChild(label);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(image.indexOf('local')!=-1) {
|
||||||
displayText = ' Local message.';
|
displayText = ' Local message.';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -193,71 +261,97 @@ mailHops.displayResult = function ( image, distance, city, state, countryName, r
|
|||||||
displayText = city+', '+state;
|
displayText = city+', '+state;
|
||||||
else if(countryName)
|
else if(countryName)
|
||||||
displayText = countryName;
|
displayText = countryName;
|
||||||
if(distance && distance.miles > 0){
|
if(response.distance && response.distance.miles > 0){
|
||||||
if(mailHops.unit=='mi')
|
if(mailHops.unit=='mi')
|
||||||
distanceText =' ( '+mailHops.addCommas(Math.round(distance.miles))+' mi traveled )';
|
distanceText =' ( '+mailHops.addCommas(Math.round(response.distance.miles))+' mi traveled )';
|
||||||
else
|
else
|
||||||
distanceText =' ( '+mailHops.addCommas(Math.round(distance.kilometers))+' km traveled )';
|
distanceText =' ( '+mailHops.addCommas(Math.round(response.distance.kilometers))+' km traveled )';
|
||||||
}
|
}
|
||||||
else if(displayText=='')
|
else if(displayText=='')
|
||||||
displayText = ' Local message.';
|
displayText = ' Local message.';
|
||||||
}
|
}
|
||||||
|
|
||||||
//add event for route api map
|
//add event for route api map
|
||||||
if(mailHops.resultContainerDataPane){
|
mailHops.resultMapLink.setAttribute("route", header_route);
|
||||||
mailHops.resultContainerDataPane.setAttribute("route", route);
|
|
||||||
mailHops.resultTextDataPane.style.backgroundImage = 'url('+image+')';
|
mailHops.resultTextDataPane.style.backgroundImage = 'url('+image+')';
|
||||||
mailHops.resultTextDataPane.value = displayText;
|
mailHops.resultTextDataPane.value = displayText;
|
||||||
mailHops.resultTextDataPane.setAttribute('tooltiptext',displayText+' '+distanceText);
|
mailHops.resultTextDataPane.setAttribute('tooltiptext',displayText+' '+distanceText);
|
||||||
|
|
||||||
mailHops.resultTextDataPane2.value = distanceText;
|
mailHops.resultTextDataPane2.value = distanceText;
|
||||||
mailHops.resultTextDataPane2.setAttribute('tooltiptext',displayText+' '+distanceText);
|
mailHops.resultTextDataPane2.setAttribute('tooltiptext',displayText+' '+distanceText);
|
||||||
|
//show the detail link
|
||||||
|
mailHops.resultDetailsLink.style.display = 'block';
|
||||||
|
mailHops.resultMapLink.style.display = 'block';
|
||||||
|
//show details by default
|
||||||
|
if(mailHops.showDetails){
|
||||||
|
mailHops.resultContainerDetails.style.display = 'block';
|
||||||
|
mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink active');
|
||||||
}
|
}
|
||||||
} ;
|
else{
|
||||||
|
mailHops.resultContainerDetails.style.display = 'none';
|
||||||
|
mailHops.resultDetailsLink.setAttribute('class','text-link dataPaneMoreLink');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//display the connection error message
|
||||||
|
mailHops.displayError = function(){
|
||||||
|
mailHops.resultMapLink.removeAttribute("route");
|
||||||
|
mailHops.resultTextDataPane.style.backgroundImage = 'url(chrome://mailhops/content/images/error.png)';
|
||||||
|
mailHops.resultTextDataPane.value = ' MailHops Failed.';
|
||||||
|
mailHops.resultTextDataPane.setAttribute('tooltiptext',' Could not connect to MailHops.');
|
||||||
|
|
||||||
|
mailHops.resultTextDataPane2.value = distanceText;
|
||||||
|
mailHops.resultTextDataPane2.setAttribute('tooltiptext',' Could not connect to MailHops.');
|
||||||
|
};
|
||||||
|
|
||||||
mailHops.clearRoute = function(){
|
mailHops.clearRoute = function(){
|
||||||
|
|
||||||
if(mailHops.resultContainerDataPane){
|
mailHops.resultContainerDetails.style.display = 'none';
|
||||||
|
mailHops.resultDetailsLink.style.display = 'none';
|
||||||
|
mailHops.resultMapLink.style.display = 'none';
|
||||||
|
|
||||||
mailHops.resultTextDataPane.style.backgroundImage = 'url(chrome://mailhops/content/images/loader.gif)';
|
mailHops.resultTextDataPane.style.backgroundImage = 'url(chrome://mailhops/content/images/loader.gif)';
|
||||||
mailHops.resultTextDataPane.value = ' Looking Up Route';
|
mailHops.resultTextDataPane.value = ' Looking Up Route';
|
||||||
mailHops.resultTextDataPane.setAttribute('tooltiptext','Looking Up Route');
|
mailHops.resultTextDataPane.setAttribute('tooltiptext','Looking Up Route');
|
||||||
|
|
||||||
mailHops.resultTextDataPane2.value = '';
|
mailHops.resultTextDataPane2.value = '';
|
||||||
mailHops.resultTextDataPane2.setAttribute('tooltiptext','');
|
mailHops.resultTextDataPane2.setAttribute('tooltiptext','');
|
||||||
}
|
|
||||||
} ;
|
|
||||||
|
|
||||||
mailHops.setupEventListener = function()
|
//remove child details
|
||||||
{
|
while(mailHops.resultDetails.firstChild) {
|
||||||
|
mailHops.resultDetails.removeChild(mailHops.resultDetails.firstChild);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mailHops.setupEventListener = function(){
|
||||||
if ( mailHops.isLoaded ){
|
if ( mailHops.isLoaded ){
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
mailHops.startLoading() ;
|
mailHops.init() ;
|
||||||
mailHops.registerObserver() ;
|
mailHops.registerObserver() ;
|
||||||
|
|
||||||
var listener = {} ;
|
var listener = {} ;
|
||||||
listener.onStartHeaders = function() { mailHops.clearRoute() ; } ;
|
listener.onStartHeaders = function() { mailHops.clearRoute() ; } ;
|
||||||
listener.onEndHeaders = mailHops.loadHeaderData ;
|
listener.onEndHeaders = mailHops.loadHeaderData ;
|
||||||
gMessageListeners.push ( listener ) ;
|
gMessageListeners.push ( listener ) ;
|
||||||
} ;
|
};
|
||||||
|
|
||||||
//preferences observers
|
//preferences observers
|
||||||
mailHops.registerObserver = function()
|
mailHops.registerObserver = function(){
|
||||||
{
|
|
||||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService ( Components.interfaces.nsIPrefService ) ;
|
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService ( Components.interfaces.nsIPrefService ) ;
|
||||||
mailHops._branch = prefService.getBranch ( "mail.mailHops." ) ;
|
mailHops._branch = prefService.getBranch ( "mail.mailHops." ) ;
|
||||||
mailHops._branch.QueryInterface ( Components.interfaces.nsIPrefBranchInternal ) ;
|
mailHops._branch.QueryInterface ( Components.interfaces.nsIPrefBranchInternal ) ;
|
||||||
mailHops._branch.addObserver ( "" , mailHops , false ) ;
|
mailHops._branch.addObserver ( "" , mailHops , false ) ;
|
||||||
} ;
|
};
|
||||||
|
|
||||||
mailHops.unregisterObserver = function()
|
mailHops.unregisterObserver = function(){
|
||||||
{
|
|
||||||
if ( !mailHops._branch ){
|
if ( !mailHops._branch ){
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
mailHops._branch.removeObserver ( "" , mailHops ) ;
|
mailHops._branch.removeObserver ( "" , mailHops ) ;
|
||||||
} ;
|
};
|
||||||
|
|
||||||
mailHops.observe = function ( aSubject , aTopic , aData )
|
mailHops.observe = function ( aSubject , aTopic , aData )
|
||||||
{
|
{
|
||||||
@ -265,11 +359,11 @@ mailHops.observe = function ( aSubject , aTopic , aData )
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
mailHops.startLoading();
|
//load preferences
|
||||||
} ;
|
mailHops.loadPref();
|
||||||
|
};
|
||||||
|
|
||||||
mailHops.getCharPref = function ( strName , strDefault )
|
mailHops.getCharPref = function ( strName , strDefault ){
|
||||||
{
|
|
||||||
var value;
|
var value;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -282,10 +376,10 @@ mailHops.getCharPref = function ( strName , strDefault )
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ( value ) ;
|
return ( value ) ;
|
||||||
} ;
|
};
|
||||||
|
|
||||||
//mailhops lookup
|
//mailhops lookup
|
||||||
mailHops.lookup = function(route){
|
mailHops.lookup = function(header_route){
|
||||||
|
|
||||||
//setup loading
|
//setup loading
|
||||||
mailHops.clearRoute();
|
mailHops.clearRoute();
|
||||||
@ -295,45 +389,29 @@ mailHops.lookup = function(route){
|
|||||||
|
|
||||||
//call mailhops api for lookup
|
//call mailhops api for lookup
|
||||||
var xmlhttp = new XMLHttpRequest();
|
var xmlhttp = new XMLHttpRequest();
|
||||||
var flag= 'chrome://mailhops/content/images/local.png';
|
|
||||||
var city;
|
|
||||||
var state;
|
|
||||||
var countryName;
|
|
||||||
|
|
||||||
xmlhttp.open("GET", 'http://api.mailhops.com/v1/lookup/?tb&app='+mailHops.appVersion+'&r='+route.toString(),true);
|
xmlhttp.open("GET", 'http://api.mailhops.com/v1/lookup/?tb&app='+mailHops.appVersion+'&r='+String(header_route),true);
|
||||||
xmlhttp.onreadystatechange=function() {
|
xmlhttp.onreadystatechange=function() {
|
||||||
if (xmlhttp.readyState==4) {
|
if (xmlhttp.readyState==4) {
|
||||||
try{
|
try{
|
||||||
var data = nativeJSON.decode(xmlhttp.responseText);
|
var data = nativeJSON.decode(xmlhttp.responseText);
|
||||||
if(data && data.meta.code==200){
|
if(data && data.meta.code==200){
|
||||||
for(var i=0; i<data.response.route.length;i++){
|
|
||||||
if(!data.response.route[i].private && !data.response.route[i].client){
|
|
||||||
if(data.response.route[i].countryCode)
|
|
||||||
flag='chrome://mailhops/content/images/flags/'+data.response.route[i].countryCode.toLowerCase()+'.png';
|
|
||||||
city=data.response.route[i].city;
|
|
||||||
state=data.response.route[i].state;
|
|
||||||
countryName=data.response.route[i].countryName;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//display the result
|
//display the result
|
||||||
mailHops.displayResult(flag,data.response.distance,city,state,countryName,route);
|
mailHops.displayResult(header_route,data.response);
|
||||||
} else {
|
} else {
|
||||||
//display the error
|
//display the error
|
||||||
mailHops.displayResult('chrome://mailhops/content/images/error.png',null,null,null,null,null);
|
mailHops.displayError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ex){
|
catch (ex){
|
||||||
mailHops.displayResult('chrome://mailhops/content/images/error.png',null,null,null,null,null);
|
mailHops.displayError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xmlhttp.send(null);
|
xmlhttp.send(null);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mailHops.addCommas = function(nStr)
|
mailHops.addCommas = function(nStr){
|
||||||
{
|
|
||||||
nStr += '';
|
nStr += '';
|
||||||
var x = nStr.split('.');
|
var x = nStr.split('.');
|
||||||
var x1 = x[0];
|
var x1 = x[0];
|
||||||
@ -345,8 +423,7 @@ mailHops.addCommas = function(nStr)
|
|||||||
return x1 + x2;
|
return x1 + x2;
|
||||||
};
|
};
|
||||||
|
|
||||||
mailHops.launchMap = function(route)
|
mailHops.launchMap = function(route){
|
||||||
{
|
|
||||||
//launch mailhops api map
|
//launch mailhops api map
|
||||||
var openwin = window.openDialog('http://api.mailhops.com/v1/map/?tb&app='+mailHops.appVersion+'&m='+mailHops.map+'&u='+mailHops.unit+'&r='+route,"MailHops",'toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,close=yes,width=732,height=332');
|
var openwin = window.openDialog('http://api.mailhops.com/v1/map/?tb&app='+mailHops.appVersion+'&m='+mailHops.map+'&u='+mailHops.unit+'&r='+route,"MailHops",'toolbar=no,location=no,directories=no,menubar=yes,scrollbars=yes,close=yes,width=732,height=332');
|
||||||
openwin.focus();
|
openwin.focus();
|
||||||
|
@ -14,10 +14,22 @@
|
|||||||
<label class="dataPaneHeader" crop="right" value="Route"></label>
|
<label class="dataPaneHeader" crop="right" value="Route"></label>
|
||||||
<separator class="dataPaneBoxSeparator" flex="1"></separator>
|
<separator class="dataPaneBoxSeparator" flex="1"></separator>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<vbox id="mailhopsDataPane" flex="1">
|
<vbox id="mailhopsDataPane" flex="1">
|
||||||
<label id="mailhopsDataPaneText" class="text-link dataPaneAddressitem" tooltiptext=""></label>
|
<label id="mailhopsDataPaneText" class="dataPaneAddressitem" tooltiptext=""></label>
|
||||||
<label id="mailhopsDataPaneText2" class="text-link dataPaneAddressitem" tooltiptext=""></label>
|
<label id="mailhopsDataPaneText2" class="dataPaneAddressitem" tooltiptext=""></label>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
|
<hbox class="mailHopsLinkContainer">
|
||||||
|
<vbox><label id="mailhopsDataPaneMapLink" class="text-link dataPaneMoreLink" value="map" tooltiptext="Show Route Map"></label></vbox>
|
||||||
|
<vbox><label id="mailhopsDataPaneDetailsLink" class="text-link dataPaneMoreLink" value="details" tooltiptext="Show Route Details"></label></vbox>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
<hbox id="mailhopsDetailsContainer">
|
||||||
|
<vbox id="mailhopsDataPaneDetails" flex="1">
|
||||||
|
</vbox>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
</vbox>
|
</vbox>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
|
@ -7,22 +7,26 @@ var mailHopPreferences =
|
|||||||
{
|
{
|
||||||
loadPreferences: function()
|
loadPreferences: function()
|
||||||
{
|
{
|
||||||
if(mailHops.getCharPref("mail.mailHops.map",'goog')=='goog')
|
if(pref.getCharPref("mail.mailHops.map",'goog')=='goog')
|
||||||
document.getElementById("mailhop.map").selectedIndex = 0;
|
document.getElementById("mailhop.map").selectedIndex = 0;
|
||||||
else
|
else
|
||||||
document.getElementById("mailhop.map").selectedIndex = 1;
|
document.getElementById("mailhop.map").selectedIndex = 1;
|
||||||
if(mailHops.getCharPref("mail.mailHops.unit",'mi')=='mi')
|
|
||||||
|
if(pref.getCharPref("mail.mailHops.unit",'mi')=='mi')
|
||||||
document.getElementById("mailhop.unit").selectedIndex = 0;
|
document.getElementById("mailhop.unit").selectedIndex = 0;
|
||||||
else
|
else
|
||||||
document.getElementById("mailhop.unit").selectedIndex = 1;
|
document.getElementById("mailhop.unit").selectedIndex = 1;
|
||||||
|
|
||||||
|
if(pref.getCharPref("mail.mailHops.show_details",'false')=='true')
|
||||||
|
document.getElementById("mailhop.show_details").checked = true;
|
||||||
|
else
|
||||||
|
document.getElementById("mailhop.show_details").checked = false;
|
||||||
|
|
||||||
} ,
|
} ,
|
||||||
savePreferences: function()
|
savePreferences: function()
|
||||||
{
|
{
|
||||||
mailHopPreferences.setCharPref("mail.mailHops.map", document.getElementById("mailhop.map").selectedItem.value) ;
|
pref.setCharPref("mail.mailHops.map", document.getElementById("mailhop.map").selectedItem.value) ;
|
||||||
mailHopPreferences.setCharPref("mail.mailHops.unit", document.getElementById("mailhop.unit").selectedItem.value) ;
|
pref.setCharPref("mail.mailHops.unit", document.getElementById("mailhop.unit").selectedItem.value) ;
|
||||||
} ,
|
pref.setCharPref("mail.mailHops.show_details", String(document.getElementById("mailhop.show_details").checked)) ;
|
||||||
setCharPref: function( strName , strValue )
|
|
||||||
{
|
|
||||||
pref.setCharPref ( strName , strValue ) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
<radio value="bing" label="Bing"/>
|
<radio value="bing" label="Bing"/>
|
||||||
</radiogroup>
|
</radiogroup>
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
|
||||||
<groupbox>
|
<groupbox>
|
||||||
<caption label="Default Unit"/>
|
<caption label="Default Unit"/>
|
||||||
<radiogroup id="mailhop.unit">
|
<radiogroup id="mailhop.unit">
|
||||||
@ -28,6 +29,11 @@
|
|||||||
<radio value="km" label="Kilometers"/>
|
<radio value="km" label="Kilometers"/>
|
||||||
</radiogroup>
|
</radiogroup>
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
|
||||||
|
<groupbox>
|
||||||
|
<caption label="Display Options"/>
|
||||||
|
<checkbox id="mailhop.show_details" label="Show Details" checked="false"/>
|
||||||
|
</groupbox>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
</dialog>
|
</dialog>
|
||||||
|
@ -5,3 +5,49 @@
|
|||||||
#mailhopsResultText {padding-left:4px;}
|
#mailhopsResultText {padding-left:4px;}
|
||||||
|
|
||||||
#mailHopsResultImage {padding-left:4px;display: none;}
|
#mailHopsResultImage {padding-left:4px;display: none;}
|
||||||
|
|
||||||
|
#mailhopsDataPaneDetailsLink{
|
||||||
|
margin-left: 10px;
|
||||||
|
text-align: center;
|
||||||
|
padding-right: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mailhopsDataPaneDetailsLink.active{
|
||||||
|
color: #FFF;
|
||||||
|
margin-left: 10px;
|
||||||
|
background-color: #98a5b3;
|
||||||
|
-moz-border-radius: 20px;
|
||||||
|
-webkit-border-radius: 20px;
|
||||||
|
-khtml-border-radius: 20px;
|
||||||
|
border-radius: 20px;
|
||||||
|
text-align: center;
|
||||||
|
padding-right: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mailhopsDetail{
|
||||||
|
padding-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mailHopsLinkContainer{
|
||||||
|
padding-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mailhopsDetailsContainer{
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
display: none;
|
||||||
|
border: 1px solid #e1e2e5;
|
||||||
|
background-color: #f7f8f9;
|
||||||
|
-moz-border-radius: 5px;
|
||||||
|
-webkit-border-radius: 5px;
|
||||||
|
-khtml-border-radius: 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mailhopsDataPaneDetails{
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mailhopsDataPane{
|
||||||
|
padding-bottom: 4px;
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
<em:id>postbox@mailhops.com</em:id>
|
<em:id>postbox@mailhops.com</em:id>
|
||||||
<em:type>2</em:type>
|
<em:type>2</em:type>
|
||||||
<em:name>MailHops</em:name>
|
<em:name>MailHops</em:name>
|
||||||
<em:version>0.4.7</em:version>
|
<em:version>0.4.8</em:version>
|
||||||
<em:description>MailHops maps the route an email traveled to get to you. Using GeoIP it also displays distance traveled along with the location (city, state and country) of the sender.</em:description>
|
<em:description>MailHops maps the route an email traveled to get to you. Using GeoIP it also displays distance traveled along with the location (city, state and country) of the sender.</em:description>
|
||||||
<em:iconURL>chrome://mailhops/content/images/mailhops32.png</em:iconURL>
|
<em:iconURL>chrome://mailhops/content/images/mailhops32.png</em:iconURL>
|
||||||
<em:homepageURL>http://mailhops.com</em:homepageURL>
|
<em:homepageURL>http://mailhops.com</em:homepageURL>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user