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

Side by Side Diff: composer.js

Issue 29371763: Issue 4795 - Use modern JavaScript syntax (Closed)
Patch Set: Created Jan. 13, 2017, 12:11 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
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 targetPageId = null; 18 let targetPageId = null;
19 19
20 function onKeyDown(event) 20 function onKeyDown(event)
21 { 21 {
22 if (event.keyCode == 27) 22 if (event.keyCode == 27)
23 { 23 {
24 event.preventDefault(); 24 event.preventDefault();
25 closeDialog(); 25 closeDialog();
26 } 26 }
27 else if (event.keyCode == 13 && !event.shiftKey && !event.ctrlKey) 27 else if (event.keyCode == 13 && !event.shiftKey && !event.ctrlKey)
28 { 28 {
29 event.preventDefault(); 29 event.preventDefault();
30 addFilters(); 30 addFilters();
31 } 31 }
32 } 32 }
33 33
34 function addFilters() 34 function addFilters()
35 { 35 {
36 ext.backgroundPage.sendMessage( 36 ext.backgroundPage.sendMessage(
37 { 37 {
38 type: "filters.importRaw", 38 type: "filters.importRaw",
39 text: document.getElementById("filters").value 39 text: document.getElementById("filters").value
40 }, 40 },
41 function(errors) 41 errors =>
42 { 42 {
43 if (errors.length > 0) 43 if (errors.length > 0)
44 alert(errors.join("\n")); 44 alert(errors.join("\n"));
45 else 45 else
46 closeDialog(true); 46 closeDialog(true);
47 }); 47 });
48 } 48 }
49 49
50 function closeDialog(success) 50 function closeDialog(success)
51 { 51 {
(...skipping 18 matching lines...) Expand all
70 document.getElementById("addButton").addEventListener("click", addFilters); 70 document.getElementById("addButton").addEventListener("click", addFilters);
71 document.getElementById("cancelButton").addEventListener( 71 document.getElementById("cancelButton").addEventListener(
72 "click", closeDialog.bind(null, false) 72 "click", closeDialog.bind(null, false)
73 ); 73 );
74 74
75 // Apply jQuery UI styles 75 // Apply jQuery UI styles
76 $("button").button(); 76 $("button").button();
77 77
78 document.getElementById("filters").focus(); 78 document.getElementById("filters").focus();
79 79
80 ext.onMessage.addListener(function(msg, sender, sendResponse) 80 ext.onMessage.addListener((msg, sender, sendResponse) =>
81 { 81 {
82 switch (msg.type) 82 switch (msg.type)
83 { 83 {
84 case "composer.dialog.init": 84 case "composer.dialog.init":
85 targetPageId = msg.sender; 85 targetPageId = msg.sender;
86 document.getElementById("filters").value = msg.filters.join("\n"); 86 document.getElementById("filters").value = msg.filters.join("\n");
87 break; 87 break;
88 case "composer.dialog.close": 88 case "composer.dialog.close":
89 window.close(); 89 window.close();
90 break; 90 break;
91 } 91 }
92 }); 92 });
93 93
94 window.removeEventListener("load", init); 94 window.removeEventListener("load", init);
95 } 95 }
96 window.addEventListener("load", init, false); 96 window.addEventListener("load", init, false);
OLDNEW
« chrome/ext/common.js ('K') | « chrome/ext/popup.js ('k') | composer.postload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld