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

Unified Diff: chrome/content/options.js

Issue 8382011: Applied changes from emailed code review (Closed)
Patch Set: Created Sept. 28, 2012, 1:40 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') | no next file with comments »
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
@@ -47,19 +47,18 @@
whitelistElement.removeItemAt(i);
// Build a list of custom rules and sort it alphabetically
- let customRules = Prefs.custom_replace;
+ let prefRulesList = Prefs.custom_replace;
+ let prefWhitelist = Prefs.whitelist;
let ruleList = [];
let whitelist = [];
- for (let searchString in customRules)
+
+ for (let searchString in prefRulesList)
{
- if(searchString == customRules[searchString])
- {
- whitelist.push(searchString);
- }
- else
- {
- ruleList.push([searchString, customRules[searchString]]);
- }
+ ruleList.push([searchString, prefRulesList[searchString]]);
+ }
+ for (let searchString in prefWhitelist)
+ {
+ whitelist.push(searchString);
}
ruleList.sort(function(a, b)
@@ -74,7 +73,7 @@
whitelist.sort();
// Add the rules to the list
- if(ruleList.length > 0)
+ if (ruleList.length > 0)
{
for (let i = 0; i < ruleList.length; i++)
{
@@ -103,7 +102,7 @@
ruleListElement.appendChild(option);
}
- if(whitelist.length > 0)
+ if (whitelist.length > 0)
{
for (let i = 0; i < whitelist.length; i++)
{
@@ -138,15 +137,20 @@
E("find").oninput();
}
-function removeRule(btn)
+function removeRule(btn, pref)
{
let list = E(btn.getAttribute("_list"));
let items = list.selectedItems;
+ let {onWhitelistEntryRemoved} = require("rules");
+
for (let i = items.length - 1; i >= 0; i--)
{
let searchString = items[i].getAttribute("value");
- delete Prefs.custom_replace[searchString];
+ delete Prefs[pref][searchString];
+
+ if (pref == "whitelist")
+ onWhitelistEntryRemoved(searchString);
}
- Prefs.custom_replace = JSON.parse(JSON.stringify(Prefs.custom_replace));
+ Prefs[pref] = JSON.parse(JSON.stringify(Prefs[pref]));
}
« no previous file with comments | « no previous file | chrome/content/options.xul » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld