diff --git a/bootstrap.js b/bootstrap.js index faea25f..1c940c2 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -19,6 +19,7 @@ Cu.import("resource://gre/modules/AddonManager.jsm"); function LOG(m) (m = addon.name + ' Message @ ' + (new Date()).toISOString() + "\n> " + m, dump(m + "\n"), Services.console.logStringMessage(m)); +function rsc(n) 'resource://' + addon.tag + '/' + n; let i$ = { onOpenWindow: function(aWindow) { @@ -36,6 +37,22 @@ let i$ = { onWindowTitleChange: function() {} }; +let showAlertNotification = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService); +showAlertNotification = showAlertNotification.showAlertNotification.bind(showAlertNotification); + +function iNotify(aMsg, callback) { + let nme = addon.branch.getIntPref('nme'); + + if(nme == 2) { + showAlertNotification(rsc("icon.png"),addon.name,aMsg,!1,"", + (s,t) => t == "alertshow" || callback(t)); + } else { + if(nme) Services.prompt.alert(null,addon.name,aMsg); + + callback(); + } +} + function onClickHanlder(ev) { ev.preventDefault(); @@ -50,7 +67,7 @@ function onClickHanlder(ev) { let d = this.ownerDocument, l = this.lastChild, f = this.firstChild; - l.textContent = 'Installing...'; + l.textContent = ' Installing...'; f.className = f.className.replace('plus','hourglass'); d.body.appendChild(d.createElement('style')).textContent = '@keyframes ' +addon.tag+'{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}'; @@ -118,8 +135,7 @@ function onClickHanlder(ev) { } f.style.animation = null; f.className = f.className.replace('hourglass',c); - Services.prompt.alert(null,addon.name,aMsg); - oFile.remove(!1); + iNotify(aMsg, () => oFile.remove(!1)); }; aInstall.addListener({ @@ -315,9 +331,18 @@ function startup(data) { }; addon.branch = Services.prefs.getBranch('extensions.'+addon.tag+'.'); + let io = Services.io; + io.getProtocolHandler("resource") + .QueryInterface(Ci.nsIResProtocolHandler) + .setSubstitution(addon.tag, + io.newURI(__SCRIPT_URI_SPEC__+'/../',null,null)); + i$.wmf(loadIntoWindowStub); Services.wm.addListener(i$); + if(!addon.branch.getPrefType('nme')) { + addon.branch.setIntPref('nme',2); + } addon.branch.setCharPref('version', addon.version); }); } @@ -328,6 +353,10 @@ function shutdown(data, reason) { Services.wm.removeListener(i$); i$.wmf(unloadFromWindow); + + Services.io.getProtocolHandler("resource") + .QueryInterface(Ci.nsIResProtocolHandler) + .setSubstitution(addon.tag,null); } function install(data, reason) {} diff --git a/install.rdf b/install.rdf index 4a717ba..b5f8cba 100644 --- a/install.rdf +++ b/install.rdf @@ -4,7 +4,7 @@ {86054B0A-BD85-42F9-8E58-8794EC6F6EA1} 2 GitHub Extension Installer - 1.4a3 + 1.4a4 Diego Casorran <dcasorran@gmail.com> Install Browser Extensions straight from GitHub Repositories Zulkarnain K. diff --git a/options.xul b/options.xul index d8c1ee4..ccfb330 100644 --- a/options.xul +++ b/options.xul @@ -1,6 +1,15 @@ + + + + + + + + + - Comma-separated list of repositories where the button will be added on PRs. + Comma-separated list of repositories where the button will be added on its PRs. \ No newline at end of file