| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 var backgroundPage = chrome.extension.getBackgroundPage(); | |
| 19 var require = backgroundPage.require; | |
| 20 | |
| 21 with(require("filterClasses")) | 18 with(require("filterClasses")) |
| 22 { | 19 { |
| 23 this.Filter = Filter; | 20 this.Filter = Filter; |
| 24 this.WhitelistFilter = WhitelistFilter; | 21 this.WhitelistFilter = WhitelistFilter; |
| 25 } | 22 } |
| 26 with(require("subscriptionClasses")) | 23 with(require("subscriptionClasses")) |
| 27 { | 24 { |
| 28 this.Subscription = Subscription; | 25 this.Subscription = Subscription; |
| 29 this.SpecialSubscription = SpecialSubscription; | 26 this.SpecialSubscription = SpecialSubscription; |
| 30 this.DownloadableSubscription = DownloadableSubscription; | 27 this.DownloadableSubscription = DownloadableSubscription; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 $("button").button(); | 64 $("button").button(); |
| 68 $(".refreshButton").button("option", "icons", {primary: "ui-icon-refresh"}); | 65 $(".refreshButton").button("option", "icons", {primary: "ui-icon-refresh"}); |
| 69 $(".addButton").button("option", "icons", {primary: "ui-icon-plus"}); | 66 $(".addButton").button("option", "icons", {primary: "ui-icon-plus"}); |
| 70 $(".removeButton").button("option", "icons", {primary: "ui-icon-minus"}); | 67 $(".removeButton").button("option", "icons", {primary: "ui-icon-minus"}); |
| 71 | 68 |
| 72 // Popuplate option checkboxes | 69 // Popuplate option checkboxes |
| 73 initCheckbox("shouldShowIcon"); | 70 initCheckbox("shouldShowIcon"); |
| 74 initCheckbox("shouldShowBlockElementMenu"); | 71 initCheckbox("shouldShowBlockElementMenu"); |
| 75 initCheckbox("hidePlaceholders"); | 72 initCheckbox("hidePlaceholders"); |
| 76 | 73 |
| 74 ext.onMessage.addListener(onMessage); |
| 75 |
| 77 // Load recommended subscriptions | 76 // Load recommended subscriptions |
| 78 loadRecommendations(); | 77 loadRecommendations(); |
| 79 | 78 |
| 80 // Show user's filters | 79 // Show user's filters |
| 81 reloadFilters(); | 80 reloadFilters(); |
| 82 } | 81 } |
| 83 $(loadOptions); | 82 $(loadOptions); |
| 84 | 83 |
| 84 function onMessage(msg) |
| 85 { |
| 86 switch (msg.type) |
| 87 { |
| 88 case "add-subscription": |
| 89 startSubscriptionSelection(msg.title, msg.url); |
| 90 break; |
| 91 default: |
| 92 console.log("got unexpected message: " + msg.type); |
| 93 } |
| 94 }; |
| 95 |
| 85 // Reloads the displayed subscriptions and filters | 96 // Reloads the displayed subscriptions and filters |
| 86 function reloadFilters() | 97 function reloadFilters() |
| 87 { | 98 { |
| 88 // Load user filter URLs | 99 // Load user filter URLs |
| 89 var container = document.getElementById("filterLists"); | 100 var container = document.getElementById("filterLists"); |
| 90 while (container.lastChild) | 101 while (container.lastChild) |
| 91 container.removeChild(container.lastChild); | 102 container.removeChild(container.lastChild); |
| 92 | 103 |
| 93 var hasAcceptable = false; | 104 var hasAcceptable = false; |
| 94 for (var i = 0; i < FilterStorage.subscriptions.length; i++) | 105 for (var i = 0; i < FilterStorage.subscriptions.length; i++) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 233 |
| 223 function startSubscriptionSelection(title, url) | 234 function startSubscriptionSelection(title, url) |
| 224 { | 235 { |
| 225 var list = document.getElementById("subscriptionSelector"); | 236 var list = document.getElementById("subscriptionSelector"); |
| 226 if (list.length == 0) | 237 if (list.length == 0) |
| 227 { | 238 { |
| 228 delayedSubscriptionSelection = [title, url]; | 239 delayedSubscriptionSelection = [title, url]; |
| 229 return; | 240 return; |
| 230 } | 241 } |
| 231 | 242 |
| 232 $('#tabs').tabs('select', 0); | 243 $("#tabs").tabs("select", 0); |
| 233 $("#addSubscriptionContainer").show(); | 244 $("#addSubscriptionContainer").show(); |
| 234 $("#addSubscriptionButton").hide(); | 245 $("#addSubscriptionButton").hide(); |
| 235 $("#subscriptionSelector").focus(); | 246 $("#subscriptionSelector").focus(); |
| 236 if (typeof url != "undefined") | 247 if (typeof url != "undefined") |
| 237 { | 248 { |
| 238 list.selectedIndex = list.length - 1; | 249 list.selectedIndex = list.length - 1; |
| 239 document.getElementById("customSubscriptionTitle").value = title; | 250 document.getElementById("customSubscriptionTitle").value = title; |
| 240 document.getElementById("customSubscriptionLocation").value = url; | 251 document.getElementById("customSubscriptionLocation").value = url; |
| 241 } | 252 } |
| 242 updateSubscriptionSelection(); | 253 updateSubscriptionSelection(); |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 links[i].href = arguments[i + 1]; | 645 links[i].href = arguments[i + 1]; |
| 635 links[i].setAttribute("target", "_blank"); | 646 links[i].setAttribute("target", "_blank"); |
| 636 } | 647 } |
| 637 else if (typeof arguments[i + 1] == "function") | 648 else if (typeof arguments[i + 1] == "function") |
| 638 { | 649 { |
| 639 links[i].href = "javascript:void(0);"; | 650 links[i].href = "javascript:void(0);"; |
| 640 links[i].addEventListener("click", arguments[i + 1], false); | 651 links[i].addEventListener("click", arguments[i + 1], false); |
| 641 } | 652 } |
| 642 } | 653 } |
| 643 } | 654 } |
| OLD | NEW |