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

Side by Side Diff: options.js

Issue 11094018: Use i18n.js from adblockplus to restrict HTML tag usage (Closed)
Patch Set: Created July 16, 2013, 9:28 a.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 <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
(...skipping 15 matching lines...) Expand all
26 with(require("subscriptionClasses")) 26 with(require("subscriptionClasses"))
27 { 27 {
28 this.Subscription = Subscription; 28 this.Subscription = Subscription;
29 this.SpecialSubscription = SpecialSubscription; 29 this.SpecialSubscription = SpecialSubscription;
30 this.DownloadableSubscription = DownloadableSubscription; 30 this.DownloadableSubscription = DownloadableSubscription;
31 } 31 }
32 var FilterStorage = require("filterStorage").FilterStorage; 32 var FilterStorage = require("filterStorage").FilterStorage;
33 var FilterNotifier = require("filterNotifier").FilterNotifier; 33 var FilterNotifier = require("filterNotifier").FilterNotifier;
34 var Prefs = require("prefs").Prefs; 34 var Prefs = require("prefs").Prefs;
35 var Synchronizer = require("synchronizer").Synchronizer; 35 var Synchronizer = require("synchronizer").Synchronizer;
36 var Utils = require("utils").Utils;
36 37
37 // Loads options from localStorage and sets UI elements accordingly 38 // Loads options from localStorage and sets UI elements accordingly
38 function loadOptions() 39 function loadOptions()
39 { 40 {
40 // Set page title to i18n version of "Adblock Plus Options" 41 // Set page title to i18n version of "Adblock Plus Options"
41 document.title = i18n.getMessage("options"); 42 document.title = i18n.getMessage("options");
42 43
43 // Set links 44 // Set links
44 $("#acceptableAdsLink").attr("href", Prefs.subscriptions_exceptionsurl); 45 $("#acceptableAdsLink").attr("href", Prefs.subscriptions_exceptionsurl);
45 $("#acceptableAdsDocs").attr("href", Prefs.documentation_link.replace(/%LINK%/ g, "acceptable_ads").replace(/%LANG%/g, require("utils").Utils.appLocale)); 46 $("#acceptableAdsDocs").attr("href", Utils.getDocLink("acceptable_ads"));
47 setLinks("filter-must-follow-syntax", "https://adblockplus.org/en/filters");
Wladimir Palant 2013/07/16 10:39:27 The link ID indeed exists already - "filterdoc".
48 setLinks("found-a-bug", "https://adblockplus.org/forum/viewforum.php?f=10");
46 49
47 // Add event listeners 50 // Add event listeners
48 window.addEventListener("unload", unloadOptions, false); 51 window.addEventListener("unload", unloadOptions, false);
49 $("#updateFilterLists").click(updateFilterLists); 52 $("#updateFilterLists").click(updateFilterLists);
50 $("#startSubscriptionSelection").click(startSubscriptionSelection); 53 $("#startSubscriptionSelection").click(startSubscriptionSelection);
51 $("#subscriptionSelector").change(updateSubscriptionSelection); 54 $("#subscriptionSelector").change(updateSubscriptionSelection);
52 $("#addSubscription").click(addSubscription); 55 $("#addSubscription").click(addSubscription);
53 $("#acceptableAds").click(allowAcceptableAds); 56 $("#acceptableAds").click(allowAcceptableAds);
54 $("#whitelistForm").submit(addWhitelistDomain); 57 $("#whitelistForm").submit(addWhitelistDomain);
55 $("#removeWhitelist").click(removeSelectedExcludedDomain); 58 $("#removeWhitelist").click(removeSelectedExcludedDomain);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 { 170 {
168 var element = elements[i]; 171 var element = elements[i];
169 var option = new Option(); 172 var option = new Option();
170 option.text = element.getAttribute("title") + " (" + element.getAttribute( "specialization") + ")"; 173 option.text = element.getAttribute("title") + " (" + element.getAttribute( "specialization") + ")";
171 option._data = { 174 option._data = {
172 title: element.getAttribute("title"), 175 title: element.getAttribute("title"),
173 url: element.getAttribute("url"), 176 url: element.getAttribute("url"),
174 homepage: element.getAttribute("homepage") 177 homepage: element.getAttribute("homepage")
175 }; 178 };
176 179
177 var prefix = require("utils").Utils.checkLocalePrefixMatch(element.getAttr ibute("prefixes")); 180 var prefix = Utils.checkLocalePrefixMatch(element.getAttribute("prefixes") );
178 if (prefix) 181 if (prefix)
179 { 182 {
180 option.style.fontWeight = "bold"; 183 option.style.fontWeight = "bold";
181 option.style.backgroundColor = "#E0FFE0"; 184 option.style.backgroundColor = "#E0FFE0";
182 option.style.color = "#000000"; 185 option.style.color = "#000000";
183 if (!selectedPrefix || selectedPrefix.length < prefix.length) 186 if (!selectedPrefix || selectedPrefix.length < prefix.length)
184 { 187 {
185 selectedIndex = i; 188 selectedIndex = i;
186 selectedPrefix = prefix; 189 selectedPrefix = prefix;
187 matchCount = 1; 190 matchCount = 1;
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 if (subscription.disabled == !enabled.checked) 612 if (subscription.disabled == !enabled.checked)
610 return; 613 return;
611 614
612 subscription.disabled = !enabled.checked; 615 subscription.disabled = !enabled.checked;
613 }, false); 616 }, false);
614 617
615 updateSubscriptionInfo(element); 618 updateSubscriptionInfo(element);
616 619
617 document.getElementById("filterLists").appendChild(element); 620 document.getElementById("filterLists").appendChild(element);
618 } 621 }
622
623 function setLinks(id)
624 {
625 var element = document.getElementById(id);
626 if (!element)
627 return;
628
629 var links = element.getElementsByTagName("a");
630 for (var i = 0; i < links.length; i++)
631 {
632 if (typeof arguments[i + 1] == "string")
633 {
634 links[i].href = arguments[i + 1];
635 links[i].setAttribute("target", "_blank");
636 }
637 else if (typeof arguments[i + 1] == "function")
638 {
639 links[i].href = "javascript:void(0);";
640 links[i].addEventListener("click", arguments[i + 1], false);
641 }
642 }
643 }
OLDNEW

Powered by Google App Engine
This is Rietveld