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

Side by Side Diff: options.js

Issue 29328672: Issue 2668 - Use new subscription types in options page (Closed)
Patch Set: Created Sept. 25, 2015, 3:27 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 var elements = document.querySelectorAll("[data-access='" + access + " ']"); 203 var elements = document.querySelectorAll("[data-access='" + access + " ']");
204 for (var i = 0; i < elements.length; i++) 204 for (var i = 0; i < elements.length; i++)
205 { 205 {
206 var element = elements[i]; 206 var element = elements[i];
207 var control = element.querySelector(".control"); 207 var control = element.querySelector(".control");
208 if (control.localName == "input") 208 if (control.localName == "input")
209 control.checked = subscription.disabled == false; 209 control.checked = subscription.disabled == false;
210 if (subscriptionUrl in recommendationsMap) 210 if (subscriptionUrl in recommendationsMap)
211 { 211 {
212 var recommendation = recommendationsMap[subscriptionUrl]; 212 var recommendation = recommendationsMap[subscriptionUrl];
213 if (recommendation.isAdsType) 213 if (recommendation.type == "ads")
214 { 214 {
215 if (subscription.disabled == false) 215 if (subscription.disabled == false)
216 { 216 {
217 collections.allLangs.removeItem(subscription); 217 collections.allLangs.removeItem(subscription);
218 collections.langs.addItems(subscription); 218 collections.langs.addItems(subscription);
219 } 219 }
220 else 220 else
221 { 221 {
222 collections.allLangs.addItems(subscription); 222 collections.allLangs.addItems(subscription);
223 collections.langs.removeItem(subscription); 223 collections.langs.removeItem(subscription);
(...skipping 26 matching lines...) Expand all
250 } 250 }
251 else 251 else
252 { 252 {
253 Object.observe(subscription, onObjectChanged); 253 Object.observe(subscription, onObjectChanged);
254 } 254 }
255 255
256 var collection = null; 256 var collection = null;
257 if (subscriptionUrl in recommendationsMap) 257 if (subscriptionUrl in recommendationsMap)
258 { 258 {
259 var recommendation = recommendationsMap[subscriptionUrl]; 259 var recommendation = recommendationsMap[subscriptionUrl];
260 if (recommendation.isPopular) 260 if (recommendation.type != "ads")
261 collection = collections.popular; 261 collection = collections.popular;
262 else if (recommendation.isAdsType && subscription.disabled == false) 262 else if (subscription.disabled == false)
263 collection = collections.langs; 263 collection = collections.langs;
264 else 264 else
265 collection = collections.allLangs; 265 collection = collections.allLangs;
266 } 266 }
267 else if (subscriptionUrl == acceptableAdsUrl) 267 else if (subscriptionUrl == acceptableAdsUrl)
268 collection = collections.acceptableAds; 268 collection = collections.acceptableAds;
269 else 269 else
270 collection = collections.custom; 270 collection = collections.custom;
271 271
272 collection.addItems(subscription); 272 collection.addItems(subscription);
(...skipping 29 matching lines...) Expand all
302 { 302 {
303 var element = elements[i]; 303 var element = elements[i];
304 var subscription = Object.create(null); 304 var subscription = Object.create(null);
305 subscription.title = element.getAttribute("title"); 305 subscription.title = element.getAttribute("title");
306 subscription.url = element.getAttribute("url"); 306 subscription.url = element.getAttribute("url");
307 subscription.disabled = null; 307 subscription.disabled = null;
308 subscription.downloadStatus = null; 308 subscription.downloadStatus = null;
309 subscription.homepage = null; 309 subscription.homepage = null;
310 subscription.lastSuccess = null; 310 subscription.lastSuccess = null;
311 var recommendation = Object.create(null); 311 var recommendation = Object.create(null);
312 recommendation.isAdsType = false; 312 recommendation.type = element.getAttribute("type");
313 recommendation.isPopular = false;
314 var prefix = element.getAttribute("prefixes"); 313 var prefix = element.getAttribute("prefixes");
315 if (prefix) 314 if (prefix)
316 { 315 {
317 var prefix = element.getAttribute("prefixes").replace(/,/g, "_"); 316 prefix = prefix.replace(/\W/g, "_");
318 subscription.title = ext.i18n.getMessage("options_language_" + prefix) ; 317 subscription.title = ext.i18n.getMessage("options_language_" + prefix) ;
319 recommendation.isAdsType = true;
320 } 318 }
321 else 319 else
322 { 320 {
323 subscription.title = element.getAttribute("specialization"); 321 var type = recommendation.type.replace(/\W/g, "_");
Thomas Greiner 2015/09/25 15:43:22 I needed to replace "-" with "_" for "common_featu
saroyanm 2015/11/10 16:47:25 Nit: What is the reason to assign the result to va
Thomas Greiner 2015/11/10 19:54:09 Just a personal preference to improve readability
saroyanm 2015/11/11 10:47:57 I see, well while nothing related in coding styles
324 recommendation.isPopular = true; 322 subscription.title = ext.i18n.getMessage("common_feature_" + type + "_ title");
325 } 323 }
326 324
327 recommendationsMap[subscription.url] = recommendation; 325 recommendationsMap[subscription.url] = recommendation;
328 updateSubscription(subscription); 326 updateSubscription(subscription);
329 } 327 }
330 }, false); 328 }, false);
331 request.send(null); 329 request.send(null);
332 } 330 }
333 331
334 function onClick(e) 332 function onClick(e)
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 filter: ["added", "loaded", "removed"] 740 filter: ["added", "loaded", "removed"]
743 }); 741 });
744 ext.backgroundPage.sendMessage( 742 ext.backgroundPage.sendMessage(
745 { 743 {
746 type: "subscriptions.listen", 744 type: "subscriptions.listen",
747 filter: ["added", "disabled", "homepage", "removed", "title"] 745 filter: ["added", "disabled", "homepage", "removed", "title"]
748 }); 746 });
749 747
750 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 748 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
751 })(); 749 })();
OLDNEW
« no previous file with comments | « locale/en-US/common.json ('k') | subscriptions.xml » ('j') | subscriptions.xml » ('J')

Powered by Google App Engine
This is Rietveld