home to your local SPACEGIRL 💫 arimelody.space
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fixed event order issues with swapping

Signed-off-by: ari melody <ari@arimelody.me>

+22 -8
+8 -1
public/script/music-gateway.js
··· 51 51 52 52 function bind_share_btn() { 53 53 const share_btn = document.getElementById("share"); 54 - share_btn.onclick = (e) => { 54 + if (navigator.clipboard === undefined) { 55 + share_btn.onclick = event => { 56 + console.error("clipboard is not supported by this browser!"); 57 + }; 58 + return; 59 + } 60 + share_btn.onclick = event => { 61 + event.preventDefault(); 55 62 navigator.clipboard.writeText(window.location.href); 56 63 share_btn.classList.remove('active'); 57 64 void share_btn.offsetWidth;
+3 -2
public/script/swap.js
··· 4 4 5 5 async function cached_fetch(url) { 6 6 let cached = caches[url]; 7 - console.log("cache: " + cached); 8 7 9 8 const res = cached === undefined ? await fetch(url) : await fetch(url, { 10 9 headers: { ··· 113 112 swap(event.state, false); 114 113 }); 115 114 116 - bind(document.body); 115 + document.addEventListener("DOMContentLoaded", () => { 116 + bind(document.body); 117 + });
+6
public/style/music-gateway.css
··· 358 358 359 359 #share { 360 360 margin: 0; 361 + padding: 0; 361 362 display: inline-block; 363 + color: inherit; 364 + font-family: inherit; 365 + font-size: inherit; 362 366 line-height: 1em; 363 367 text-shadow: 0 .05em 2px #0004; 364 368 cursor: pointer; 365 369 opacity: .5; 370 + background: none; 371 + border: none; 366 372 transition: opacity .1s linear; 367 373 } 368 374
+1 -1
views/base.html
··· 13 13 <!-- <script type="application/javascript" src="/script/lib/htmx.js"></script> --> 14 14 <!-- <script type="application/javascript" src="/script/lib/htmx.min.js"></script> --> 15 15 <!-- <script type="application/javascript" src="/script/lib/htmx-preload.js"></script> --> 16 - <script type="application/javascript" src="/script/swap.js" defer></script> 16 + <script type="application/javascript" src="/script/swap.js"></script> 17 17 </head> 18 18 19 19 <body>
+1 -1
views/index.html
··· 20 20 21 21 {{define "content"}} 22 22 <main> 23 - <script type="module" src="/script/main.js" defer></script> 23 + <script type="module" src="/script/main.js"></script> 24 24 25 25 <h1> 26 26 # hello, world!
+2 -2
views/music-gateway.html
··· 30 30 31 31 {{define "content"}} 32 32 <main> 33 - <script type="module" src="/script/music-gateway.js" defer></script> 33 + <script type="module" src="/script/music-gateway.js"></script> 34 34 35 35 <div id="background" style="background-image: url({{.ResolveArtwork}})"></div> 36 36 ··· 79 79 </p> 80 80 {{end}} 81 81 82 - <p id="share">share</p> 82 + <button id="share">share</button> 83 83 </div> 84 84 85 85 {{if .Credits}}
+1 -1
views/music.html
··· 18 18 19 19 {{define "content"}} 20 20 <main> 21 - <script type="module" src="/script/music.js" defer></script> 21 + <script type="module" src="/script/music.js"></script> 22 22 23 23 <h1> 24 24 # my music