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 Location.pathname Created Oct. 18, 2017, 12:23 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
« no previous file with comments | « devtools-panel.html ('k') | ext/background.js » ('j') | ext/background.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) =>
+{
+ 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({
+ 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);
+});
« no previous file with comments | « devtools-panel.html ('k') | ext/background.js » ('j') | ext/background.js » ('J')

Powered by Google App Engine
This is Rietveld