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

Side by Side Diff: desktop-options.js

Issue 29569649: Issue 4580 - Replace ext.i18n with i18n (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Update adblockplusui dependency again Created Oct. 10, 2017, 4:31 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
« no previous file with comments | « dependencies ('k') | ext/common.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 /* global $, i18n, i18nTimeDateStrings */ 18 /* global $, i18nTimeDateStrings */
19 19
20 "use strict"; 20 "use strict";
21 21
22 /** 22 /**
23 * Creates a wrapping function used to conveniently send a type of message. 23 * Creates a wrapping function used to conveniently send a type of message.
24 * 24 *
25 * @param {Object} baseMessage The part of the message that's always sent 25 * @param {Object} baseMessage The part of the message that's always sent
26 * @param {...string} paramKeys Any message keys that have dynamic values. The 26 * @param {...string} paramKeys Any message keys that have dynamic values. The
27 * returned function will take the corresponding 27 * returned function will take the corresponding
28 * values as arguments. 28 * values as arguments.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 "filters_subscription_lastDownload_checksumMismatch"] 84 "filters_subscription_lastDownload_checksumMismatch"]
85 ]); 85 ]);
86 86
87 let delayedSubscriptionSelection = null; 87 let delayedSubscriptionSelection = null;
88 let acceptableAdsUrl; 88 let acceptableAdsUrl;
89 89
90 // Loads options from localStorage and sets UI elements accordingly 90 // Loads options from localStorage and sets UI elements accordingly
91 function loadOptions() 91 function loadOptions()
92 { 92 {
93 // Set page title to i18n version of "Adblock Plus Options" 93 // Set page title to i18n version of "Adblock Plus Options"
94 document.title = i18n.getMessage("options"); 94 document.title = chrome.i18n.getMessage("options");
95 95
96 // Set links 96 // Set links
97 getPref("subscriptions_exceptionsurl", url => 97 getPref("subscriptions_exceptionsurl", url =>
98 { 98 {
99 acceptableAdsUrl = url; 99 acceptableAdsUrl = url;
100 $("#acceptableAdsLink").attr("href", acceptableAdsUrl); 100 $("#acceptableAdsLink").attr("href", acceptableAdsUrl);
101 }); 101 });
102 getDocLink("acceptable_ads", url => 102 getDocLink("acceptable_ads", url =>
103 { 103 {
104 $("#acceptableAdsDocs").attr("href", url); 104 $("#acceptableAdsDocs").attr("href", url);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 { 298 {
299 selectedIndex = i; 299 selectedIndex = i;
300 selectedPrefix = prefix; 300 selectedPrefix = prefix;
301 } 301 }
302 } 302 }
303 } 303 }
304 list.appendChild(option); 304 list.appendChild(option);
305 } 305 }
306 306
307 let option = new Option(); 307 let option = new Option();
308 let label = i18n.getMessage("filters_addSubscriptionOther_label"); 308 let label = chrome.i18n.getMessage("filters_addSubscriptionOther_label");
309 option.text = label + "\u2026"; 309 option.text = label + "\u2026";
310 option._data = null; 310 option._data = null;
311 list.appendChild(option); 311 list.appendChild(option);
312 312
313 list.selectedIndex = selectedIndex; 313 list.selectedIndex = selectedIndex;
314 314
315 if (delayedSubscriptionSelection) 315 if (delayedSubscriptionSelection)
316 startSubscriptionSelection(...delayedSubscriptionSelection); 316 startSubscriptionSelection(...delayedSubscriptionSelection);
317 }); 317 });
318 } 318 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 let list = document.getElementById("subscriptionSelector"); 358 let list = document.getElementById("subscriptionSelector");
359 let data = list.options[list.selectedIndex]._data; 359 let data = list.options[list.selectedIndex]._data;
360 if (data) 360 if (data)
361 addSubscription(data.url, data.title, data.homepage); 361 addSubscription(data.url, data.title, data.homepage);
362 else 362 else
363 { 363 {
364 let url = document.getElementById("customSubscriptionLocation") 364 let url = document.getElementById("customSubscriptionLocation")
365 .value.trim(); 365 .value.trim();
366 if (!/^https?:/i.test(url)) 366 if (!/^https?:/i.test(url))
367 { 367 {
368 alert(i18n.getMessage("global_subscription_invalid_location")); 368 alert(chrome.i18n.getMessage("global_subscription_invalid_location"));
369 $("#customSubscriptionLocation").focus(); 369 $("#customSubscriptionLocation").focus();
370 return; 370 return;
371 } 371 }
372 372
373 let title = document.getElementById("customSubscriptionTitle").value.trim(); 373 let title = document.getElementById("customSubscriptionTitle").value.trim();
374 if (!title) 374 if (!title)
375 title = url; 375 title = url;
376 376
377 addSubscription(url, title, null); 377 addSubscription(url, title, null);
378 } 378 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 414
415 let enabled = element.getElementsByClassName("subscriptionEnabled")[0]; 415 let enabled = element.getElementsByClassName("subscriptionEnabled")[0];
416 enabled.checked = !subscription.disabled; 416 enabled.checked = !subscription.disabled;
417 417
418 let lastUpdate = element.getElementsByClassName("subscriptionUpdate")[0]; 418 let lastUpdate = element.getElementsByClassName("subscriptionUpdate")[0];
419 lastUpdate.classList.remove("error"); 419 lastUpdate.classList.remove("error");
420 420
421 let {downloadStatus} = subscription; 421 let {downloadStatus} = subscription;
422 if (subscription.isDownloading) 422 if (subscription.isDownloading)
423 { 423 {
424 lastUpdate.textContent = i18n.getMessage( 424 lastUpdate.textContent = chrome.i18n.getMessage(
425 "filters_subscription_lastDownload_inProgress" 425 "filters_subscription_lastDownload_inProgress"
426 ); 426 );
427 } 427 }
428 else if (downloadStatus && downloadStatus != "synchronize_ok") 428 else if (downloadStatus && downloadStatus != "synchronize_ok")
429 { 429 {
430 if (statusMessages.has(downloadStatus)) 430 if (statusMessages.has(downloadStatus))
431 { 431 {
432 lastUpdate.textContent = i18n.getMessage( 432 lastUpdate.textContent = chrome.i18n.getMessage(
433 statusMessages.get(downloadStatus) 433 statusMessages.get(downloadStatus)
434 ); 434 );
435 } 435 }
436 else 436 else
437 lastUpdate.textContent = downloadStatus; 437 lastUpdate.textContent = downloadStatus;
438 lastUpdate.classList.add("error"); 438 lastUpdate.classList.add("error");
439 } 439 }
440 else if (subscription.lastDownload > 0) 440 else if (subscription.lastDownload > 0)
441 { 441 {
442 let timeDate = i18nTimeDateStrings(subscription.lastDownload * 1000); 442 let timeDate = i18nTimeDateStrings(subscription.lastDownload * 1000);
443 let messageID = (timeDate[1] ? "last_updated_at" : "last_updated_at_today"); 443 let messageID = (timeDate[1] ? "last_updated_at" : "last_updated_at_today");
444 lastUpdate.textContent = i18n.getMessage(messageID, timeDate); 444 lastUpdate.textContent = chrome.i18n.getMessage(messageID, timeDate);
445 } 445 }
446 } 446 }
447 447
448 function onSubscriptionMessage(action, subscription) 448 function onSubscriptionMessage(action, subscription)
449 { 449 {
450 let element = findSubscriptionElement(subscription); 450 let element = findSubscriptionElement(subscription);
451 451
452 switch (action) 452 switch (action)
453 { 453 {
454 case "disabled": 454 case "disabled":
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 element.removeAttribute("id"); 649 element.removeAttribute("id");
650 element._subscription = subscription; 650 element._subscription = subscription;
651 651
652 let removeButton = element.getElementsByClassName( 652 let removeButton = element.getElementsByClassName(
653 "subscriptionRemoveButton" 653 "subscriptionRemoveButton"
654 )[0]; 654 )[0];
655 removeButton.setAttribute("title", removeButton.textContent); 655 removeButton.setAttribute("title", removeButton.textContent);
656 removeButton.textContent = "\xD7"; 656 removeButton.textContent = "\xD7";
657 removeButton.addEventListener("click", () => 657 removeButton.addEventListener("click", () =>
658 { 658 {
659 if (!confirm(i18n.getMessage("global_remove_subscription_warning"))) 659 if (!confirm(chrome.i18n.getMessage("global_remove_subscription_warning")))
660 return; 660 return;
661 661
662 removeSubscription(subscription.url); 662 removeSubscription(subscription.url);
663 }, false); 663 }, false);
664 664
665 getPref("additional_subscriptions", additionalSubscriptions => 665 getPref("additional_subscriptions", additionalSubscriptions =>
666 { 666 {
667 if (additionalSubscriptions.includes(subscription.url)) 667 if (additionalSubscriptions.includes(subscription.url))
668 removeButton.style.visibility = "hidden"; 668 removeButton.style.visibility = "hidden";
669 }); 669 });
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 onFilterMessage(message.action, message.args[0]); 739 onFilterMessage(message.action, message.args[0]);
740 break; 740 break;
741 case "prefs.respond": 741 case "prefs.respond":
742 onPrefMessage(message.action, message.args[0]); 742 onPrefMessage(message.action, message.args[0]);
743 break; 743 break;
744 case "subscriptions.respond": 744 case "subscriptions.respond":
745 onSubscriptionMessage(message.action, message.args[0]); 745 onSubscriptionMessage(message.action, message.args[0]);
746 break; 746 break;
747 } 747 }
748 }); 748 });
OLDNEW
« no previous file with comments | « dependencies ('k') | ext/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld