1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-29 08:55:46 +01:00

Fix executing commandline.input callback. Closes issue #331.

This commit is contained in:
Kris Maglione
2011-01-30 11:14:50 -05:00
parent c50ddf6bb6
commit 64e9cfc545
4 changed files with 16 additions and 9 deletions

View File

@@ -760,14 +760,21 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @returns {XMLHttpRequest}
*/
httpGet: function httpGet(url, callback, self) {
let params = callback;
if (!isObject(params))
params = { callback: params && function () callback.apply(self, arguments) };
try {
let xmlhttp = services.Xmlhttp();
xmlhttp.mozBackgroundRequest = true;
if (callback) {
xmlhttp.onload = function handler(event) { util.trapErrors(callback, self, xmlhttp, event) };
if (params.callback) {
xmlhttp.onload = function handler(event) { util.trapErrors(params.callback, params, xmlhttp, event) };
xmlhttp.onerror = xmlhttp.onload;
}
xmlhttp.open("GET", url, !!callback);
if (params.mimeType)
xmlhttp.overrideMimeType(params.mimeType);
xmlhttp.open(params.method || "GET", url, !!params.callback, params.user, params.pass);
xmlhttp.send(null);
return xmlhttp;
}