From 1e69a5f40cd6932c826ec67658f2016e1d52087d Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 11 Sep 2008 04:00:23 +0000 Subject: [PATCH] Fix liberator.storage.saveAll(). --- content/bookmarks.js | 4 ++-- content/liberator.js | 30 +++++++++--------------------- content/storage.jsi | 8 ++++---- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/content/bookmarks.js b/content/bookmarks.js index 742bbc86..3972440a 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -457,7 +457,7 @@ liberator.Bookmarks = function () //{{{ } if (openItems) - return liberator.openTabs((i[0] for (i in items)), items.length); + return liberator.open([i[0] for (i in items)], liberator.NEW_TAB); var title, url, tags, keyword, extra; var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "
" + @@ -762,7 +762,7 @@ liberator.History = function () //{{{ if (openItems) { - return liberator.openTabs((i[0] for (i in items)), items.length); + return liberator.open([i[0] for (i in items)], liberator.NEW_TAB); } else { diff --git a/content/liberator.js b/content/liberator.js index a6bb08df..851cf56a 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -858,16 +858,22 @@ const liberator = (function () //{{{ // [["url1", postdata1], ["url2", postdata2], ...] // @param where: if ommited, CURRENT_TAB is assumed // but NEW_TAB is set when liberator.forceNewTab is true. - // @param callback: not implemented, will be allowed to specify a callback function - // which is called, when the page finished loading + // @param force: Don't prompt whether to open more than 20 tabs. // @returns true when load was initiated, or false on error - open: function (urls, where) + open: function (urls, where, force) { // convert the string to an array of converted URLs // -> see liberator.util.stringToURLArray for more details if (typeof urls == "string") urls = liberator.util.stringToURLArray(urls); + if (urls.length > 20 && !force) + { + liberator.commandline.input("This will open " + urls.length + " new tabs. Would you like to continue? (yes/[no])", + function (resp) { if (resp.match(/^y(es)?$/i)) liberator.open(urls, where, true) }); + return true; + } + if (urls.length == 0) return false; @@ -924,24 +930,6 @@ const liberator = (function () //{{{ return true; }, - /* Not really ideal. I'd like open to do this. */ - openTabs: function (uris, length) - { - let open = function () - { - for each (let uri in uris) - liberator.open(uri, liberator.NEW_TAB); - } - if ((length || uris.length) > 50) - liberator.commandline.input("This will open " + (length || uris.length) + " new tabs. Would you like to continue? (yes/[no])", - function (resp) { if (resp.match(/^y(es)?$/i)) open() }, - { - completer: function (filter) [0, [["yes", "Open all in tabs"], ["no", "Cancel"]]], - }); - else - open(); - }, - // namespace for plugins/scripts. Actually (only) the active plugin must/can set a // v.plugins.mode = string to show on v.modes.CUSTOM // v.plugins.stop = hooked on a v.modes.reset() diff --git a/content/storage.jsi b/content/storage.jsi index 46e6edc5..fc3136fe 100644 --- a/content/storage.jsi +++ b/content/storage.jsi @@ -110,7 +110,7 @@ function ObjectStore(name, store) this.__iterator__ = function() { for (let key in object) yield [key, object[key]]; - } + }; } ObjectStore.prototype = prototype; @@ -162,7 +162,7 @@ function ArrayStore(name, store) var funcName = aFuncName; arguments[0] = array; array = Array[funcName].apply(Array, arguments); - }, + }; this.get = function get(index) { @@ -172,7 +172,7 @@ function ArrayStore(name, store) this.__iterator__ = function() { for(let i = 0; i < array.length; i++) yield [i, array[i]]; - } + }; } ArrayStore.prototype = prototype; @@ -230,7 +230,7 @@ var storage = { saveAll: function storeAll() { for each(key in keys) - key.store(); + key.save(); } };