js fixes courtesy drzed
This commit is contained in:
@ -1,40 +1,51 @@
|
||||
var expandConfig = null;
|
||||
var collapseConfig = null;
|
||||
var config = null;
|
||||
let config;
|
||||
let debug = false;
|
||||
|
||||
function initToggleConfig()
|
||||
{
|
||||
expandConfig = document.getElementById("expandConfig");
|
||||
collapseConfig = document.getElementById("collapseConfig");
|
||||
config = document.getElementById("configuration");
|
||||
function initToggleConfig() {
|
||||
const configurationElement = document.getElementById("configuration");
|
||||
if (configurationElement) {
|
||||
config = configurationElement;
|
||||
hideConfig();
|
||||
} else if (debug) {
|
||||
console.error("Configuration element not found.");
|
||||
}
|
||||
}
|
||||
|
||||
function hideConfig() {
|
||||
if (!collapseConfig)
|
||||
if (config) {
|
||||
config.style.display = "none";
|
||||
} else if (debug && !document.querySelector("#expandConfig")) {
|
||||
console.error("ExpandConfig link element not found.");
|
||||
}
|
||||
}
|
||||
|
||||
function showConfig() {
|
||||
if (collapseConfig)
|
||||
if (document.querySelector("#collapseConfig")) {
|
||||
config.style.display = "block";
|
||||
} else if (debug) {
|
||||
console.error("CollapseConfig link element not found.");
|
||||
}
|
||||
}
|
||||
|
||||
function clean() {
|
||||
if (expandConfig) {
|
||||
expandConfig.remove();
|
||||
const expandConfigElement = document.getElementById("expandConfig");
|
||||
const collapseConfigElement = document.getElementById("collapseConfig");
|
||||
|
||||
if (expandConfigElement) {
|
||||
expandConfigElement.remove();
|
||||
}
|
||||
if (collapseConfig) {
|
||||
collapseConfig.remove();
|
||||
|
||||
if (collapseConfigElement) {
|
||||
collapseConfigElement.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function expand() {
|
||||
clean();
|
||||
var x = document.createElement("link");
|
||||
x.type="text/css";
|
||||
x.rel="stylesheet";
|
||||
x.href="/outproxy/resources/expand.css";
|
||||
const x = document.createElement("link");
|
||||
x.type = "text/css";
|
||||
x.rel = "stylesheet";
|
||||
x.href = "/outproxy/resources/expand.css";
|
||||
x.setAttribute("id", "expandConfig");
|
||||
document.head.appendChild(x);
|
||||
showConfig();
|
||||
@ -42,19 +53,22 @@ function expand() {
|
||||
|
||||
function collapse() {
|
||||
clean();
|
||||
var c = document.createElement("link");
|
||||
c.type="text/css";
|
||||
c.rel="stylesheet";
|
||||
c.href="/outproxy/resources/collapse.css";
|
||||
const c = document.createElement("link");
|
||||
c.type = "text/css";
|
||||
c.rel = "stylesheet";
|
||||
c.href = "/outproxy/resources/collapse.css";
|
||||
c.setAttribute("id", "collapseConfig");
|
||||
document.head.appendChild(c);
|
||||
hideConfig();
|
||||
}
|
||||
|
||||
function copyText() {
|
||||
document.execCommand("copy");
|
||||
navigator.clipboard.writeText("Some text to copy").then(
|
||||
() => console.log('Copy successful'),
|
||||
err => console.error('Copy failed: ', err)
|
||||
);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
initToggleConfig();
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
initToggleConfig();
|
||||
}, true);
|
||||
|
Reference in New Issue
Block a user