From 2a2c55ddd12f85da129e7576c60c73f8e8e5b95e Mon Sep 17 00:00:00 2001 From: Andrew Van Tassel Date: Fri, 22 Nov 2013 22:26:57 -0700 Subject: [PATCH] Added minimum logging to show api url Added debug option for this logging in the preferences --- chrome/content/mailhops.js | 20 ++++++++++++++++++-- chrome/content/preferences.js | 6 ++++++ chrome/content/preferences.xul | 1 + install.rdf | 2 +- mailhops.xpi | Bin 0 -> 141974 bytes 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 mailhops.xpi diff --git a/chrome/content/mailhops.js b/chrome/content/mailhops.js index 3f1de64..0ccc406 100644 --- a/chrome/content/mailhops.js +++ b/chrome/content/mailhops.js @@ -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,7 +126,8 @@ 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',''); if(mailHops.options.use_private) @@ -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(); } } diff --git a/chrome/content/preferences.js b/chrome/content/preferences.js index fd1eb71..6319094 100644 --- a/chrome/content/preferences.js +++ b/chrome/content/preferences.js @@ -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)) ; } diff --git a/chrome/content/preferences.xul b/chrome/content/preferences.xul index 110f2da..dc54ada 100644 --- a/chrome/content/preferences.xul +++ b/chrome/content/preferences.xul @@ -74,6 +74,7 @@ +