mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 22:57:58 +01:00
Fix executing commandline.input callback. Closes issue #331.
This commit is contained in:
1
common/bootstrap.js
vendored
1
common/bootstrap.js
vendored
@@ -32,6 +32,7 @@ function reportError(e) {
|
|||||||
|
|
||||||
function httpGet(url) {
|
function httpGet(url) {
|
||||||
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
||||||
|
xmlhttp.overrideMimeType("text/plain");
|
||||||
xmlhttp.open("GET", url, false);
|
xmlhttp.open("GET", url, false);
|
||||||
xmlhttp.send(null);
|
xmlhttp.send(null);
|
||||||
return xmlhttp;
|
return xmlhttp;
|
||||||
|
|||||||
@@ -520,8 +520,8 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
commandline.input("This will delete all bookmarks. Would you like to continue? (yes/[no]) ",
|
commandline.input("This will delete all bookmarks. Would you like to continue? (yes/[no]) ",
|
||||||
function (resp) {
|
function (resp) {
|
||||||
if (resp && resp.match(/^y(es)?$/i)) {
|
if (resp && resp.match(/^y(es)?$/i)) {
|
||||||
Object.keys(bookmarkcache.bookmarks).forEach(function (id) { services.bookmarks.removeItem(id); });
|
bookmarks.remove(Object.keys(bookmarkcache.bookmarks));
|
||||||
dactyl.echomsg("All bookmarks deleted", 1, commandline.FORCE_SINGLELINE);
|
dactyl.echomsg("All bookmarks deleted");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
else {
|
else {
|
||||||
@@ -534,8 +534,7 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
var deletedCount = bookmarks.remove(context.allItems.items.map(function (item) item.item.id));
|
var deletedCount = bookmarks.remove(context.allItems.items.map(function (item) item.item.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
dactyl.echomsg({ message: deletedCount + " bookmark(s) deleted" },
|
dactyl.echomsg({ message: deletedCount + " bookmark(s) deleted" });
|
||||||
1, commandline.FORCE_SINGLELINE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ var CommandExMode = Class("CommandExMode", CommandMode, {
|
|||||||
|
|
||||||
var CommandPromptMode = Class("CommandPromptMode", CommandMode, {
|
var CommandPromptMode = Class("CommandPromptMode", CommandMode, {
|
||||||
init: function init(prompt, params) {
|
init: function init(prompt, params) {
|
||||||
this.prompt = prompt;
|
this.prompt = isArray(prompt) ? prompt : ["Question", prompt];
|
||||||
update(this, params);
|
update(this, params);
|
||||||
init.supercall(this);
|
init.supercall(this);
|
||||||
},
|
},
|
||||||
@@ -752,7 +752,7 @@ var CommandLine = Module("commandline", {
|
|||||||
input: function _input(prompt, callback, extra) {
|
input: function _input(prompt, callback, extra) {
|
||||||
extra = extra || {};
|
extra = extra || {};
|
||||||
|
|
||||||
CommandPromptMode(prompt, extra).open();
|
CommandPromptMode(prompt, update({ onSubmit: callback }, extra)).open();
|
||||||
},
|
},
|
||||||
|
|
||||||
readHeredoc: function readHeredoc(end) {
|
readHeredoc: function readHeredoc(end) {
|
||||||
|
|||||||
@@ -760,14 +760,21 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @returns {XMLHttpRequest}
|
* @returns {XMLHttpRequest}
|
||||||
*/
|
*/
|
||||||
httpGet: function httpGet(url, callback, self) {
|
httpGet: function httpGet(url, callback, self) {
|
||||||
|
let params = callback;
|
||||||
|
if (!isObject(params))
|
||||||
|
params = { callback: params && function () callback.apply(self, arguments) };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let xmlhttp = services.Xmlhttp();
|
let xmlhttp = services.Xmlhttp();
|
||||||
xmlhttp.mozBackgroundRequest = true;
|
xmlhttp.mozBackgroundRequest = true;
|
||||||
if (callback) {
|
if (params.callback) {
|
||||||
xmlhttp.onload = function handler(event) { util.trapErrors(callback, self, xmlhttp, event) };
|
xmlhttp.onload = function handler(event) { util.trapErrors(params.callback, params, xmlhttp, event) };
|
||||||
xmlhttp.onerror = xmlhttp.onload;
|
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);
|
xmlhttp.send(null);
|
||||||
return xmlhttp;
|
return xmlhttp;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user