diff options
-rw-r--r-- | server/src/routes/ui/style/forms.css | 3 | ||||
-rw-r--r-- | server/src/routes/ui/style/mod.rs | 1 | ||||
-rw-r--r-- | server/src/routes/ui/style/playerconf-copy-url.js | 31 |
3 files changed, 34 insertions, 1 deletions
diff --git a/server/src/routes/ui/style/forms.css b/server/src/routes/ui/style/forms.css index bfb0e8a..259d7ef 100644 --- a/server/src/routes/ui/style/forms.css +++ b/server/src/routes/ui/style/forms.css @@ -25,7 +25,8 @@ input[type="password"]:disabled { border: 2px solid grey; } -input[type="submit"] { +input[type="submit"], +form button { padding: 0.5em; margin: 0.5em; justify-self: center; diff --git a/server/src/routes/ui/style/mod.rs b/server/src/routes/ui/style/mod.rs index 9098691..4a6830f 100644 --- a/server/src/routes/ui/style/mod.rs +++ b/server/src/routes/ui/style/mod.rs @@ -45,6 +45,7 @@ fn css_bundle() -> String { fn js_bundle() -> String { concat_files!( // "transition.js", + "playerconf-copy-url.js", "js-player.js" ) } diff --git a/server/src/routes/ui/style/playerconf-copy-url.js b/server/src/routes/ui/style/playerconf-copy-url.js new file mode 100644 index 0000000..0145bd5 --- /dev/null +++ b/server/src/routes/ui/style/playerconf-copy-url.js @@ -0,0 +1,31 @@ + +globalThis.addEventListener("load", () => { + for (const e of document.getElementsByClassName("playerconf")) + patch_playerconf(e) +}) + +function patch_playerconf(form) { + const submit = form.lastChild + + const copyurl = document.createElement("button") + const d = document.createElement("div") + form.removeChild(submit) + d.appendChild(submit) + d.appendChild(copyurl) + form.append(d) + + copyurl.textContent = "Copy Stream URL" + d.style.gridArea = "b" + d.style.width = "100%" + copyurl.style.width = "5em" + + copyurl.addEventListener("click", ev => { + ev.preventDefault() + const fd = new FormData(form) + const sp = ["v", "a", "s"].map(k => fd.get(k)).filter(k => k != "").flat() + const url = `${window.location.protocol}//${window.location.host}/n/${window.location.pathname.split("/")[2]}/stream?tracks=${sp}` + navigator.clipboard.writeText(url) + copyurl.textContent = "Copied" + setTimeout(() => copyurl.textContent = "Copy Stream URL", 1000) + }) +} |