LEFT | RIGHT |
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-2017 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, i18n_timeDateStrings */ | 18 /* global $, i18n, 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 function addSubscriptionClicked() | 363 function addSubscriptionClicked() |
364 { | 364 { |
365 let list = document.getElementById("subscriptionSelector"); | 365 let list = document.getElementById("subscriptionSelector"); |
366 let data = list.options[list.selectedIndex]._data; | 366 let data = list.options[list.selectedIndex]._data; |
367 if (data) | 367 if (data) |
368 addSubscription(data.url, data.title, data.homepage); | 368 addSubscription(data.url, data.title, data.homepage); |
369 else | 369 else |
370 { | 370 { |
371 let url = document.getElementById("customSubscriptionLocation") | 371 let url = document.getElementById("customSubscriptionLocation") |
372 .value.trim(); | 372 .value.trim(); |
373 if (!/^https?:/i.test(url)) | 373 if (!/^https?:/i.test(url)) |
374 { | 374 { |
375 alert(i18n.getMessage("global_subscription_invalid_location")); | 375 alert(i18n.getMessage("global_subscription_invalid_location")); |
376 $("#customSubscriptionLocation").focus(); | 376 $("#customSubscriptionLocation").focus(); |
377 return; | 377 return; |
378 } | 378 } |
379 | 379 |
380 let title = document.getElementById("customSubscriptionTitle").value.trim(); | 380 let title = document.getElementById("customSubscriptionTitle").value.trim(); |
381 if (!title) | 381 if (!title) |
382 title = url; | 382 title = url; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 lastUpdate.textContent = i18n.getMessage( | 439 lastUpdate.textContent = i18n.getMessage( |
440 statusMessages.get(downloadStatus) | 440 statusMessages.get(downloadStatus) |
441 ); | 441 ); |
442 } | 442 } |
443 else | 443 else |
444 lastUpdate.textContent = downloadStatus; | 444 lastUpdate.textContent = downloadStatus; |
445 lastUpdate.classList.add("error"); | 445 lastUpdate.classList.add("error"); |
446 } | 446 } |
447 else if (subscription.lastDownload > 0) | 447 else if (subscription.lastDownload > 0) |
448 { | 448 { |
449 let timeDate = i18n_timeDateStrings(subscription.lastDownload * 1000); | 449 let timeDate = i18nTimeDateStrings(subscription.lastDownload * 1000); |
450 let messageID = (timeDate[1] ? "last_updated_at" : "last_updated_at_today"); | 450 let messageID = (timeDate[1] ? "last_updated_at" : "last_updated_at_today"); |
451 lastUpdate.textContent = i18n.getMessage(messageID, timeDate); | 451 lastUpdate.textContent = i18n.getMessage(messageID, timeDate); |
452 } | 452 } |
453 } | 453 } |
454 | 454 |
455 function onSubscriptionMessage(action, subscription) | 455 function onSubscriptionMessage(action, subscription) |
456 { | 456 { |
457 let element = findSubscriptionElement(subscription); | 457 let element = findSubscriptionElement(subscription); |
458 | 458 |
459 switch (action) | 459 switch (action) |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 let rawFilters = document.getElementById("rawFilters"); | 608 let rawFilters = document.getElementById("rawFilters"); |
609 let filters = []; | 609 let filters = []; |
610 | 610 |
611 if (rawFilters.style.display != "table-row") | 611 if (rawFilters.style.display != "table-row") |
612 { | 612 { |
613 rawFilters.style.display = "table-row"; | 613 rawFilters.style.display = "table-row"; |
614 for (let option of document.getElementById("userFiltersBox").options) | 614 for (let option of document.getElementById("userFiltersBox").options) |
615 filters.push(option.value); | 615 filters.push(option.value); |
616 } | 616 } |
617 else | 617 else |
| 618 { |
618 rawFilters.style.display = "none"; | 619 rawFilters.style.display = "none"; |
| 620 } |
619 | 621 |
620 document.getElementById("rawFiltersText").value = filters.join("\n"); | 622 document.getElementById("rawFiltersText").value = filters.join("\n"); |
621 } | 623 } |
622 | 624 |
623 // Imports filters in the raw text box | 625 // Imports filters in the raw text box |
624 function importRawFiltersText() | 626 function importRawFiltersText() |
625 { | 627 { |
626 let text = document.getElementById("rawFiltersText").value; | 628 let text = document.getElementById("rawFiltersText").value; |
627 | 629 |
628 importRawFilters(text, true, errors => | 630 importRawFilters(text, true, errors => |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 onFilterMessage(message.action, message.args[0]); | 739 onFilterMessage(message.action, message.args[0]); |
738 break; | 740 break; |
739 case "prefs.respond": | 741 case "prefs.respond": |
740 onPrefMessage(message.action, message.args[0]); | 742 onPrefMessage(message.action, message.args[0]); |
741 break; | 743 break; |
742 case "subscriptions.respond": | 744 case "subscriptions.respond": |
743 onSubscriptionMessage(message.action, message.args[0]); | 745 onSubscriptionMessage(message.action, message.args[0]); |
744 break; | 746 break; |
745 } | 747 } |
746 }); | 748 }); |
LEFT | RIGHT |