fix: update settings
This commit is contained in:
+30
-6
@@ -1,19 +1,43 @@
|
||||
const input = document.getElementById("channel-input");
|
||||
const copyBtn = document.getElementById("copy-btn");
|
||||
const openBtn = document.getElementById("open-btn");
|
||||
const linkEl = document.getElementById("game-link");
|
||||
const autoRestartEl = document.getElementById("opt-auto-restart");
|
||||
const singlePlayEl = document.getElementById("opt-single-play");
|
||||
|
||||
function buildUrl() {
|
||||
const name = input.value.trim().toLowerCase() || "Ku6ep_XBOCTuK";
|
||||
const single = singlePlayEl.checked ? "1" : "0";
|
||||
return `${location.origin}${location.pathname.replace(/\/[^/]*$/, "/")}game?channel=${encodeURIComponent(name)}&singlePlay=${single}`;
|
||||
}
|
||||
|
||||
function updateLink() {
|
||||
linkEl.textContent = buildUrl();
|
||||
linkEl.className = "";
|
||||
}
|
||||
|
||||
function copyLink() {
|
||||
const name = input.value.trim().toLowerCase() || "Ku6ep_XBOCTuK";
|
||||
const autoRestart = autoRestartEl.checked ? "1" : "0";
|
||||
const url = `${location.origin}${location.pathname.replace(/\/[^/]*$/, "/")}game.html?channel=${encodeURIComponent(name)}&autoRestart=${autoRestart}`;
|
||||
navigator.clipboard.writeText(url).then(() => {
|
||||
navigator.clipboard.writeText(buildUrl()).then(() => {
|
||||
linkEl.textContent = "СКОПИРОВАНО!";
|
||||
linkEl.className = "copied";
|
||||
setTimeout(updateLink, 1500);
|
||||
});
|
||||
}
|
||||
|
||||
copyBtn.addEventListener("click", copyLink);
|
||||
function openLink() {
|
||||
window.open(buildUrl(), "_blank");
|
||||
}
|
||||
|
||||
input.addEventListener("input", updateLink);
|
||||
singlePlayEl.addEventListener("change", updateLink);
|
||||
input.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Enter") copyLink();
|
||||
});
|
||||
|
||||
copyBtn.addEventListener("click", copyLink);
|
||||
openBtn.addEventListener("click", openLink);
|
||||
|
||||
updateLink();
|
||||
|
||||
document.querySelector(".hint-toggle").addEventListener("click", () => {
|
||||
document.querySelector(".settings-hints").classList.toggle("hidden");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user