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: Undo accidental whitespace change Created Jan. 16, 2017, 2:57 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 "use strict";
19
20 let targetPageId = null;
19 21
20 function onKeyDown(event) 22 function onKeyDown(event)
21 { 23 {
22 if (event.keyCode == 27) 24 if (event.keyCode == 27)
23 { 25 {
24 event.preventDefault(); 26 event.preventDefault();
25 closeDialog(); 27 closeDialog();
26 } 28 }
27 else if (event.keyCode == 13 && !event.shiftKey && !event.ctrlKey) 29 else if (event.keyCode == 13 && !event.shiftKey && !event.ctrlKey)
28 { 30 {
29 event.preventDefault(); 31 event.preventDefault();
30 addFilters(); 32 addFilters();
31 } 33 }
32 } 34 }
33 35
34 function addFilters() 36 function addFilters()
35 { 37 {
36 ext.backgroundPage.sendMessage( 38 ext.backgroundPage.sendMessage(
37 { 39 {
38 type: "filters.importRaw", 40 type: "filters.importRaw",
39 text: document.getElementById("filters").value 41 text: document.getElementById("filters").value
40 }, 42 },
41 function(errors) 43 errors =>
42 { 44 {
43 if (errors.length > 0) 45 if (errors.length > 0)
44 alert(errors.join("\n")); 46 alert(errors.join("\n"));
45 else 47 else
46 closeDialog(true); 48 closeDialog(true);
47 }); 49 });
48 } 50 }
49 51
50 function closeDialog(success) 52 function closeDialog(success)
51 { 53 {
(...skipping 18 matching lines...) Expand all
70 document.getElementById("addButton").addEventListener("click", addFilters); 72 document.getElementById("addButton").addEventListener("click", addFilters);
71 document.getElementById("cancelButton").addEventListener( 73 document.getElementById("cancelButton").addEventListener(
72 "click", closeDialog.bind(null, false) 74 "click", closeDialog.bind(null, false)
73 ); 75 );
74 76
75 // Apply jQuery UI styles 77 // Apply jQuery UI styles
76 $("button").button(); 78 $("button").button();
77 79
78 document.getElementById("filters").focus(); 80 document.getElementById("filters").focus();
79 81
80 ext.onMessage.addListener(function(msg, sender, sendResponse) 82 ext.onMessage.addListener((msg, sender, sendResponse) =>
81 { 83 {
82 switch (msg.type) 84 switch (msg.type)
83 { 85 {
84 case "composer.dialog.init": 86 case "composer.dialog.init":
85 targetPageId = msg.sender; 87 targetPageId = msg.sender;
86 document.getElementById("filters").value = msg.filters.join("\n"); 88 document.getElementById("filters").value = msg.filters.join("\n");
87 break; 89 break;
88 case "composer.dialog.close": 90 case "composer.dialog.close":
89 window.close(); 91 window.close();
90 break; 92 break;
91 } 93 }
92 }); 94 });
93 95
94 window.removeEventListener("load", init); 96 window.removeEventListener("load", init);
95 } 97 }
96 window.addEventListener("load", init, false); 98 window.addEventListener("load", init, false);
OLDNEW

Powered by Google App Engine
This is Rietveld