diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2014-12-07 10:53:03 -0500 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2014-12-07 10:53:03 -0500 |
commit | b8b74f38babd5186cc538b4aeae7c0dba7c7c8b6 (patch) | |
tree | eb180e55546ac9c6eba7895bc7af8aef06eb722b /src | |
parent | 9d43f129d4ad56dded752aa75c4dd2bb5af48b9e (diff) | |
download | eib-b8b74f38babd5186cc538b4aeae7c0dba7c7c8b6.tar.xz eib-b8b74f38babd5186cc538b4aeae7c0dba7c7c8b6.zip |
Add features, README.rst.
Diffstat (limited to 'src')
-rw-r--r-- | src/bootstrap.js | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/bootstrap.js b/src/bootstrap.js index b01697f..7d4bf8f 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -43,13 +43,14 @@ EIB.listen = function () { resp += "Content-Type: text/html\r\n\r\n"; resp += "<!DOCTYPE html><html><head><title>EVE-IGB Bridge</title>"; if (headers["EVE_TRUSTED"]) { - resp += "<script>"; + resp += '<script>'; if (headers["EVE_TRUSTED"] == "Yes") { - resp += EIB.pending.join("\r\n"); - EIB.pending = []; - resp += 'setTimeout(function () {'; - resp += ' window.location.reload();'; - resp += '}, 100);'; + var delay = 100; + if (EIB.pending.length) { + resp += EIB.pending.shift(); + delay = 1000; + } + resp += 'setTimeout(function () { location.reload(); }, ' + delay + ');'; } else { resp += 'CCPEVE.requestTrust("http://127.0.0.1:' + EIB.serverSocket.port + '");'; } @@ -80,6 +81,7 @@ var HttpObserver = { for (var header in EIB.headers) { channel.setRequestHeader(header, EIB.headers[header], false); } + channel.setRequestHeader("User-Agent", channel.getRequestHeader("User-Agent") + " EVE-IGB", false); } } }; @@ -107,24 +109,23 @@ var WindowListener = { var TrustedReparser = { observe: function () { - if (!EIB.prefs.prefHasUserValue("trusted")) { - EIB.prefs.setCharPref("trusted", "[]"); - } - EIB.trusted = JSON.parse(EIB.prefs.getCharPref("trusted")); + EIB.trusted = EIB.prefs.prefHasUserValue("trusted") ? + JSON.parse(EIB.prefs.getCharPref("trusted")) : + []; } }; function startup(data, reason) { EIB.listen(); - EIB.prefs = Services.prefs.getBranch("extensions.eib."); - EIB.prefs.addObserver("trusted", TrustedReparser, false); - TrustedReparser.observe(); - forEachOpenWindow(loadIntoWindow); Services.wm.addListener(WindowListener); Services.obs.addObserver(HttpObserver, "http-on-modify-request", false); + + EIB.prefs = Services.prefs.getBranch("extensions.eib."); + EIB.prefs.addObserver("trusted", TrustedReparser, false); + TrustedReparser.observe(); } function shutdown(data, reason) { @@ -135,12 +136,12 @@ function shutdown(data, reason) { EIB.serverSocket.close(); delete EIB.serverSocket; - EIB.prefs.removeObserver("trusted", TrustedReparser); - forEachOpenWindow(unloadFromWindow); Services.wm.removeListener(WindowListener); Services.obs.removeObserver(HttpObserver, "http-on-modify-request"); + + EIB.prefs.removeObserver("trusted", TrustedReparser); } function checkTrusted(href) { @@ -157,7 +158,7 @@ function injectCCPEVE(e) { ["openEveMail", "showInfo", "showPreview", "showRouteTo", "showMap", "showFitting", "showContract", "showMarketDetails", "setDestination", "addWaypoint", "joinChannel", "joinMailingList", "createContract", "buyType", "findInContracts", "addToMarketQuickBar", "addContact", "removeContact", "addCorpContact", "removeCorpContact", "block", "addBounty", "inviteToFleet", "startConversation", "showContracts", "showOnMap", "editMember", "awardDecoration", "sendMail", "showContents", "bookmark"].forEach(function (n) { Object.defineProperty(CCPEVE, n, { value: Cu.exportFunction(function () { - EIB.pending.push('CCPEVE.' + n + '(' + Array.prototype.join.call(arguments, ',') + ');'); + EIB.pending.push('CCPEVE.' + n + '(' + JSON.stringify([].slice.call(arguments)).slice(1, -1) + ');'); return null; }, CCPEVE) }); |