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

Death to E4X and stuff.

This commit is contained in:
Kris Maglione
2012-11-28 18:52:37 -08:00
parent 9420c58772
commit db38e43e96

View File

@@ -3,7 +3,7 @@
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
/* use strict */ "use strict";
// TODO: // TODO:
// - fix Sanitize autocommand // - fix Sanitize autocommand
@@ -20,7 +20,7 @@ defineModule("sanitizer", {
lazyRequire("messages", ["_"]); lazyRequire("messages", ["_"]);
lazyRequire("overlay", ["overlay"]); lazyRequire("overlay", ["overlay"]);
lazyRequire("storage", ["storage"]); lazyRequire("storage", ["storage"]);
lazyRequire("template", ["template"]); lazyRequire("template", ["template", "template_"]);
let tmp = Object.create(this); let tmp = Object.create(this);
JSMLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp); JSMLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
@@ -165,13 +165,12 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
]; ];
function prefOverlay(branch, persistent, local) update(Object.create(local), { function prefOverlay(branch, persistent, local) update(Object.create(local), {
before: array.toObject([ before: [
[branch.substr(Item.PREFIX.length) + "history", ["preferences", { id: branch.substr(Item.PREFIX.length) + "history",
<preferences xmlns={XUL}>{ xmlns: "xul" },
template.map(ourItems(persistent), function (item) template_.map(ourItems(persistent), function (item)
<preference type="bool" id={branch + item.name} name={branch + item.name}/>) ["preference", { type: "bool", id: branch + item.name, name: branch + item.name }])]
}</preferences>.*::*] ],
]),
init: function init(win) { init: function init(win) {
let pane = win.document.getElementById("SanitizeDialogPane"); let pane = win.document.getElementById("SanitizeDialogPane");
for (let [, pref] in iter(pane.preferences)) for (let [, pref] in iter(pane.preferences))
@@ -187,20 +186,18 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
function (win) prefOverlay(branch, true, { function (win) prefOverlay(branch, true, {
append: { append: {
SanitizeDialogPane: SanitizeDialogPane:
<groupbox orient="horizontal" xmlns={XUL}> ["groupbox", { orient: "horizontal", xmlns: "xul" },
<caption label={config.appName + /*L*/" (see :help privacy)"}/> ["caption", { label: config.appName + /*L*/" (see :help privacy)" }],
<grid flex="1"> ["grid", { flex: "1" },
<columns><column flex="1"/><column flex="1"/></columns> ["columns", {},
<rows>{ ["column", { flex: "1" }],
["column", { flex: "1" }]],
["rows", {},
let (items = ourItems(true)) let (items = ourItems(true))
template.map(util.range(0, Math.ceil(items.length / 2)), function (i) template_.map(util.range(0, Math.ceil(items.length / 2)), function (i)
<row xmlns={XUL}>{ ["row", {},
template.map(items.slice(i * 2, i * 2 + 2), function (item) template_.map(items.slice(i * 2, i * 2 + 2), function (item)
<checkbox xmlns={XUL} label={item.description} preference={branch + item.name}/>) ["checkbox", { xmlns: XUL, label: item.description, preference: branch + item.name }])])]]],
}</row>)
}</rows>
</grid>
</groupbox>
} }
})); }));
} }
@@ -208,16 +205,14 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
overlay.overlayWindow("chrome://browser/content/sanitize.xul", overlay.overlayWindow("chrome://browser/content/sanitize.xul",
function (win) prefOverlay(branch, false, { function (win) prefOverlay(branch, false, {
append: { append: {
itemList: <> itemList: [
<listitem xmlns={XUL} label={/*L*/"See :help privacy for the following:"} disabled="true" style="font-style: italic; font-weight: bold;"/> ["listitem", { xmlns: "xul", label: /*L*/"See :help privacy for the following:",
{ disabled: "true", style: "font-style: italic; font-weight: bold;" }],
template.map(ourItems(), function ([item, desc]) template_.map(ourItems(), function ([item, desc])
<listitem xmlns={XUL} type="checkbox" ["listitem", { xmlns: "xul", preference: branch + item,
label={config.appName + " " + desc} type: "checkbox", label: config.appName + ", " + desc,
preference={branch + item} onsyncfrompreference: "return gSanitizePromptDialog.onReadGeneric();" }]),
onsyncfrompreference="return gSanitizePromptDialog.onReadGeneric();"/>) ]
}
</>
}, },
ready: function ready(win) { ready: function ready(win) {
let elem = win.document.getElementById("itemList"); let elem = win.document.getElementById("itemList");
@@ -529,11 +524,11 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
return; return;
case "list": case "list":
modules.commandline.commandOutput(template.tabular( modules.commandline.commandOutput(template_.tabular(
["Host", "Expiry (UTC)", "Path", "Name", "Value"], ["Host", "Expiry (UTC)", "Path", "Name", "Value"],
["padding-right: 1em", "padding-right: 1em", "padding-right: 1em", "max-width: 12em; overflow: hidden;", "padding-left: 1ex;"], ["padding-right: 1em", "padding-right: 1em", "padding-right: 1em", "max-width: 12em; overflow: hidden;", "padding-left: 1ex;"],
([c.host, ([c.host,
c.isSession ? <span highlight="Enabled">session</span> c.isSession ? ["span", { highlight: "Enabled" }, "session"]
: (new Date(c.expiry * 1000).toJSON() || "Never").replace(/:\d\d\.000Z/, "").replace("T", " ").replace(/-/g, "/"), : (new Date(c.expiry * 1000).toJSON() || "Never").replace(/:\d\d\.000Z/, "").replace("T", " ").replace(/-/g, "/"),
c.path, c.path,
c.name, c.name,
@@ -555,7 +550,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
let count = [0, 0]; let count = [0, 0];
for (let c in Sanitizer.iterCookies(host)) for (let c in Sanitizer.iterCookies(host))
count[c.isSession + 0]++; count[c.isSession + 0]++;
return <>{Sanitizer.COMMANDS[getPerms(host)]} (session: {count[1]} persistent: {count[0]})</>; return [Sanitizer.COMMANDS[getPerms(host)], " (session: ", count[1], " persistent: ", count[0], ")"].join("");
}; };
break; break;
case 1: case 1: