Index: chrome/content/options.js |
=================================================================== |
--- a/chrome/content/options.js |
+++ b/chrome/content/options.js |
@@ -32,50 +32,44 @@ function onFindChange() |
function onPrefChange(name) |
{ |
if (name == "custom_replace" || name == "whitelist") |
updateList(); |
} |
function updateList() |
{ |
+ // |
+ // Custom rules |
+ // |
+ |
let ruleListElement = E("custom_corrections"); |
- let whitelistElement = E("whitelist"); |
// Remove existing list entries |
for (let i = ruleListElement.getRowCount() - 1; i >= 0; i--) |
ruleListElement.removeItemAt(i); |
- for (let i = whitelistElement.getRowCount() - 1; i >= 0; i--) |
- whitelistElement.removeItemAt(i); |
// Build a list of custom rules and sort it alphabetically |
let prefRulesList = Prefs.custom_replace; |
- let prefWhitelist = Prefs.whitelist; |
let ruleList = []; |
- let whitelist = []; |
- |
+ |
for (let searchString in prefRulesList) |
{ |
ruleList.push([searchString, prefRulesList[searchString]]); |
} |
- for (let searchString in prefWhitelist) |
- { |
- whitelist.push(searchString); |
- } |
ruleList.sort(function(a, b) |
{ |
if (a[0] < b[0]) |
return -1; |
else if (a[0] > b[0]) |
return 1; |
else |
return 0; |
}); |
- whitelist.sort(); |
// Add the rules to the list |
if (ruleList.length > 0) |
{ |
for (let i = 0; i < ruleList.length; i++) |
{ |
let [searchString, replacement] = ruleList[i]; |
@@ -97,23 +91,38 @@ function updateList() |
{ |
let option = document.createElement("listitem"); |
option.setAttribute("class", "auto-entry"); |
option.setAttribute("label", ruleListElement.getAttribute("_emptyLabel")); |
ruleListElement.appendChild(option); |
} |
+ // |
+ // Exception rules |
+ // |
+ |
+ let whitelistElement = E("whitelist"); |
+ |
+ // Remove existing list entries |
+ for (let i = whitelistElement.getRowCount() - 1; i >= 0; i--) |
+ whitelistElement.removeItemAt(i); |
+ |
+ // Build a list of exceptions and sort it alphabetically |
+ let whitelist = Object.keys(Prefs.whitelist); |
+ whitelist.sort(); |
+ |
+ // Add the rules to the list |
if (whitelist.length > 0) |
{ |
for (let i = 0; i < whitelist.length; i++) |
{ |
let option = document.createElement("listitem"); |
option.setAttribute("value", whitelist[i]); |
- option.setAttribute("label", whitelist[i]) |
+ option.setAttribute("label", whitelist[i]); |
whitelistElement.appendChild(option); |
} |
} |
else |
{ |
let option = document.createElement("listitem"); |
option.setAttribute("class", "auto-entry"); |