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

Added minimum logging to show api url

Added debug option for this logging in the preferences
This commit is contained in:
Andrew Van Tassel 2013-11-22 22:26:57 -07:00
parent 7e96333074
commit 2a2c55ddd1
5 changed files with 26 additions and 3 deletions

View File

@ -24,12 +24,18 @@ var mailHops =
resultMeta: null,
isLoaded: false,
options: {'map':'goog','unit':'mi','api_url':'http://api.mailhops.com'},
options: {'map':'goog','unit':'mi','api_url':'http://api.mailhops.com','debug':false},
appVersion: 'MailHops Postbox 0.8.2',
message: {secure:[]},
client_location: null
}
function LOG(msg) {
var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage('MailHops: '+msg);
}
mailHops.init = function()
{
//load preferences
@ -120,6 +126,7 @@ mailHops.loadPref = function()
//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','');
@ -921,11 +928,16 @@ mailHops.lookupRoute = function(header_route){
var cached_results=mailHops.getResults();
if(cached_results){
if(mailHops.options.debug)
LOG('Found Cached Result');
cached_results = JSON.parse(cached_results);
mailHops.displayResult(header_route, cached_results.response, cached_results.meta, lookupURL);
return;
}
if(mailHops.options.debug)
LOG(lookupURL);
//call mailhops api for lookup
var xmlhttp = new XMLHttpRequest();
@ -942,11 +954,15 @@ mailHops.lookupRoute = function(header_route){
//display the result
mailHops.displayResult(header_route,data.response,data.meta, lookupURL);
} else {
if(mailHops.options.debug)
LOG(JSON.stringify(data));
//display the error
mailHops.displayError(data);
}
}
catch (ex){
if(mailHops.options.debug)
LOG(JSON.stringify(ex));
mailHops.displayError();
}
}

View File

@ -102,6 +102,11 @@ var mailHopPreferences =
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');
ResetLocation(document.getElementById("mailhop.refresh_location"));
@ -123,6 +128,7 @@ var mailHopPreferences =
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.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)) ;
}

View File

@ -74,6 +74,7 @@
<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"/>
<label class="text-link plain act" onclick="TestConnection(this);" value="Test Connection" />

View File

@ -7,7 +7,7 @@
<em:id>postbox@mailhops.com</em:id>
<em:type>2</em:type>
<em:name>MailHops</em:name>
<em:version>0.8.2</em:version>
<em:version>0.8.3</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:iconURL>chrome://mailhops/content/images/mailhops32.png</em:iconURL>
<em:homepageURL>http://mailhops.com</em:homepageURL>

BIN
mailhops.xpi Normal file

Binary file not shown.