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

Fixed date logic on time travel

This commit is contained in:
Andrew Van Tassel 2016-10-03 22:23:19 -06:00
parent 2999749c36
commit 7d37587a77
2 changed files with 8 additions and 10 deletions

View File

@ -198,15 +198,14 @@ mailHops.getRoute = function(){
for( var h=0; h < headReceivedArr.length; h++ ) {
//build the received line by concat until semi-colon ; date/time
rline += headReceivedArr[h];
if(headReceivedArr[h].indexOf(';')==-1)
if(headReceivedArr[h].indexOf(';') === -1)
continue;
// first and last dates are used to calculate time traveled
if(rline.indexOf(';')!==-1){
if(rline.indexOf(';') !== -1){
if(!firstDate)
firstDate = rline.substring(rline.indexOf(';')+1).trim();
if(!lastDate)
lastDate = rline.substring(rline.indexOf(';')+1).trim();
else
firstDate = rline.substring(rline.indexOf(';')+1).trim();
}
// parse IPs out of Received line
@ -237,7 +236,7 @@ mailHops.getRoute = function(){
try {
firstDate = new Date(firstDate);
lastDate = new Date(lastDate);
mailHops.message.time = lastDate-firstDate;
mailHops.message.time = lastDate - firstDate;
} catch(e){
mailHops.LOG('travel dates parse Error: '+JSON.stringify(e));
mailHops.message.time = null;
@ -394,7 +393,6 @@ mailHops.LOG(lookupURL);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState===4){
try {
mailHops.LOG(xmlhttp.status);
var data = JSON.parse(xmlhttp.responseText);
if(xmlhttp.status===200){
var d = new Date();
@ -431,8 +429,8 @@ mailHops.saveResults = function(results,route){
msgHdr.setStringProperty( "MH-Route", results );
//Add tag
if(!!route){
try{
if(!!route && !!mailHops.options.api_key){
try {
var countryCode = mailHopsUtils.getOriginatingCountryCode(route);
var msg = Components.classes["@mozilla.org/array;1"].createInstance(Components.interfaces.nsIMutableArray);
msg.clear();

View File

@ -308,7 +308,7 @@ var mailHopsDisplay =
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)+' hrs.';
distanceText += ' in '+Math.round(message.time/60/60)+' hr.';
}
if(header_route)