diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/content/autocommands.js | 4 | ||||
-rw-r--r-- | common/content/bookmarks.js | 14 | ||||
-rw-r--r-- | common/content/browser.js | 14 | ||||
-rw-r--r-- | common/content/buffer.js | 19 | ||||
-rw-r--r-- | common/content/commandline.js | 6 | ||||
-rw-r--r-- | common/content/events.js | 2 | ||||
-rw-r--r-- | common/content/quickmarks.js | 4 | ||||
-rw-r--r-- | common/content/statusline.js | 6 | ||||
-rw-r--r-- | common/modules/storage.jsm | 4 |
9 files changed, 41 insertions, 32 deletions
diff --git a/common/content/autocommands.js b/common/content/autocommands.js index 84e9f8c2..d97210b8 100644 --- a/common/content/autocommands.js +++ b/common/content/autocommands.js @@ -207,7 +207,7 @@ var AutoCommands = Module("autocommands", { return void dactyl.echomsg("No matching autocommands"); let [event, url] = args; - let defaultURL = url || buffer.URL.spec; + let defaultURL = url || buffer.uri.spec; let validEvents = Object.keys(config.autocommands); // TODO: add command validators @@ -224,7 +224,7 @@ var AutoCommands = Module("autocommands", { for (let i = 0; i < tabs.count; i++) { tabs.select(i); // if no url arg is specified use the current buffer's URL - autocommands.trigger(event, { url: url || buffer.URL.spec }); + autocommands.trigger(event, { url: url || buffer.uri.spec }); } tabs.select(current); diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index 7565de63..73b7989a 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -134,7 +134,7 @@ var Bookmarks = Module("bookmarks", { if (count > 0) dactyl.echomsg({ domains: [util.getHost(url)], message: "Removed bookmark: " + url }); else { - let title = buffer.URL.spec == url && buffer.title || url; + let title = buffer.uri.spec == url && buffer.title || url; let extra = ""; if (title != url) extra = " (" + title + ")"; @@ -453,7 +453,7 @@ var Bookmarks = Module("bookmarks", { post: args["-post"], tags: args["-tags"] || [], title: args["-title"] || (args.length === 0 ? buffer.title : null), - url: args.length === 0 ? buffer.URL.spec : args[0] + url: args.length === 0 ? buffer.uri.spec : args[0] }; if (bookmarks.add(opts)) { @@ -523,7 +523,7 @@ var Bookmarks = Module("bookmarks", { }); else { if (!(args.length || args["-tags"] || args["-keyword"] || args["-title"])) - var deletedCount = bookmarks.remove(buffer.URL.spec); + var deletedCount = bookmarks.remove(buffer.uri.spec); else { let context = CompletionContext(args.join(" ")); context.fork("bookmark", 0, completion, "bookmark", @@ -555,7 +555,7 @@ var Bookmarks = Module("bookmarks", { function () { let options = {}; - let url = buffer.URL.spec; + let url = buffer.uri.spec; let bmarks = bookmarks.get(url).filter(function (bmark) bmark.url == url); if (bmarks.length == 1) { @@ -572,20 +572,20 @@ var Bookmarks = Module("bookmarks", { options["-tags"] = bmark.tags.join(", "); } else { - if (buffer.title != buffer.URL.spec) + if (buffer.title != buffer.uri.spec) options["-title"] = buffer.title; if (content.document.characterSet !== "UTF-8") options["-charset"] = content.document.characterSet; } commandline.open(":", - commands.commandToString({ command: "bmark", options: options, arguments: [buffer.URL.spec] }), + commands.commandToString({ command: "bmark", options: options, arguments: [buffer.uri.spec] }), modes.EX); }); mappings.add(myModes, ["A"], "Toggle bookmarked state of current URL", - function () { bookmarks.toggle(buffer.URL.spec); }); + function () { bookmarks.toggle(buffer.uri.spec); }); }, options: function () { options.add(["defsearch", "ds"], diff --git a/common/content/browser.js b/common/content/browser.js index e3c789e0..826c2a6b 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -14,18 +14,18 @@ var Browser = Module("browser", { }, { climbUrlPath: function (count) { - let url = buffer.URI.clone(); + let url = buffer.documentURI.clone(); dactyl.assert(url instanceof Ci.nsIURL); while (count-- && url.path != "/") url.path = url.path.replace(/[^\/]+\/*$/, ""); - dactyl.assert(!url.equals(buffer.URI)); + dactyl.assert(!url.equals(buffer.documentURI)); dactyl.open(url.spec); }, incrementURL: function (count) { - let matches = buffer.URL.spec.match(/(.*?)(\d+)(\D*)$/); + let matches = buffer.uri.spec.match(/(.*?)(\d+)(\D*)$/); dactyl.assert(matches); let oldNum = matches[2]; @@ -66,7 +66,7 @@ var Browser = Module("browser", { mappings: function () { mappings.add([modes.NORMAL], ["y"], "Yank current location to the clipboard", - function () { dactyl.clipboardWrite(buffer.URL.spec, true); }); + function () { dactyl.clipboardWrite(buffer.uri.spec, true); }); // opening websites mappings.add([modes.NORMAL], @@ -75,7 +75,7 @@ var Browser = Module("browser", { mappings.add([modes.NORMAL], ["O"], "Open one or more URLs, based on current location", - function () { commandline.open(":", "open " + buffer.URL.spec, modes.EX); }); + function () { commandline.open(":", "open " + buffer.uri.spec, modes.EX); }); mappings.add([modes.NORMAL], ["t"], "Open one or more URLs in a new tab", @@ -83,7 +83,7 @@ var Browser = Module("browser", { mappings.add([modes.NORMAL], ["T"], "Open one or more URLs in a new tab, based on current location", - function () { commandline.open(":", "tabopen " + buffer.URL.spec, modes.EX); }); + function () { commandline.open(":", "tabopen " + buffer.uri.spec, modes.EX); }); mappings.add([modes.NORMAL], ["w"], "Open one or more URLs in a new window", @@ -91,7 +91,7 @@ var Browser = Module("browser", { mappings.add([modes.NORMAL], ["W"], "Open one or more URLs in a new window, based on current location", - function () { commandline.open(":", "winopen " + buffer.URL.spec, modes.EX); }); + function () { commandline.open(":", "winopen " + buffer.uri.spec, modes.EX); }); mappings.add([modes.NORMAL], ["<C-a>"], "Increment last number in URL", diff --git a/common/content/buffer.js b/common/content/buffer.js index c06017b1..5d764ad5 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -387,15 +387,24 @@ var Buffer = Module("buffer", { set lastInputField(value) { this.localStore.lastInputField = value && Cu.getWeakReference(value); }, /** - * @property {string} The current top-level document's URL. + * @property {nsIURI} The current top-level document's URI. */ - get URL() util.newURI(content.location.href), - + get uri() util.newURI(content.location.href), /** - * @property {string} The current top-level document's URL, sans any + * @property {nsIURI} The current top-level document's URI, sans any * fragment identifier. */ - get URI() let (doc = content.document) doc.documentURIObject || util.newURI(doc.documentURI), + get documentURI() let (doc = content.document) doc.documentURIObject || util.newURI(doc.documentURI), + + /** + * @property {string} The current top-level document's URL. + */ + get URL() { + let str = String(content.location.href); + for (let [k, v] in Iterator(util.newURI(content.location.href))) + str[k] = v; + return str; + }, /** * @property {number} The buffer's height in pixels. diff --git a/common/content/commandline.js b/common/content/commandline.js index 5c9ce77a..d941bc1e 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -310,16 +310,16 @@ var CommandLine = Module("commandline", { this._callbacks = {}; - this._store = storage.newMap("command-history", { store: true, privateData: true }); + memoize(this, "_store", function () storage.newMap("command-history", { store: true, privateData: true })); for (let name in values(["command", "search"])) if (storage.exists("history-" + name)) { let ary = storage.newArray("history-" + name, { store: true, privateData: true }); this._store.set(name, [v for ([k, v] in ary)]); - ary.remove(); + ary.delete(); + this._store.changed(); } - this._store.changed(); this._messageHistory = { //{{{ _messages: [], diff --git a/common/content/events.js b/common/content/events.js index ee9e4a2e..c2939c35 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1272,7 +1272,7 @@ var Events = Module("events", { "Pass certain keys through directly for the given URLs", "regexpmap", "", { has: function (key) { - let url = buffer.URI.spec; + let url = buffer.documentURI.spec; for (let re in values(this.value)) if (re.test(url) && re.result.some(function (k) k === key)) return true; diff --git a/common/content/quickmarks.js b/common/content/quickmarks.js index 4b2031f8..0bf63837 100644 --- a/common/content/quickmarks.js +++ b/common/content/quickmarks.js @@ -144,7 +144,7 @@ var QuickMarks = Module("quickmarks", { dactyl.assert(/^[a-zA-Z0-9]$/.test(args[0]), "E191: Argument must be an ASCII letter or digit"); if (!args[1]) - quickmarks.add(args[0], buffer.URL.spec); + quickmarks.add(args[0], buffer.uri.spec); else quickmarks.add(args[0], args[1]); }, @@ -198,7 +198,7 @@ var QuickMarks = Module("quickmarks", { ["M"], "Add new QuickMark for current URL", function ({ arg }) { dactyl.assert(/^[a-zA-Z0-9]$/.test(arg), "E191: Argument must be an ASCII letter or digit"); - quickmarks.add(arg, buffer.URL.spec); + quickmarks.add(arg, buffer.uri.spec); }, { arg: true }); } diff --git a/common/content/statusline.js b/common/content/statusline.js index f78a3691..af5223fc 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -120,7 +120,7 @@ var StatusLine = Module("statusline", { * respectively. * * @param {string} url The URL to display. - * @default buffer.URL + * @default buffer.uri */ updateUrl: function updateUrl(url) { // ripped from Firefox; modified @@ -155,7 +155,7 @@ var StatusLine = Module("statusline", { // TODO: this probably needs a more general solution. if (url == null) - url = buffer.URL.spec; + url = buffer.uri.spec; // when session information is available, add [+] when we can go // backwards, [-] when we can go forwards @@ -168,7 +168,7 @@ var StatusLine = Module("statusline", { modified += "-"; } if (modules.bookmarks) { - if (bookmarks.isBookmarked(buffer.URL)) + if (bookmarks.isBookmarked(buffer.uri)) modified += UTF8("❤"); //modified += UTF8("♥"); } diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index 220e284d..3c25b31d 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -4,7 +4,6 @@ // given in the LICENSE.txt file included with this file. "use strict"; -var myObject = Object; Components.utils.import("resource://dactyl/bootstrap.jsm"); defineModule("storage", { exports: ["File", "storage"], @@ -12,6 +11,7 @@ defineModule("storage", { }, this); var win32 = /^win(32|nt)$/i.test(services.runtime.OS); +var myObject = JSON.parse("{}").constructor; function loadData(name, store, type) { try { @@ -55,7 +55,7 @@ var StoreBase = Class("StoreBase", { this.fireEvent("change", null); }, - remove: function remove() { + delete: function delete() { delete storage.keys[this.name]; delete storage[this.name]; storage.infoPath.child(this.name).remove(false); |