diff --git a/index.html b/index.html index d7aa12c..aab4269 100644 --- a/index.html +++ b/index.html @@ -1,3 +1,4 @@ + @@ -627,7 +628,7 @@ }); // Update command display if a version is selected const activeBtn = document.querySelector("#version-buttons button.active"); - if (activeBtn) updateCommand(activeBtn.dataset.version); + activeBtn ? updateCommand(activeBtn.dataset.version) : updateCommand(); } // GitHub proxy toggle event listener @@ -763,9 +764,10 @@ function updateCommand(version) { const tool = document.querySelector('input[name="tool"]:checked').value; const proxy = localStorage.getItem("gh-proxy-enabled") === "true" ? " | sed 's#https://github.com#https://gh-proxy.com/https://github.com#g'" : ""; + const _version = version===undefined?"": `VERSION=${version} ` const cmd = tool === "curl" - ? `
VERSION=${version} bash \<(curl https://mikrotik.ltd/chr.sh${proxy})
` - : `
VERSION=${version} bash \<(wget -O - https://mikrotik.ltd/chr.sh${proxy})
`; + ? `
${_version}bash \<(curl https://mikrotik.ltd/chr.sh${proxy})
` + : `
${_version}bash \<(wget -O - https://mikrotik.ltd/chr.sh${proxy})
`; commandDiv.innerHTML = cmd; } @@ -773,7 +775,7 @@ document.querySelectorAll('input[name="tool"]').forEach(radio => { radio.addEventListener("change", () => { const activeBtn = document.querySelector("#version-buttons button.active"); - if (activeBtn) updateCommand(activeBtn.dataset.version); + activeBtn ? updateCommand(activeBtn.dataset.version) : updateCommand(); }); }); @@ -782,12 +784,18 @@ buttons.forEach(btn => { btn.addEventListener("click", (e) => { e.preventDefault(); - updateCommand(btn.dataset.version); - buttons.forEach(b => b.classList.remove("active")); - btn.classList.add("active"); + if (btn.classList.contains("active")) { + updateCommand(); + btn.classList.remove("active"); + }else{ + updateCommand(btn.dataset.version); + buttons.forEach(b => b.classList.remove("active")); + btn.classList.add("active"); + } + }); }); - buttons[0].click(); // Select first button by default + updateCommand(); // Copy command to clipboard functionality copyBtn.addEventListener("click", () => {