1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-11 10:35:45 +01:00

Rename stringToURLArray ⇒ parseURLs.

This commit is contained in:
Kris Maglione
2010-10-11 15:50:23 -04:00
parent f4ddaafb9e
commit 7f2126179e
4 changed files with 29 additions and 23 deletions

View File

@@ -94,7 +94,7 @@ const Browser = Module("browser", {
mappings.add([modes.NORMAL], ["~"], mappings.add([modes.NORMAL], ["~"],
"Open home directory", "Open home directory",
function () { dactyl.open("~/"); }); function () { dactyl.open("~"); });
mappings.add([modes.NORMAL], ["gh"], mappings.add([modes.NORMAL], ["gh"],
"Open homepage", "Open homepage",
@@ -170,7 +170,7 @@ const Browser = Module("browser", {
dactyl.open("about:blank"); dactyl.open("about:blank");
}, { }, {
completer: function (context) completion.url(context), completer: function (context) completion.url(context),
domains: function (args) array.compact(dactyl.stringToURLArray(args[0] || "").map( domains: function (args) array.compact(dactyl.parseURLs(args[0] || "").map(
function (url) util.getHost(url))), function (url) util.getHost(url))),
literal: 0, literal: 0,
privateData: true privateData: true

View File

@@ -25,19 +25,24 @@ const FailedAssertion = Class("FailedAssertion", Error, {
} }
}); });
function deprecated(reason, fn, name) function deprecated(reason, fn) {
let (func = (callable(fn) ? fn : function () this[fn].apply(this, arguments))) let name, func = callable(fn) ? fn : function () this[fn].apply(this, arguments);
update(function deprecatedMethod() { function deprecatedMethod() {
let frame = Components.stack.caller; let frame = Components.stack.caller;
if (!set.add(deprecatedMethod.seen, frame.filename)) if (!set.add(deprecatedMethod.seen, frame.filename))
dactyl.echoerr( dactyl.echoerr(
frame.filename.replace(/^.*? -> /, "") + frame.filename.replace(/^.*? -> /, "") +
":" + frame.lineNumber + ": " + ":" + frame.lineNumber + ": " +
(this.className || this.constructor.className) + "." + (this.className || this.constructor.className) + "." +
(fn.name || name) + " is deprecated: " + reason); (fn.name || name) + " is deprecated: " + reason);
return func.apply(this, arguments); return func.apply(this, arguments);
}, }
{ seen: { "chrome://dactyl/content/javascript.js": true } }); deprecatedMethod.seen = { "chrome://dactyl/content/javascript.js": true };
return callable(fn) ? deprecatedMethod : Class.Property({
get: function () deprecatedMethod,
init: function (prop) { name = prop }
});
}
const Dactyl = Module("dactyl", { const Dactyl = Module("dactyl", {
init: function () { init: function () {
@@ -746,7 +751,7 @@ const Dactyl = Module("dactyl", {
* *
* @param {string|Array} urls A representation of the URLs to open. May be * @param {string|Array} urls A representation of the URLs to open. May be
* either a string, which will be passed to * either a string, which will be passed to
* {@see Dactyl#stringToURLArray}, or an array in the same format as * {@see Dactyl#parseURLs}, or an array in the same format as
* would be returned by the same. * would be returned by the same.
* @param {object} params A set of parameters specifying how to open the * @param {object} params A set of parameters specifying how to open the
* URLs. The following properties are recognized: * URLs. The following properties are recognized:
@@ -770,7 +775,7 @@ const Dactyl = Module("dactyl", {
*/ */
open: function (urls, params, force) { open: function (urls, params, force) {
if (typeof urls == "string") if (typeof urls == "string")
urls = dactyl.stringToURLArray(urls); urls = dactyl.parseURLs(urls);
if (urls.length > 20 && !force) if (urls.length > 20 && !force)
return commandline.input("This will open " + urls.length + " new tabs. Would you like to continue? (yes/[no]) ", return commandline.input("This will open " + urls.length + " new tabs. Would you like to continue? (yes/[no]) ",
@@ -884,7 +889,8 @@ const Dactyl = Module("dactyl", {
* @param {string} str * @param {string} str
* @returns {string[]} * @returns {string[]}
*/ */
stringToURLArray: function stringToURLArray(str) { stringToURLArray: deprecated("Please use dactyl.parseURLs instead", "parseURLs"),
parseURLs: function parseURLs(str) {
let urls; let urls;
if (options["urlseparator"]) if (options["urlseparator"])

View File

@@ -155,10 +155,10 @@ const Option = Class("Option", {
dactyl.triggerObserver("options." + this.name, newValues); dactyl.triggerObserver("options." + this.name, newValues);
}, },
getValues: deprecated("Please use Option#get instead", "get", "getValues"), getValues: deprecated("Please use Option#get instead", "get"),
setValues: deprecated("Please use Option#set instead", "set", "setValues"), setValues: deprecated("Please use Option#set instead", "set"),
joinValues: deprecated("Please use Option#stringify instead", "stringify", "joinValues"), joinValues: deprecated("Please use Option#stringify instead", "stringify"),
parseValues: deprecated("Please use Option#parse instead", "parse", "parseValues"), parseValues: deprecated("Please use Option#parse instead", "parse"),
values: Class.Property({ values: Class.Property({
get: deprecated("Please use Option#value instead", function values() this.value), get: deprecated("Please use Option#value instead", function values() this.value),
set: deprecated("Please use Option#value instead", function values(val) this.value = val) set: deprecated("Please use Option#value instead", function values(val) this.value = val)

View File

@@ -41,7 +41,7 @@ const QuickMarks = Module("quickmarks", {
find: function find(url) { find: function find(url) {
let res = []; let res = [];
for (let [k, v] in this._qmarks) for (let [k, v] in this._qmarks)
if (dactyl.stringToURLArray(v).some(function (u) String.replace(u, /#.*/, "") == url)) if (dactyl.parseURLs(v).some(function (u) String.replace(u, /#.*/, "") == url))
res.push(k); res.push(k);
return res; return res;
}, },