1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 20:47:58 +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

1
common/bootstrap.js vendored
View File

@@ -32,6 +32,7 @@ function reportError(e) {
function httpGet(url) {
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
xmlhttp.overrideMimeType("text/plain");
xmlhttp.open("GET", url, false);
xmlhttp.send(null);
return xmlhttp;

View File

@@ -520,8 +520,8 @@ var Bookmarks = Module("bookmarks", {
commandline.input("This will delete all bookmarks. Would you like to continue? (yes/[no]) ",
function (resp) {
if (resp && resp.match(/^y(es)?$/i)) {
Object.keys(bookmarkcache.bookmarks).forEach(function (id) { services.bookmarks.removeItem(id); });
dactyl.echomsg("All bookmarks deleted", 1, commandline.FORCE_SINGLELINE);
bookmarks.remove(Object.keys(bookmarkcache.bookmarks));
dactyl.echomsg("All bookmarks deleted");
}
});
else {
@@ -534,8 +534,7 @@ var Bookmarks = Module("bookmarks", {
var deletedCount = bookmarks.remove(context.allItems.items.map(function (item) item.item.id));
}
dactyl.echomsg({ message: deletedCount + " bookmark(s) deleted" },
1, commandline.FORCE_SINGLELINE);
dactyl.echomsg({ message: deletedCount + " bookmark(s) deleted" });
}
},

View File

@@ -430,7 +430,7 @@ var CommandExMode = Class("CommandExMode", CommandMode, {
var CommandPromptMode = Class("CommandPromptMode", CommandMode, {
init: function init(prompt, params) {
this.prompt = prompt;
this.prompt = isArray(prompt) ? prompt : ["Question", prompt];
update(this, params);
init.supercall(this);
},
@@ -752,7 +752,7 @@ var CommandLine = Module("commandline", {
input: function _input(prompt, callback, extra) {
extra = extra || {};
CommandPromptMode(prompt, extra).open();
CommandPromptMode(prompt, update({ onSubmit: callback }, extra)).open();
},
readHeredoc: function readHeredoc(end) {

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;
}