mirror of
https://github.com/MailHops/mailhops-plugin.git
synced 2025-05-18 15:20:08 -07:00
Added Country to display if no city state
This commit is contained in:
parent
e2b1f2a612
commit
00d378f1bc
@ -19,7 +19,7 @@ var mailHops =
|
|||||||
isLoaded: false,
|
isLoaded: false,
|
||||||
map: 'goog',
|
map: 'goog',
|
||||||
unit: 'mi',
|
unit: 'mi',
|
||||||
appVersion: 'MailHops Thunderbird 0.3'
|
appVersion: 'MailHops Thunderbird 0.4'
|
||||||
}
|
}
|
||||||
|
|
||||||
mailHops.startLoading = function()
|
mailHops.startLoading = function()
|
||||||
@ -159,24 +159,33 @@ mailHops.testIP = function(ip,header){
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mailHops.displayResult = function ( distance, image, city, state, route )
|
mailHops.displayResult = function ( distance, image, city, state, countryName, route )
|
||||||
{
|
{
|
||||||
if(distance){
|
var displayText='';
|
||||||
|
|
||||||
|
if(city && state)
|
||||||
|
displayText = city+', '+state;
|
||||||
|
else if(countryName)
|
||||||
|
displayText = countryName;
|
||||||
|
|
||||||
|
if(distance)
|
||||||
|
{
|
||||||
if(distance.miles > 0){
|
if(distance.miles > 0){
|
||||||
if(mailHops.unit=='mi')
|
if(mailHops.unit=='mi')
|
||||||
mailHops.resultText.textContent = city+', '+state+' ( '+addCommas(Math.round(distance.miles))+' mi traveled )';
|
displayText +=' ( '+addCommas(Math.round(distance.miles))+' mi traveled )';
|
||||||
else
|
else
|
||||||
mailHops.resultText.textContent = city+', '+state+' ( '+addCommas(Math.round(distance.kilometers))+' km traveled )';
|
displayText +=' ( '+addCommas(Math.round(distance.kilometers))+' km traveled )';
|
||||||
}
|
}
|
||||||
else if(city && state)
|
|
||||||
mailHops.resultText.textContent = city+', '+state;
|
|
||||||
else
|
else
|
||||||
mailHops.resultText.textContent = ' Local message.';
|
displayText = ' Local message.';
|
||||||
mailHops.container.setAttribute("onclick","launchMap('"+route.toString()+"');");
|
mailHops.container.setAttribute("onclick","launchMap('"+route.toString()+"');");
|
||||||
} else {
|
}
|
||||||
mailHops.resultText.textContent = ' There was a problem.';
|
else
|
||||||
|
{
|
||||||
|
displayText = ' There was a problem.';
|
||||||
mailHops.container.removeAttribute("onclick");
|
mailHops.container.removeAttribute("onclick");
|
||||||
}
|
}
|
||||||
|
mailHops.resultText.textContent = displayText;
|
||||||
mailHops.resultImage.src=image;
|
mailHops.resultImage.src=image;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@ -254,6 +263,7 @@ mailHops.lookup = function(route){
|
|||||||
var flag= 'chrome://mailhops/content/images/local.png';
|
var flag= 'chrome://mailhops/content/images/local.png';
|
||||||
var city;
|
var city;
|
||||||
var state;
|
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='+route.toString(),true);
|
||||||
xmlhttp.onreadystatechange=function() {
|
xmlhttp.onreadystatechange=function() {
|
||||||
@ -266,11 +276,12 @@ mailHops.lookup = function(route){
|
|||||||
flag='chrome://mailhops/content/images/flags/'+data.response.route[i].countryCode.toLowerCase()+'.png';
|
flag='chrome://mailhops/content/images/flags/'+data.response.route[i].countryCode.toLowerCase()+'.png';
|
||||||
city=data.response.route[i].city;
|
city=data.response.route[i].city;
|
||||||
state=data.response.route[i].state;
|
state=data.response.route[i].state;
|
||||||
|
countryName=data.response.route[i].countryName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//display the result
|
//display the result
|
||||||
mailHops.displayResult(data.response.distance,flag,city,state,route);
|
mailHops.displayResult(data.response.distance,flag,city,state,countryName,route);
|
||||||
} else {
|
} else {
|
||||||
//display the error
|
//display the error
|
||||||
mailHops.displayResult(null,'chrome://mailhops/content/images/error.png',null,null,null);
|
mailHops.displayResult(null,'chrome://mailhops/content/images/error.png',null,null,null);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<em:type>2</em:type>
|
<em:type>2</em:type>
|
||||||
|
|
||||||
<em:name>MailHops</em:name>
|
<em:name>MailHops</em:name>
|
||||||
<em:version>0.3</em:version>
|
<em:version>0.4</em:version>
|
||||||
<em:description>MailHops maps the route an email took to get to you.</em:description>
|
<em:description>MailHops maps the route an email took to get to you.</em:description>
|
||||||
|
|
||||||
<em:iconURL>chrome://mailhops/content/images/mailhops32.png</em:iconURL>
|
<em:iconURL>chrome://mailhops/content/images/mailhops32.png</em:iconURL>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user