Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/options.js

Issue 8478020: Slight improvements to URL Fixer code (Closed)
Patch Set: Created Oct. 1, 2012, 4:03 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/content/options.xul » ('j') | lib/typoFixer.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « no previous file | chrome/content/options.xul » ('j') | lib/typoFixer.js » ('J')

Powered by Google App Engine
This is Rietveld