diff options
Diffstat (limited to 'html/display_panel/content/main_panel.js')
-rw-r--r-- | html/display_panel/content/main_panel.js | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/html/display_panel/content/main_panel.js b/html/display_panel/content/main_panel.js index 83c3a6b..b96143b 100644 --- a/html/display_panel/content/main_panel.js +++ b/html/display_panel/content/main_panel.js @@ -59,6 +59,7 @@ document.querySelector("#info").addEventListener("click", e => { setTimeout(close, 100); return; } + if (button.tagName !== "BUTTON") button = button.closest("button"); if (button.matches(".toggle-source")) { let parent = button.parentNode; if (!parent.querySelector(".source").textContent) { @@ -69,10 +70,13 @@ document.querySelector("#info").addEventListener("click", e => { return; } if (!button.matches(".buttons > button")) return; + let domain = button.querySelector(".domain"); + let li = button.closest("li"); let entry = li && li._scriptEntry || [currentReport.url, "Page's site"]; let action = button.className; - let site = button.name === "*"; + let site = domain ? domain.textContent : button.name === "*" ? currentReport.site : ""; + if (site) { ([action] = action.split("-")); } @@ -94,13 +98,14 @@ document.querySelector("#open-options").onclick = e => { close(); } -document.querySelector("#reload").onclick = async e => { +document.body.addEventListener("click", async e => { + if (!e.target.matches(".reload")) return; let {tabId} = currentReport; if (tabId) { await browser.tabs.reload(tabId); myPort.postMessage({"update": true, tabId}); } -}; +}); /* * Takes in the [[file_id, reason],...] array and the group name for one group @@ -169,8 +174,8 @@ function createList(data, group){ */ function refreshUI(report) { currentReport = report; - - document.querySelector("#site").className = report.siteStatus || ""; + let {siteStatus, listedSite} = report; + document.querySelector("#site").className = siteStatus || ""; document.querySelector("#site h2").textContent = `This site ${report.site}`; @@ -194,6 +199,20 @@ function refreshUI(report) { b.disabled = true; } + if (siteStatus && siteStatus !== "unknown") { + let siteContainer = document.querySelector("#site"); + let statusLabel = siteStatus; + if (listedSite && listedSite !== report.site) { + statusLabel += ` via ${listedSite}`; + siteContainer.querySelector(".forget").disabled = true; + } + let status = siteContainer.querySelector(".status"); + status.classList.add(siteStatus); + status.textContent = statusLabel; + } else { + document.querySelector("#site .status").textContent = ""; + } + let noscript = scriptsCount === 0; document.body.classList.toggle("empty", noscript); } |