diff --git a/chrome/content/mailhops.js b/chrome/content/mailhops.js index 6a6fbf1..22c3615 100644 --- a/chrome/content/mailhops.js +++ b/chrome/content/mailhops.js @@ -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(); diff --git a/chrome/content/tb-overlay.js b/chrome/content/tb-overlay.js index d9b0cdf..3a6b582 100644 --- a/chrome/content/tb-overlay.js +++ b/chrome/content/tb-overlay.js @@ -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)