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

Delta Between Two Patch Sets: chrome/content/options.js

Issue 8433028: added hook function to appIntegration to handle function-overwrites from other extensions (Closed)
Left Patch Set: Created Sept. 25, 2012, 4:30 p.m.
Right Patch Set: added missing statement Created Sept. 28, 2012, 9:52 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | chrome/content/tests/qunit.css » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 * This Source Code is subject to the terms of the Mozilla Public License 2 * This Source Code is subject to the terms of the Mozilla Public License
3 * version 2.0 (the "License"). You can obtain a copy of the License at 3 * version 2.0 (the "License"). You can obtain a copy of the License at
4 * http://mozilla.org/MPL/2.0/. 4 * http://mozilla.org/MPL/2.0/.
5 */ 5 */
6 6
7 Cu.import("resource://gre/modules/Services.jsm"); 7 Cu.import("resource://gre/modules/Services.jsm");
8 8
9 let {Prefs} = require("prefs"); 9 let {Prefs} = require("prefs");
10 Prefs.addListener(onPrefChange); 10 Prefs.addListener(onPrefChange);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (a[0] < b[0]) 66 if (a[0] < b[0])
67 return -1; 67 return -1;
68 else if (a[0] > b[0]) 68 else if (a[0] > b[0])
69 return 1; 69 return 1;
70 else 70 else
71 return 0; 71 return 0;
72 }); 72 });
73 whitelist.sort(); 73 whitelist.sort();
74 74
75 // Add the rules to the list 75 // Add the rules to the list
76 if(ruleList.length > 0) 76 if (ruleList.length > 0)
77 { 77 {
78 for (let i = 0; i < ruleList.length; i++) 78 for (let i = 0; i < ruleList.length; i++)
79 { 79 {
80 let [searchString, replacement] = ruleList[i]; 80 let [searchString, replacement] = ruleList[i];
81 81
82 let option = document.createElement('listitem'); 82 let option = document.createElement('listitem');
83 option.setAttribute("value", searchString); 83 option.setAttribute("value", searchString);
84 84
85 let cell1 = document.createElement('listcell'); 85 let cell1 = document.createElement('listcell');
86 cell1.setAttribute("label", searchString); 86 cell1.setAttribute("label", searchString);
87 option.appendChild(cell1); 87 option.appendChild(cell1);
88 88
89 let cell2 = document.createElement('listcell'); 89 let cell2 = document.createElement('listcell');
90 cell2.setAttribute("label", replacement); 90 cell2.setAttribute("label", replacement);
91 option.appendChild(cell2); 91 option.appendChild(cell2);
92 92
93 ruleListElement.appendChild(option); 93 ruleListElement.appendChild(option);
94 } 94 }
95 } 95 }
96 else 96 else
97 { 97 {
98 let option = document.createElement("listitem"); 98 let option = document.createElement("listitem");
99 option.setAttribute("class", "auto-entry"); 99 option.setAttribute("class", "auto-entry");
100 option.setAttribute("label", ruleListElement.getAttribute("_emptyLabel")); 100 option.setAttribute("label", ruleListElement.getAttribute("_emptyLabel"));
101 101
102 ruleListElement.appendChild(option); 102 ruleListElement.appendChild(option);
103 } 103 }
104 104
105 if(whitelist.length > 0) 105 if (whitelist.length > 0)
106 { 106 {
107 for (let i = 0; i < whitelist.length; i++) 107 for (let i = 0; i < whitelist.length; i++)
108 { 108 {
109 let option = document.createElement("listitem"); 109 let option = document.createElement("listitem");
110 option.setAttribute("value", whitelist[i]); 110 option.setAttribute("value", whitelist[i]);
111 option.setAttribute("label", whitelist[i]) 111 option.setAttribute("label", whitelist[i])
112 112
113 whitelistElement.appendChild(option); 113 whitelistElement.appendChild(option);
114 } 114 }
115 } 115 }
(...skipping 19 matching lines...) Expand all
135 135
136 E("find").value = E("replace").value = ""; 136 E("find").value = E("replace").value = "";
137 E("find").oninput(); 137 E("find").oninput();
138 } 138 }
139 139
140 function removeRule(btn, pref) 140 function removeRule(btn, pref)
141 { 141 {
142 let list = E(btn.getAttribute("_list")); 142 let list = E(btn.getAttribute("_list"));
143 let items = list.selectedItems; 143 let items = list.selectedItems;
144 144
145 let {onWhitelistEntryRemoved} = require("rules");
146
145 for (let i = items.length - 1; i >= 0; i--) 147 for (let i = items.length - 1; i >= 0; i--)
146 { 148 {
147 let searchString = items[i].getAttribute("value"); 149 let searchString = items[i].getAttribute("value");
148 delete Prefs[pref][searchString]; 150 delete Prefs[pref][searchString];
151
152 if (pref == "whitelist")
153 onWhitelistEntryRemoved(searchString);
149 } 154 }
150 Prefs[pref] = JSON.parse(JSON.stringify(Prefs[pref])); 155 Prefs[pref] = JSON.parse(JSON.stringify(Prefs[pref]));
151 } 156 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld