aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-09-06 20:40:03 +0200
committermetamuffin <metamuffin@disroot.org>2023-09-06 20:40:03 +0200
commite5c627592ddbb464787d0e1c61e5091815d7679a (patch)
tree367809258bc5bd6aba3f5441be3e2a04b9a2b4c0
parent2b3271ead145fa7a6ed880caf93f52af822ede8c (diff)
downloadjellything-e5c627592ddbb464787d0e1c61e5091815d7679a.tar
jellything-e5c627592ddbb464787d0e1c61e5091815d7679a.tar.bz2
jellything-e5c627592ddbb464787d0e1c61e5091815d7679a.tar.zst
copy url in playerconf
-rw-r--r--server/src/routes/ui/style/forms.css3
-rw-r--r--server/src/routes/ui/style/mod.rs1
-rw-r--r--server/src/routes/ui/style/playerconf-copy-url.js31
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)
+ })
+}