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

Side by Side Diff: devtools-panel.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Fix ESLint errors Created Oct. 11, 2017, 11:47 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-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
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 button.textContent = label; 65 button.textContent = label;
66 button.classList.add("action"); 66 button.classList.add("action");
67 67
68 button.addEventListener("click", () => 68 button.addEventListener("click", () =>
69 { 69 {
70 chrome.runtime.sendMessage({ 70 chrome.runtime.sendMessage({
71 type: "filters." + action, 71 type: "filters." + action,
72 text: filter 72 text: filter
73 }); 73 });
74 }, false); 74 });
75 75
76 return button; 76 return button;
77 } 77 }
78 78
79 function createRecord(request, filter, template) 79 function createRecord(request, filter, template)
80 { 80 {
81 let row = document.importNode(template, true); 81 let row = document.importNode(template, true);
82 row.dataset.type = request.type; 82 row.dataset.type = request.type;
83 83
84 row.querySelector(".domain").textContent = request.docDomain; 84 row.querySelector(".domain").textContent = request.docDomain;
85 row.querySelector(".type").textContent = request.type; 85 row.querySelector(".type").textContent = request.type;
86 86
87 let urlElement = row.querySelector(".url"); 87 let urlElement = row.querySelector(".url");
88 let actionWrapper = row.querySelector(".action-wrapper"); 88 let actionWrapper = row.querySelector(".action-wrapper");
89 89
90 if (request.url) 90 if (request.url)
91 { 91 {
92 urlElement.textContent = request.url; 92 urlElement.textContent = request.url;
93 93
94 if (request.type != "POPUP") 94 if (request.type != "POPUP")
95 { 95 {
96 urlElement.classList.add("resourceLink"); 96 urlElement.classList.add("resourceLink");
97 urlElement.addEventListener("click", () => 97 urlElement.addEventListener("click", () =>
98 { 98 {
99 ext.devtools.panels.openResource(request.url); 99 chrome.devtools.panels.openResource(request.url);
100 }, false); 100 });
101 } 101 }
102 } 102 }
103 103
104 if (filter) 104 if (filter)
105 { 105 {
106 let filterElement = row.querySelector(".filter"); 106 let filterElement = row.querySelector(".filter");
107 let originElement = row.querySelector(".origin"); 107 let originElement = row.querySelector(".origin");
108 108
109 filterElement.textContent = filter.text; 109 filterElement.textContent = filter.text;
110 row.dataset.state = filter.whitelisted ? "whitelisted" : "blocked"; 110 row.dataset.state = filter.whitelisted ? "whitelisted" : "blocked";
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 187
188 document.addEventListener("DOMContentLoaded", () => 188 document.addEventListener("DOMContentLoaded", () =>
189 { 189 {
190 let container = document.getElementById("items"); 190 let container = document.getElementById("items");
191 let table = container.querySelector("tbody"); 191 let table = container.querySelector("tbody");
192 let template = document.querySelector("template").content.firstElementChild; 192 let template = document.querySelector("template").content.firstElementChild;
193 193
194 document.getElementById("reload").addEventListener("click", () => 194 document.getElementById("reload").addEventListener("click", () =>
195 { 195 {
196 ext.devtools.inspectedWindow.reload(); 196 chrome.devtools.inspectedWindow.reload();
197 }, false); 197 });
198 198
199 document.getElementById("filter-state").addEventListener("change", (event) => 199 document.getElementById("filter-state").addEventListener("change", (event) =>
200 { 200 {
201 container.dataset.filterState = event.target.value; 201 container.dataset.filterState = event.target.value;
202 }, false); 202 });
203 203
204 document.getElementById("filter-type").addEventListener("change", (event) => 204 document.getElementById("filter-type").addEventListener("change", (event) =>
205 { 205 {
206 container.dataset.filterType = event.target.value; 206 container.dataset.filterType = event.target.value;
207 }, false); 207 });
208 208
209 ext.onMessage.addListener((message) => 209 ext.onMessage.addListener((message) =>
210 { 210 {
211 switch (message.type) 211 switch (message.type)
212 { 212 {
213 case "add-record": 213 case "add-record":
214 table.appendChild(createRecord(message.request, message.filter, 214 table.appendChild(createRecord(message.request, message.filter,
215 template)); 215 template));
216 break; 216 break;
217 217
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 lastFilterQuery = null; 249 lastFilterQuery = null;
250 break; 250 break;
251 } 251 }
252 }); 252 });
253 253
254 // Since Chrome 54 the themeName is accessible, for earlier versions we must 254 // Since Chrome 54 the themeName is accessible, for earlier versions we must
255 // assume the default theme is being used. 255 // assume the default theme is being used.
256 // https://bugs.chromium.org/p/chromium/issues/detail?id=608869 256 // https://bugs.chromium.org/p/chromium/issues/detail?id=608869
257 let theme = chrome.devtools.panels.themeName || "default"; 257 let theme = chrome.devtools.panels.themeName || "default";
258 document.body.classList.add(theme); 258 document.body.classList.add(theme);
259 }, false); 259 });
OLDNEW

Powered by Google App Engine
This is Rietveld