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

Unified Diff: devtools-panel.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Use runtime.onConnect Created Oct. 12, 2017, 1:22 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: devtools-panel.js
===================================================================
--- a/devtools-panel.js
+++ b/devtools-panel.js
@@ -14,32 +14,31 @@
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
let lastFilterQuery = null;
-chrome.runtime.sendMessage({type: "types.get"},
- (filterTypes) =>
+chrome.runtime.sendMessage({type: "types.get"}, (filterTypes) =>
+{
Manish Jethani 2017/10/12 01:30:02 Just indentation.
+ let filterTypesElem = document.getElementById("filter-type");
+ let filterStyleElem = document.createElement("style");
+ for (let type of filterTypes)
{
- let filterTypesElem = document.getElementById("filter-type");
- let filterStyleElem = document.createElement("style");
- for (let type of filterTypes)
- {
- filterStyleElem.innerHTML +=
- `#items[data-filter-type=${type}] tr:not([data-type=${type}])` +
- "{display: none;}";
- let optionNode = document.createElement("option");
- optionNode.appendChild(document.createTextNode(type));
- filterTypesElem.appendChild(optionNode);
- }
- document.body.appendChild(filterStyleElem);
- });
+ filterStyleElem.innerHTML +=
+ `#items[data-filter-type=${type}] tr:not([data-type=${type}])` +
+ "{display: none;}";
+ let optionNode = document.createElement("option");
+ optionNode.appendChild(document.createTextNode(type));
+ filterTypesElem.appendChild(optionNode);
+ }
+ document.body.appendChild(filterStyleElem);
+});
function generateFilter(request, domainSpecific)
{
let filter = request.url.replace(/^[\w-]+:\/+(?:www\.)?/, "||");
let options = [];
if (request.type == "POPUP")
{
@@ -66,17 +65,17 @@
button.classList.add("action");
button.addEventListener("click", () =>
{
chrome.runtime.sendMessage({
type: "filters." + action,
text: filter
});
- }, false);
+ });
return button;
}
function createRecord(request, filter, template)
{
let row = document.importNode(template, true);
row.dataset.type = request.type;
@@ -91,18 +90,18 @@
{
urlElement.textContent = request.url;
if (request.type != "POPUP")
{
urlElement.classList.add("resourceLink");
urlElement.addEventListener("click", () =>
{
- ext.devtools.panels.openResource(request.url);
- }, false);
+ chrome.devtools.panels.openResource(request.url);
+ });
}
}
if (filter)
{
let filterElement = row.querySelector(".filter");
let originElement = row.querySelector(".origin");
@@ -188,30 +187,34 @@
document.addEventListener("DOMContentLoaded", () =>
{
let container = document.getElementById("items");
let table = container.querySelector("tbody");
let template = document.querySelector("template").content.firstElementChild;
document.getElementById("reload").addEventListener("click", () =>
{
- ext.devtools.inspectedWindow.reload();
- }, false);
+ chrome.devtools.inspectedWindow.reload();
+ });
document.getElementById("filter-state").addEventListener("change", (event) =>
{
container.dataset.filterState = event.target.value;
- }, false);
+ });
document.getElementById("filter-type").addEventListener("change", (event) =>
{
container.dataset.filterType = event.target.value;
- }, false);
+ });
- ext.onMessage.addListener((message) =>
+ let port = chrome.runtime.connect({
Manish Jethani 2017/10/12 01:30:03 This was previously done in ext/devtools.js in adb
+ name: "devtools-" + chrome.devtools.inspectedWindow.tabId
+ });
+
+ port.onMessage.addListener((message) =>
{
switch (message.type)
{
case "add-record":
table.appendChild(createRecord(message.request, message.filter,
template));
break;
@@ -251,9 +254,9 @@
}
});
// Since Chrome 54 the themeName is accessible, for earlier versions we must
// assume the default theme is being used.
// https://bugs.chromium.org/p/chromium/issues/detail?id=608869
let theme = chrome.devtools.panels.themeName || "default";
document.body.classList.add(theme);
-}, false);
+});

Powered by Google App Engine
This is Rietveld