Add copy MusicBrainz ID button

This commit is contained in:
Claudio Ortolina
2024-11-01 10:32:00 +00:00
parent c0f039f2ee
commit 9daaaadb46
4 changed files with 53 additions and 11 deletions
+8
View File
@@ -32,6 +32,14 @@ let liveSocket = new LiveSocket("/live", Socket, {
topbar.config({barColors: {0: "#FD4F00"}, shadowColor: "rgba(0, 0, 0, .3)"})
window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
window.addEventListener("phx:page-loading-stop", _info => topbar.hide())
window.addEventListener("music_library:clipcopy", (event) => {
if ("clipboard" in navigator) {
const text = event.target.textContent;
navigator.clipboard.writeText(text);
} else {
alert("Sorry, your browser does not support clipboard copy.");
}
});
// connect if there are any LiveViews on the page
liveSocket.connect()