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

Delta Between Two Patch Sets: devtools-panel.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Left Patch Set: Use Location.pathname Created Oct. 18, 2017, 12:23 a.m.
Right Patch Set: Rebase Created Oct. 18, 2017, 1: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 | « devtools-panel.html ('k') | ext/background.js » ('j') | polyfill.js » ('J')
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-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
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 "use strict"; 18 "use strict";
19 19
20 let lastFilterQuery = null; 20 let lastFilterQuery = null;
21 21
22 chrome.runtime.sendMessage({type: "types.get"}, (filterTypes) => 22 browser.runtime.sendMessage({type: "types.get"}, (filterTypes) =>
23 { 23 {
24 let filterTypesElem = document.getElementById("filter-type"); 24 let filterTypesElem = document.getElementById("filter-type");
25 let filterStyleElem = document.createElement("style"); 25 let filterStyleElem = document.createElement("style");
26 for (let type of filterTypes) 26 for (let type of filterTypes)
27 { 27 {
28 filterStyleElem.innerHTML += 28 filterStyleElem.innerHTML +=
29 `#items[data-filter-type=${type}] tr:not([data-type=${type}])` + 29 `#items[data-filter-type=${type}] tr:not([data-type=${type}])` +
30 "{display: none;}"; 30 "{display: none;}";
31 let optionNode = document.createElement("option"); 31 let optionNode = document.createElement("option");
32 optionNode.appendChild(document.createTextNode(type)); 32 optionNode.appendChild(document.createTextNode(type));
(...skipping 26 matching lines...) Expand all
59 59
60 function createActionButton(action, label, filter) 60 function createActionButton(action, label, filter)
61 { 61 {
62 let button = document.createElement("span"); 62 let button = document.createElement("span");
63 63
64 button.textContent = label; 64 button.textContent = label;
65 button.classList.add("action"); 65 button.classList.add("action");
66 66
67 button.addEventListener("click", () => 67 button.addEventListener("click", () =>
68 { 68 {
69 chrome.runtime.sendMessage({ 69 browser.runtime.sendMessage({
70 type: "filters." + action, 70 type: "filters." + action,
71 text: filter 71 text: filter
72 }); 72 });
73 }); 73 });
74 74
75 return button; 75 return button;
76 } 76 }
77 77
78 function createRecord(request, filter, template) 78 function createRecord(request, filter, template)
79 { 79 {
80 let row = document.importNode(template, true); 80 let row = document.importNode(template, true);
81 row.dataset.type = request.type; 81 row.dataset.type = request.type;
82 82
83 row.querySelector(".domain").textContent = request.docDomain; 83 row.querySelector(".domain").textContent = request.docDomain;
84 row.querySelector(".type").textContent = request.type; 84 row.querySelector(".type").textContent = request.type;
85 85
86 let urlElement = row.querySelector(".url"); 86 let urlElement = row.querySelector(".url");
87 let actionWrapper = row.querySelector(".action-wrapper"); 87 let actionWrapper = row.querySelector(".action-wrapper");
88 88
89 if (request.url) 89 if (request.url)
90 { 90 {
91 urlElement.textContent = request.url; 91 urlElement.textContent = request.url;
92 92
93 if (request.type != "POPUP") 93 if (request.type != "POPUP")
94 { 94 {
95 urlElement.classList.add("resourceLink"); 95 urlElement.classList.add("resourceLink");
96 urlElement.addEventListener("click", () => 96 urlElement.addEventListener("click", () =>
97 { 97 {
98 chrome.devtools.panels.openResource(request.url); 98 browser.devtools.panels.openResource(request.url);
99 }); 99 });
100 } 100 }
101 } 101 }
102 102
103 if (filter) 103 if (filter)
104 { 104 {
105 let filterElement = row.querySelector(".filter"); 105 let filterElement = row.querySelector(".filter");
106 let originElement = row.querySelector(".origin"); 106 let originElement = row.querySelector(".origin");
107 107
108 filterElement.textContent = filter.text; 108 filterElement.textContent = filter.text;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 185 }
186 186
187 document.addEventListener("DOMContentLoaded", () => 187 document.addEventListener("DOMContentLoaded", () =>
188 { 188 {
189 let container = document.getElementById("items"); 189 let container = document.getElementById("items");
190 let table = container.querySelector("tbody"); 190 let table = container.querySelector("tbody");
191 let template = document.querySelector("template").content.firstElementChild; 191 let template = document.querySelector("template").content.firstElementChild;
192 192
193 document.getElementById("reload").addEventListener("click", () => 193 document.getElementById("reload").addEventListener("click", () =>
194 { 194 {
195 chrome.devtools.inspectedWindow.reload(); 195 browser.devtools.inspectedWindow.reload();
196 }); 196 });
197 197
198 document.getElementById("filter-state").addEventListener("change", (event) => 198 document.getElementById("filter-state").addEventListener("change", (event) =>
199 { 199 {
200 container.dataset.filterState = event.target.value; 200 container.dataset.filterState = event.target.value;
201 }); 201 });
202 202
203 document.getElementById("filter-type").addEventListener("change", (event) => 203 document.getElementById("filter-type").addEventListener("change", (event) =>
204 { 204 {
205 container.dataset.filterType = event.target.value; 205 container.dataset.filterType = event.target.value;
206 }); 206 });
207 207
208 let port = chrome.runtime.connect({ 208 let port = browser.runtime.connect({
209 name: "devtools-" + chrome.devtools.inspectedWindow.tabId 209 name: "devtools-" + browser.devtools.inspectedWindow.tabId
210 }); 210 });
211 211
212 port.onMessage.addListener((message) => 212 port.onMessage.addListener((message) =>
213 { 213 {
214 switch (message.type) 214 switch (message.type)
215 { 215 {
216 case "add-record": 216 case "add-record":
217 table.appendChild(createRecord(message.request, message.filter, 217 table.appendChild(createRecord(message.request, message.filter,
218 template)); 218 template));
219 break; 219 break;
(...skipping 30 matching lines...) Expand all
250 case "cancelSearch": 250 case "cancelSearch":
251 cancelSearch(table); 251 cancelSearch(table);
252 lastFilterQuery = null; 252 lastFilterQuery = null;
253 break; 253 break;
254 } 254 }
255 }); 255 });
256 256
257 // Since Chrome 54 the themeName is accessible, for earlier versions we must 257 // Since Chrome 54 the themeName is accessible, for earlier versions we must
258 // assume the default theme is being used. 258 // assume the default theme is being used.
259 // https://bugs.chromium.org/p/chromium/issues/detail?id=608869 259 // https://bugs.chromium.org/p/chromium/issues/detail?id=608869
260 let theme = chrome.devtools.panels.themeName || "default"; 260 let theme = browser.devtools.panels.themeName || "default";
261 document.body.classList.add(theme); 261 document.body.classList.add(theme);
262 }); 262 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld