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

Side by Side Diff: options.js

Issue 29333819: Issue 2375 - Implement "Blocking lists" section in new options page (Closed)
Patch Set: Created Jan. 29, 2016, 6:54 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 27 matching lines...) Expand all
38 { 38 {
39 placeholder = document.createElement("li"); 39 placeholder = document.createElement("li");
40 placeholder.className = "empty-placeholder"; 40 placeholder.className = "empty-placeholder";
41 placeholder.textContent = ext.i18n.getMessage(text); 41 placeholder.textContent = ext.i18n.getMessage(text);
42 table.appendChild(placeholder); 42 table.appendChild(placeholder);
43 } 43 }
44 else if (placeholder) 44 else if (placeholder)
45 table.removeChild(placeholder); 45 table.removeChild(placeholder);
46 } 46 }
47 47
48 Collection.prototype._createElementQuery = function(item)
49 {
50 var access = (item.url || item.text).replace(/'/g, "\\'");
51 return function(container)
52 {
53 return container.querySelector("[data-access='" + access + "']");
54 };
55 };
56
48 Collection.prototype.addItems = function() 57 Collection.prototype.addItems = function()
49 { 58 {
50 var length = Array.prototype.push.apply(this.items, arguments); 59 var length = Array.prototype.push.apply(this.items, arguments);
51 if (length == 0) 60 if (length == 0)
52 return; 61 return;
53 62
54 this.items.sort(function(a, b) 63 this.items.sort(function(a, b)
55 { 64 {
56 var aValue = (a.title || a.text || a.url).toLowerCase(); 65 var aValue = (a.title || a.text || a.url).toLowerCase();
57 var bValue = (b.title || b.text || b.url).toLowerCase(); 66 var bValue = (b.title || b.text || b.url).toLowerCase();
(...skipping 17 matching lines...) Expand all
75 if (control) 84 if (control)
76 { 85 {
77 // We use aria-labelledby to avoid triggering the control when 86 // We use aria-labelledby to avoid triggering the control when
78 // interacting with the label 87 // interacting with the label
79 control.setAttribute("aria-labelledby", labelId); 88 control.setAttribute("aria-labelledby", labelId);
80 control.addEventListener("click", this.details[j].onClick, false); 89 control.addEventListener("click", this.details[j].onClick, false);
81 } 90 }
82 91
83 this._setEmpty(table, null); 92 this._setEmpty(table, null);
84 if (table.hasChildNodes()) 93 if (table.hasChildNodes())
85 table.insertBefore(listItem, table.childNodes[this.items.indexOf(item) ]); 94 {
95 table.insertBefore(listItem,
96 table.childNodes[this.items.indexOf(item)]);
97 }
86 else 98 else
87 table.appendChild(listItem); 99 table.appendChild(listItem);
88 this.updateItem(item); 100 this.updateItem(item);
89 } 101 }
90 } 102 }
91 return length; 103 return length;
92 }; 104 };
93 105
94 Collection.prototype.removeItem = function(item) 106 Collection.prototype.removeItem = function(item)
95 { 107 {
96 var index = this.items.indexOf(item); 108 var index = this.items.indexOf(item);
97 if (index == -1) 109 if (index == -1)
98 return; 110 return;
99 111
100 this.items.splice(index, 1); 112 this.items.splice(index, 1);
113 var getListElement = this._createElementQuery(item);
101 for (var i = 0; i < this.details.length; i++) 114 for (var i = 0; i < this.details.length; i++)
102 { 115 {
103 var table = E(this.details[i].id); 116 var table = E(this.details[i].id);
104 var element = table.childNodes[index]; 117 var element = getListElement(table);
105 118
106 // Element gets removed so make sure to handle focus appropriately 119 // Element gets removed so make sure to handle focus appropriately
107 var control = element.querySelector(".control"); 120 var control = element.querySelector(".control");
108 if (control && control == document.activeElement) 121 if (control && control == document.activeElement)
109 { 122 {
110 if (!focusNextElement(element.parentElement, control)) 123 if (!focusNextElement(element.parentElement, control))
111 { 124 {
112 // Fall back to next focusable element within same tab or dialog 125 // Fall back to next focusable element within same tab or dialog
113 var focusableElement = element.parentElement; 126 var focusableElement = element.parentElement;
114 while (focusableElement) 127 while (focusableElement)
(...skipping 24 matching lines...) Expand all
139 if (!element) 152 if (!element)
140 continue; 153 continue;
141 154
142 var text = item.title || item.url || item.text; 155 var text = item.title || item.url || item.text;
143 element.querySelector(".display").textContent = text; 156 element.querySelector(".display").textContent = text;
144 if (text) 157 if (text)
145 element.setAttribute("data-search", text.toLowerCase()); 158 element.setAttribute("data-search", text.toLowerCase());
146 var control = element.querySelector(".control[role='checkbox']"); 159 var control = element.querySelector(".control[role='checkbox']");
147 if (control) 160 if (control)
148 control.setAttribute("aria-checked", item.disabled == false); 161 control.setAttribute("aria-checked", item.disabled == false);
162
163 var dateElement = element.querySelector(".date");
164 var timeElement = element.querySelector(".time");
165 if(dateElement && timeElement)
166 {
167 if (item.downloadStatus &&
168 item.downloadStatus != "synchronize_ok")
169 {
170 var map =
Thomas Greiner 2016/02/01 18:52:36 Detail: This content is static so it should be def
saroyanm 2016/02/03 14:04:26 Done, also made some other function/variable assig
171 {
172 "synchronize_invalid_url": "options_subscription_lastDownload_invali dURL",
173 "synchronize_connection_error": "options_subscription_lastDownload_c onnectionError",
174 "synchronize_invalid_data": "options_subscription_lastDownload_inval idData",
175 "synchronize_checksum_mismatch": "options_subscription_lastDownload_ checksumMismatch"
176 };
177 if (item.downloadStatus in map)
178 timeElement.textContent = ext.i18n.getMessage(map[item.downloadStatu s]);
179 else
180 timeElement.textContent = item.downloadStatus;
181 }
182 else if (item.lastDownload > 0)
183 {
184 var dateTime = i18n_formatDateTime(item.lastDownload * 1000);
185 dateElement.textContent = dateTime[0];
186 timeElement.textContent = dateTime[1];
187 }
Thomas Greiner 2016/02/01 18:52:35 What about the else-case here? Currently, this wil
saroyanm 2016/02/03 14:04:26 Good point, sorry for that, Done.
188 }
189 var websiteElement = element.querySelector(".context-menu .website");
190 var sourceElement = element.querySelector(".context-menu .source");
191 if (websiteElement && item.homepage)
192 websiteElement.setAttribute("href", item.homepage);
193 if (sourceElement)
194 sourceElement.setAttribute("href", item.url);
149 } 195 }
150 }; 196 };
151 197
152 Collection.prototype.clearAll = function() 198 Collection.prototype.clearAll = function()
153 { 199 {
154 this.items = []; 200 this.items = [];
155 for (var i = 0; i < this.details.length; i++) 201 for (var i = 0; i < this.details.length; i++)
156 { 202 {
157 var table = E(this.details[i].id); 203 var table = E(this.details[i].id);
158 var template = table.querySelector("template"); 204 var element = table.firstChild;
159 table.innerHTML = ""; 205 while (element)
160 table.appendChild(template); 206 {
207 if (element.tagName == "LI" && !element.classList.contains("static"))
208 table.removeChild(element);
209 element = element.nextElementSibling;
210 }
211
161 this._setEmpty(table, this.details[i].emptyText); 212 this._setEmpty(table, this.details[i].emptyText);
162 } 213 }
163 }; 214 };
164 215
165 function focusNextElement(container, currentElement) 216 function focusNextElement(container, currentElement)
166 { 217 {
167 var focusables = container.querySelectorAll("a, button, input, .control"); 218 var focusables = container.querySelectorAll("a, button, input, .control");
168 focusables = Array.prototype.slice.call(focusables); 219 focusables = Array.prototype.slice.call(focusables);
169 var index = focusables.indexOf(currentElement); 220 var index = focusables.indexOf(currentElement);
170 index += (index == focusables.length - 1) ? -1 : 1; 221 index += (index == focusables.length - 1) ? -1 : 1;
171 222
172 var nextElement = focusables[index]; 223 var nextElement = focusables[index];
173 if (!nextElement) 224 if (!nextElement)
174 return false; 225 return false;
175 226
176 nextElement.focus(); 227 nextElement.focus();
177 return true; 228 return true;
178 } 229 }
179 230
180 function onToggleSubscriptionClick(e) 231 function toggleRemoveSubscription(e)
181 { 232 {
182 e.preventDefault(); 233 e.preventDefault();
183 var checkbox = e.target; 234 var subscriptionUrl = findParentData(e.target, "access", false);
184 var subscriptionUrl = checkbox.parentElement.getAttribute("data-access"); 235 if (e.target.getAttribute("aria-checked") == "true")
185 if (checkbox.getAttribute("aria-checked") == "true")
186 { 236 {
187 ext.backgroundPage.sendMessage({ 237 ext.backgroundPage.sendMessage({
188 type: "subscriptions.remove", 238 type: "subscriptions.remove",
189 url: subscriptionUrl 239 url: subscriptionUrl
190 }); 240 });
191 } 241 }
192 else 242 else
193 addEnableSubscription(subscriptionUrl); 243 addEnableSubscription(subscriptionUrl);
194 } 244 }
195 245
246 function toggleDisableSubscription(e)
247 {
248 e.preventDefault();
249 var subscriptionUrl = findParentData(e.target, "access", false);
250 ext.backgroundPage.sendMessage(
251 {
252 type: "subscriptions.toggle",
253 keepInstalled: true,
254 url: subscriptionUrl
255 });
256 }
257
196 function onAddLanguageSubscriptionClick(e) 258 function onAddLanguageSubscriptionClick(e)
197 { 259 {
198 e.preventDefault(); 260 e.preventDefault();
199 var url = this.parentNode.getAttribute("data-access"); 261 var url = findParentData(this, "access", false);
200 addEnableSubscription(url); 262 addEnableSubscription(url);
201 } 263 }
202 264
203 function onRemoveFilterClick() 265 function onRemoveFilterClick()
204 { 266 {
205 var filter = this.parentNode.getAttribute("data-access"); 267 var filter = findParentData(this, "access", false);
206 ext.backgroundPage.sendMessage( 268 ext.backgroundPage.sendMessage(
207 { 269 {
208 type: "filters.remove", 270 type: "filters.remove",
209 text: filter 271 text: filter
210 }); 272 });
211 } 273 }
212 274
213 collections.popular = new Collection( 275 collections.popular = new Collection(
214 [ 276 [
215 { 277 {
216 id: "recommend-list-table", 278 id: "recommend-list-table",
217 onClick: onToggleSubscriptionClick 279 onClick: toggleRemoveSubscription
218 } 280 }
219 ]); 281 ]);
220 collections.langs = new Collection( 282 collections.langs = new Collection(
221 [ 283 [
222 { 284 {
223 id: "blocking-languages-table", 285 id: "blocking-languages-table",
224 emptyText: "options_dialog_language_added_empty", 286 emptyText: "options_dialog_language_added_empty",
225 onClick: onToggleSubscriptionClick 287 onClick: toggleRemoveSubscription
226 }, 288 },
227 { 289 {
228 id: "blocking-languages-dialog-table", 290 id: "blocking-languages-dialog-table",
229 emptyText: "options_dialog_language_added_empty" 291 emptyText: "options_dialog_language_added_empty"
230 } 292 }
231 ]); 293 ]);
232 collections.allLangs = new Collection( 294 collections.allLangs = new Collection(
233 [ 295 [
234 { 296 {
235 id: "all-lang-table", 297 id: "all-lang-table",
236 emptyText: "options_dialog_language_other_empty", 298 emptyText: "options_dialog_language_other_empty",
237 onClick: onAddLanguageSubscriptionClick 299 onClick: onAddLanguageSubscriptionClick
238 } 300 }
239 ]); 301 ]);
240 collections.acceptableAds = new Collection( 302 collections.acceptableAds = new Collection(
241 [ 303 [
242 { 304 {
243 id: "acceptableads-table", 305 id: "acceptableads-table",
244 onClick: onToggleSubscriptionClick 306 onClick: toggleRemoveSubscription
245 } 307 }
246 ]); 308 ]);
247 collections.custom = new Collection( 309 collections.custom = new Collection(
248 [ 310 [
249 { 311 {
250 id: "custom-list-table", 312 id: "custom-list-table",
251 onClick: onToggleSubscriptionClick 313 onClick: toggleRemoveSubscription
252 } 314 }
253 ]); 315 ]);
254 collections.whitelist = new Collection( 316 collections.whitelist = new Collection(
255 [ 317 [
256 { 318 {
257 id: "whitelisting-table", 319 id: "whitelisting-table",
258 emptyText: "options_whitelisted_empty", 320 emptyText: "options_whitelisted_empty",
259 onClick: onRemoveFilterClick 321 onClick: onRemoveFilterClick
260 } 322 }
261 ]); 323 ]);
262 collections.customFilters = new Collection( 324 collections.customFilters = new Collection(
263 [ 325 [
264 { 326 {
265 id: "custom-filters-table", 327 id: "custom-filters-table",
266 emptyText: "options_customFilters_empty" 328 emptyText: "options_customFilters_empty"
267 } 329 }
268 ]); 330 ]);
331 collections.filterLists = new Collection(
332 [
333 {
334 id: "all-filter-lists-table",
335 onClick: toggleDisableSubscription
336 }
337 ]);
269 338
270 function updateSubscription(subscription) 339 function observeSubscription(subscription)
271 { 340 {
272 var subscriptionUrl = subscription.url; 341 function onObjectChanged(change)
273 var knownSubscription = subscriptionsMap[subscriptionUrl];
274 if (knownSubscription)
275 knownSubscription.disabled = subscription.disabled;
276 else
277 { 342 {
278 getAcceptableAdsURL(function(acceptableAdsUrl) 343 for (var i = 0; i < change.length; i++)
279 { 344 {
280 function onObjectChanged() 345 if (change[i].name == "disabled")
281 { 346 {
282 for (var i in collections) 347 var recommendation = recommendationsMap[subscription.url];
283 collections[i].updateItem(subscription);
284
285 var recommendation = recommendationsMap[subscriptionUrl];
286 if (recommendation && recommendation.type == "ads") 348 if (recommendation && recommendation.type == "ads")
287 { 349 {
288 if (subscription.disabled == false) 350 if (subscription.disabled == false)
289 { 351 {
290 collections.allLangs.removeItem(subscription); 352 collections.allLangs.removeItem(subscription);
291 collections.langs.addItems(subscription); 353 collections.langs.addItems(subscription);
292 } 354 }
293 else 355 else
294 { 356 {
295 collections.allLangs.addItems(subscription); 357 collections.allLangs.addItems(subscription);
296 collections.langs.removeItem(subscription); 358 collections.langs.removeItem(subscription);
297 } 359 }
298 } 360 }
299 } 361 }
362 for (var i in collections)
363 collections[i].updateItem(subscription);
364 }
365 }
300 366
301 if (!Object.observe) 367 if (!Object.observe)
Thomas Greiner 2016/02/01 18:52:35 Since `Object.observe()` is not implemented in Saf
saroyanm 2016/02/03 14:04:26 Thanks for pointing that out, apparently we have t
368 {
369 ["disabled", "lastDownload"].forEach(function(property)
370 {
371 subscription["$" + property] = subscription[property];
372 Object.defineProperty(subscription, property,
302 { 373 {
303 // Currently only "disabled" property of subscription used for observa tion 374 get: function()
304 // but with Advanced tab implementation we should also add more proper ties.
305 ["disabled"].forEach(function(property)
306 { 375 {
307 subscription["$" + property] = subscription[property]; 376 return this["$" + property];
308 Object.defineProperty(subscription, property, 377 },
309 { 378 set: function(value)
310 get: function() 379 {
311 { 380 this["$" + property] = value;
312 return this["$" + property]; 381 var change = Object.create(null);
313 }, 382 change.name = property;
314 set: function(value) 383 onObjectChanged([change]);
315 { 384 }
316 this["$" + property] = value; 385 });
317 onObjectChanged(); 386 });
318 } 387 }
319 }); 388 else
320 }); 389 {
321 } 390 Object.observe(subscription, onObjectChanged);
322 else 391 }
323 { 392 }
324 Object.observe(subscription, onObjectChanged);
325 }
326 393
394 function updateSubscription(subscription)
395 {
396 var subscriptionUrl = subscription.url;
397 var knownSubscription = subscriptionsMap[subscriptionUrl];
398 if (knownSubscription)
399 {
400 for (var property in subscription)
401 if (property != "title")
402 knownSubscription[property] = subscription[property];
403 }
404 else
405 {
406 observeSubscription(subscription);
407 getAcceptableAdsURL(function(acceptableAdsUrl)
408 {
327 var collection = null; 409 var collection = null;
328 if (subscriptionUrl in recommendationsMap) 410 if (subscriptionUrl in recommendationsMap)
329 { 411 {
330 var recommendation = recommendationsMap[subscriptionUrl]; 412 var recommendation = recommendationsMap[subscriptionUrl];
331 if (recommendation.type != "ads") 413 if (recommendation.type != "ads")
332 collection = collections.popular; 414 collection = collections.popular;
333 else if (subscription.disabled == false) 415 else if (subscription.disabled == false)
334 collection = collections.langs; 416 collection = collections.langs;
335 else 417 else
336 collection = collections.allLangs; 418 collection = collections.allLangs;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 var elements = doc.documentElement.getElementsByTagName("subscription"); 456 var elements = doc.documentElement.getElementsByTagName("subscription");
375 for (var i = 0; i < elements.length; i++) 457 for (var i = 0; i < elements.length; i++)
376 { 458 {
377 var element = elements[i]; 459 var element = elements[i];
378 var subscription = Object.create(null); 460 var subscription = Object.create(null);
379 subscription.title = element.getAttribute("title"); 461 subscription.title = element.getAttribute("title");
380 subscription.url = element.getAttribute("url"); 462 subscription.url = element.getAttribute("url");
381 subscription.disabled = null; 463 subscription.disabled = null;
382 subscription.downloadStatus = null; 464 subscription.downloadStatus = null;
383 subscription.homepage = null; 465 subscription.homepage = null;
384 subscription.lastSuccess = null;
385 var recommendation = Object.create(null); 466 var recommendation = Object.create(null);
386 recommendation.type = element.getAttribute("type"); 467 recommendation.type = element.getAttribute("type");
387 var prefix = element.getAttribute("prefixes"); 468 var prefix = element.getAttribute("prefixes");
388 if (prefix) 469 if (prefix)
389 { 470 {
390 prefix = prefix.replace(/\W/g, "_"); 471 prefix = prefix.replace(/\W/g, "_");
391 subscription.title = ext.i18n.getMessage("options_language_" + prefi x); 472 subscription.title = ext.i18n.getMessage("options_language_" + prefi x);
392 } 473 }
393 else 474 else
394 { 475 {
395 var type = recommendation.type.replace(/\W/g, "_"); 476 var type = recommendation.type.replace(/\W/g, "_");
396 subscription.title = ext.i18n.getMessage("common_feature_" + type + "_title"); 477 subscription.title = ext.i18n.getMessage("common_feature_" + type + "_title");
397 } 478 }
398 479
399 recommendationsMap[subscription.url] = recommendation; 480 recommendationsMap[subscription.url] = recommendation;
400 updateSubscription(subscription); 481 updateSubscription(subscription);
401 } 482 }
402 }); 483 });
403 } 484 }
404 485
486 function findParentData(element, dataName, returnElement)
487 {
488 while (element)
489 {
490 if (element.hasAttribute("data-" + dataName))
491 return returnElement ? element : element.getAttribute("data-" + dataName );
492
493 element = element.parentElement;
494 }
495 return null;
496 }
497
405 function onClick(e) 498 function onClick(e)
406 { 499 {
500 var context = document.querySelector(".show-context-menu");
501 if (context)
502 context.classList.remove("show-context-menu");
503
407 var element = e.target; 504 var element = e.target;
408 while (true) 505 while (true)
409 { 506 {
410 if (!element) 507 if (!element)
411 return; 508 return;
412 509
413 if (element.hasAttribute("data-action")) 510 if (element.hasAttribute("data-action"))
414 break; 511 break;
415 512
416 element = element.parentElement; 513 element = element.parentElement;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 { 559 {
463 type: "filters.importRaw", 560 type: "filters.importRaw",
464 text: E("custom-filters-raw").value 561 text: E("custom-filters-raw").value
465 }); 562 });
466 E("custom-filters").classList.remove("mode-edit"); 563 E("custom-filters").classList.remove("mode-edit");
467 break; 564 break;
468 case "switch-tab": 565 case "switch-tab":
469 document.body.setAttribute("data-tab", 566 document.body.setAttribute("data-tab",
470 element.getAttribute("data-tab")); 567 element.getAttribute("data-tab"));
471 break; 568 break;
569 case "update-all-subscriptions":
570 ext.backgroundPage.sendMessage(
571 {
572 type: "subscriptions.update"
573 });
574 break;
575 case "open-context-menu":
576 var listItem = findParentData(element, "access", true);
577 if (listItem != context)
578 listItem.classList.add("show-context-menu");
579 break;
580 case "update-now":
Thomas Greiner 2016/02/01 18:52:36 Detail: For consistency I'd suggest renaming this
saroyanm 2016/02/03 14:04:27 Fare enough, done.
581 ext.backgroundPage.sendMessage(
582 {
583 type: "subscriptions.update",
584 url: findParentData(element, "access", false)
585 });
586 break;
587 case "remove-subscription":
588 ext.backgroundPage.sendMessage(
589 {
590 type: "subscriptions.remove",
591 url: findParentData(element, "access", false)
592 });
593 break;
472 } 594 }
473 } 595 }
474 } 596 }
475 597
476 function onDOMLoaded() 598 function onDOMLoaded()
477 { 599 {
478 var recommendationTemplate = document.querySelector("#recommend-list-table t emplate");
479 var popularText = ext.i18n.getMessage("options_popular");
480 recommendationTemplate.content.querySelector(".popular").textContent = popul arText;
481 var languagesTemplate = document.querySelector("#all-lang-table template");
482 var buttonText = ext.i18n.getMessage("options_button_add");
483 languagesTemplate.content.querySelector(".button-add span").textContent = bu ttonText;
484
485 populateLists(); 600 populateLists();
486
487 function onFindLanguageKeyUp() 601 function onFindLanguageKeyUp()
488 { 602 {
489 var searchStyle = E("search-style"); 603 var searchStyle = E("search-style");
490 if (!this.value) 604 if (!this.value)
491 searchStyle.innerHTML = ""; 605 searchStyle.innerHTML = "";
492 else 606 else
493 searchStyle.innerHTML = "#all-lang-table li:not([data-search*=\"" + this .value.toLowerCase() + "\"]) { display: none; }"; 607 searchStyle.innerHTML = "#all-lang-table li:not([data-search*=\"" + this .value.toLowerCase() + "\"]) { display: none; }";
494 } 608 }
495 609
496 function getKey(e) 610 function getKey(e)
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 updateShareLink(); 862 updateShareLink();
749 break; 863 break;
750 } 864 }
751 } 865 }
752 866
753 function onSubscriptionMessage(action, subscription) 867 function onSubscriptionMessage(action, subscription)
754 { 868 {
755 switch (action) 869 switch (action)
756 { 870 {
757 case "added": 871 case "added":
872 updateSubscription(subscription);
873 updateShareLink();
874
875 var knownSubscription = subscriptionsMap[subscription.url];
876 if (knownSubscription)
877 collections.filterLists.addItems(knownSubscription);
878 else
879 collections.filterLists.addItems(subscription);
880 break;
758 case "disabled": 881 case "disabled":
759 updateSubscription(subscription); 882 updateSubscription(subscription);
760 updateShareLink(); 883 updateShareLink();
761 break; 884 break;
885 case "lastDownload":
886 updateSubscription(subscription);
887 break;
762 case "homepage": 888 case "homepage":
763 // TODO: NYI 889 // TODO: NYI
764 break; 890 break;
765 case "removed": 891 case "removed":
892 var knownSubscription = subscriptionsMap[subscription.url];
766 getAcceptableAdsURL(function(acceptableAdsUrl) 893 getAcceptableAdsURL(function(acceptableAdsUrl)
767 { 894 {
768 if (subscription.url == acceptableAdsUrl) 895 if (subscription.url == acceptableAdsUrl)
769 { 896 {
770 subscription.disabled = true; 897 subscription.disabled = true;
771 updateSubscription(subscription); 898 updateSubscription(subscription);
772 } 899 }
773 else 900 else
774 { 901 {
775 var knownSubscription = subscriptionsMap[subscription.url];
776 if (subscription.url in recommendationsMap) 902 if (subscription.url in recommendationsMap)
777 knownSubscription.disabled = true; 903 knownSubscription.disabled = true;
778 else 904 else
779 { 905 {
780 collections.custom.removeItem(knownSubscription); 906 collections.custom.removeItem(knownSubscription);
781 delete subscriptionsMap[subscription.url]; 907 delete subscriptionsMap[subscription.url];
782 } 908 }
783 } 909 }
784 updateShareLink(); 910 updateShareLink();
911 collections.filterLists.removeItem(knownSubscription);
785 }); 912 });
786 break; 913 break;
787 case "title": 914 case "title":
788 // TODO: NYI 915 // TODO: NYI
789 break; 916 break;
790 } 917 }
791 } 918 }
792 919
793 function onShareLinkClick(e) 920 function onShareLinkClick(e)
794 { 921 {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 filter: ["addSubscription", "error"] 991 filter: ["addSubscription", "error"]
865 }); 992 });
866 ext.backgroundPage.sendMessage( 993 ext.backgroundPage.sendMessage(
867 { 994 {
868 type: "filters.listen", 995 type: "filters.listen",
869 filter: ["added", "loaded", "removed"] 996 filter: ["added", "loaded", "removed"]
870 }); 997 });
871 ext.backgroundPage.sendMessage( 998 ext.backgroundPage.sendMessage(
872 { 999 {
873 type: "subscriptions.listen", 1000 type: "subscriptions.listen",
874 filter: ["added", "disabled", "homepage", "removed", "title"] 1001 filter: ["added", "disabled", "homepage", "lastDownload", "removed", "title" ]
875 }); 1002 });
876 1003
877 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1004 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
878 })(); 1005 })();
OLDNEW

Powered by Google App Engine
This is Rietveld