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

Delta Between Two Patch Sets: options.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Left Patch Set: Created Feb. 7, 2017, 4:49 p.m.
Right Patch Set: Use .includes again Created March 31, 2017, 8:37 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « notification.js ('k') | popup.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 updateSubscriptionSelection(); 346 updateSubscriptionSelection();
347 document.getElementById("addSubscriptionContainer").scrollIntoView(true); 347 document.getElementById("addSubscriptionContainer").scrollIntoView(true);
348 } 348 }
349 349
350 function updateSubscriptionSelection() 350 function updateSubscriptionSelection()
351 { 351 {
352 let list = document.getElementById("subscriptionSelector"); 352 let list = document.getElementById("subscriptionSelector");
353 let data = list.options[list.selectedIndex]._data; 353 let data = list.options[list.selectedIndex]._data;
354 if (data) 354 if (data)
355 {
356 $("#customSubscriptionContainer").hide(); 355 $("#customSubscriptionContainer").hide();
357 }
358 else 356 else
359 { 357 {
360 $("#customSubscriptionContainer").show(); 358 $("#customSubscriptionContainer").show();
361 $("#customSubscriptionTitle").focus(); 359 $("#customSubscriptionTitle").focus();
362 } 360 }
363 } 361 }
364 362
365 function addSubscriptionClicked() 363 function addSubscriptionClicked()
366 { 364 {
367 let list = document.getElementById("subscriptionSelector"); 365 let list = document.getElementById("subscriptionSelector");
368 let data = list.options[list.selectedIndex]._data; 366 let data = list.options[list.selectedIndex]._data;
369 if (data) 367 if (data)
370 {
371 addSubscription(data.url, data.title, data.homepage); 368 addSubscription(data.url, data.title, data.homepage);
372 }
373 else 369 else
374 { 370 {
375 let url = document.getElementById("customSubscriptionLocation") 371 let url = document.getElementById("customSubscriptionLocation")
376 .value.trim(); 372 .value.trim();
377 if (!/^https?:/i.test(url)) 373 if (!/^https?:/i.test(url))
378 { 374 {
379 alert(i18n.getMessage("global_subscription_invalid_location")); 375 alert(i18n.getMessage("global_subscription_invalid_location"));
380 $("#customSubscriptionLocation").focus(); 376 $("#customSubscriptionLocation").focus();
381 return; 377 return;
382 } 378 }
383 379
384 let title = document.getElementById("customSubscriptionTitle").value.trim(); 380 let title = document.getElementById("customSubscriptionTitle").value.trim();
385 if (!title) 381 if (!title)
386 title = url; 382 title = url;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 } 434 }
439 else if (downloadStatus && downloadStatus != "synchronize_ok") 435 else if (downloadStatus && downloadStatus != "synchronize_ok")
440 { 436 {
441 if (statusMessages.has(downloadStatus)) 437 if (statusMessages.has(downloadStatus))
442 { 438 {
443 lastUpdate.textContent = i18n.getMessage( 439 lastUpdate.textContent = i18n.getMessage(
444 statusMessages.get(downloadStatus) 440 statusMessages.get(downloadStatus)
445 ); 441 );
446 } 442 }
447 else 443 else
448 {
449 lastUpdate.textContent = downloadStatus; 444 lastUpdate.textContent = downloadStatus;
450 }
451 lastUpdate.classList.add("error"); 445 lastUpdate.classList.add("error");
452 } 446 }
453 else if (subscription.lastDownload > 0) 447 else if (subscription.lastDownload > 0)
454 { 448 {
455 let timeDate = i18n_timeDateStrings(subscription.lastDownload * 1000); 449 let timeDate = i18nTimeDateStrings(subscription.lastDownload * 1000);
456 let messageID = (timeDate[1] ? "last_updated_at" : "last_updated_at_today"); 450 let messageID = (timeDate[1] ? "last_updated_at" : "last_updated_at_today");
457 lastUpdate.textContent = i18n.getMessage(messageID, timeDate); 451 lastUpdate.textContent = i18n.getMessage(messageID, timeDate);
458 } 452 }
459 } 453 }
460 454
461 function onSubscriptionMessage(action, subscription) 455 function onSubscriptionMessage(action, subscription)
462 { 456 {
463 let element = findSubscriptionElement(subscription); 457 let element = findSubscriptionElement(subscription);
464 458
465 switch (action) 459 switch (action)
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 onFilterMessage(message.action, message.args[0]); 739 onFilterMessage(message.action, message.args[0]);
746 break; 740 break;
747 case "prefs.respond": 741 case "prefs.respond":
748 onPrefMessage(message.action, message.args[0]); 742 onPrefMessage(message.action, message.args[0]);
749 break; 743 break;
750 case "subscriptions.respond": 744 case "subscriptions.respond":
751 onSubscriptionMessage(message.action, message.args[0]); 745 onSubscriptionMessage(message.action, message.args[0]);
752 break; 746 break;
753 } 747 }
754 }); 748 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld