Support for selectively hiding messages.
This commit is contained in:
parent
626c1ca10f
commit
86fd2414ff
|
@ -30,11 +30,17 @@ addEventListener("unload", e => {
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
||||||
function showMessage(className, message, extraUI = null) {
|
function messageBox(className, message, extraUI = null) {
|
||||||
let el = document.getElementById("message");
|
let el = document.getElementById("message");
|
||||||
el.textContent = message;
|
if (className === "hidden" && el._lastMessage !== message) return;
|
||||||
|
el._lastMessage = el.textContent = message;
|
||||||
el.className = className;
|
el.className = className;
|
||||||
if (extraUI) el.appendChild(extraUI);
|
if (extraUI) {
|
||||||
|
el.appendChild(extraUI);
|
||||||
|
if (typeof extraUI.focus === "function") {
|
||||||
|
extraUI.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -221,7 +227,7 @@ addEventListener("unload", e => {
|
||||||
await browser.tabs.executeScript(tabId, { code: "" });
|
await browser.tabs.executeScript(tabId, { code: "" });
|
||||||
if (isHttp) {
|
if (isHttp) {
|
||||||
document.body.classList.add("disabled");
|
document.body.classList.add("disabled");
|
||||||
showMessage("warning", _("freshInstallReload"));
|
messageBox("warning", _("freshInstallReload"));
|
||||||
let buttons = document.querySelector("#buttons");
|
let buttons = document.querySelector("#buttons");
|
||||||
let b = document.createElement("button");
|
let b = document.createElement("button");
|
||||||
b.textContent = _("OK");
|
b.textContent = _("OK");
|
||||||
|
@ -243,7 +249,7 @@ addEventListener("unload", e => {
|
||||||
await include("/nscl/common/restricted.js");
|
await include("/nscl/common/restricted.js");
|
||||||
let isRestricted = isRestrictedURL(pageTab.url);
|
let isRestricted = isRestrictedURL(pageTab.url);
|
||||||
if (!isHttp || isRestricted) {
|
if (!isHttp || isRestricted) {
|
||||||
showMessage("warning", _("privilegedPage"));
|
messageBox("warning", _("privilegedPage"));
|
||||||
let tempTrust = document.getElementById("temp-trust-page");
|
let tempTrust = document.getElementById("temp-trust-page");
|
||||||
tempTrust.disabled = true;
|
tempTrust.disabled = true;
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue