1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 23:47:57 +01:00

Reconcile the format of 'sanitizeitems' with most other list options.

This commit is contained in:
Kris Maglione
2011-08-06 13:51:21 -04:00
parent b9f4221643
commit 48d1109f6a
5 changed files with 42 additions and 15 deletions

View File

@@ -861,7 +861,14 @@ var Editor = Module("editor", {
"string", config.locale,
{
initValue: function () {},
getter: function getter() services.spell.dictionary || "",
getter: function getter() {
try {
return services.spell.dictionary || "";
}
catch (e) {
return "";
}
},
setter: function setter(val) { services.spell.dictionary = val; },
completer: function completer(context) {
let res = {};

View File

@@ -1321,7 +1321,10 @@
<description>
<p>
The default list of private items to sanitize. See
<ex>:sanitize</ex> for a list and explanation of possible values.
<ex>:sanitize</ex> for a list and explanation of possible values. A
value of <str>all</str> will cause all items to be sanitized. Items
may be excluded by prefixing them with a <tt>!</tt>. The first
matching item takes precedence.
</p>
</description>
</item>

View File

@@ -75,6 +75,13 @@
<dt>sitesettings</dt> <dd>Site preferences</dd>
</dl>
<p>
Items may be excluded by prefixing them with a <tt>!</tt>. The first
matching item takes precedence. Therefore, the value
<tt>!commandline all</tt> will sanitize all items but the command
line. A value of <tt>all !commandline</tt> will sanitize all items.
</p>
<p>
When <em>history</em> items are sanitized, all command-line
history items containing URLs or page titles (other than bookmark

View File

@@ -407,7 +407,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
function (args) {
dactyl.assert(!modules.options['private'], _("command.sanitize.privateMode"));
if (args["-host"] && !args.length)
if (args["-host"] && !args.length && !args.bang)
args[0] = "all";
let timespan = args["-timespan"] || modules.options["sanitizetimespan"];
@@ -418,15 +418,15 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
match ? 1000 * (Date.now() - 1000 * parseInt(num, 10) * { m: 60, h: 3600, d: 3600 * 24, w: 3600 * 24 * 7 }[unit])
: (timespan[0] == "s" ? sanitizer.sessionStart : null);
let items = args.slice();
if (args.bang) {
let opt = modules.options.get("sanitizeitems");
if (args.bang)
dactyl.assert(args.length == 0, _("error.trailingCharacters"));
items = Object.keys(sanitizer.itemMap).filter(
function (k) modules.options.get("sanitizeitems").has(k));
else {
dactyl.assert(opt.validator(args), _("error.invalidArgument"));
opt = { __proto__: opt, value: args.slice() };
}
else
dactyl.assert(modules.options.get("sanitizeitems").validator(items), _("error.invalidArgument"));
let items = Object.keys(sanitizer.itemMap).slice(1).filter(opt.has, opt);
function sanitize(items) {
sanitizer.range = range.native;
@@ -442,13 +442,12 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
sanitizer.sanitize(items, range);
}
if (items.indexOf("all") >= 0 && !args["-host"])
if (array.nth(opt.value, function (i) i == "all" || /^!/.test(i), 0) == "all" && !args["-host"])
modules.commandline.input(_("sanitize.prompt.deleteAll") + " ",
function (resp) {
if (resp.match(/^y(es)?$/i)) {
items = Object.keys(sanitizer.itemMap).filter(function (k) items.indexOf(k) === -1);
sanitize(items);
dactyl.echo(_("command.sanitize.allDeleted"));
dactyl.echomsg(_("command.sanitize.allDeleted"));
}
else
dactyl.echo(_("command.sanitize.noneDeleted"));
@@ -594,9 +593,19 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
"stringlist", "all",
{
get values() values(sanitizer.itemMap).toArray(),
has: modules.Option.has.toggleAll,
completer: function completer(context, extra) {
if (context.filter[0] == "!")
context.advance(1);
return completer.superapply(this, arguments);
},
has: function has(val)
let (res = array.nth(this.value, function (v) v == "all" || v.replace(/^!/, "") == val, 0))
res && !/^!/.test(res),
validator: function (values) values.length &&
values.every(function (val) val === "all" || Set.has(sanitizer.itemMap, val))
values.every(function (val) val === "all" || Set.has(sanitizer.itemMap, val.replace(/^!/, "")))
});
options.add(["sanitizeshutdown", "ss"],

View File

@@ -174,6 +174,7 @@
variable. [b4]
- 'passkeys' is now a [sitemap] with key chain support rather
than a [regexpmap]. [b6]
- The precise format of 'sanitizeitems' has changed slightly. [b8]
- 'showmode' is now a [regexplist]. [b6]
- 'showstatuslinks' and 'showtabline' are now [string] options. [b4]
• IMPORTANT: Command script files now use the *.penta file extension. [b2]