A music player that connects to your cloud/distributed storage.
1// Version upgrade (only works with `diffuse-artifacts` deployments)
2if (document.location.hostname.endsWith("diffuse.sh")) {
3 document.querySelectorAll("#status").forEach(async (status) => {
4 const versionOrCid =
5 document.location.pathname.slice(1).split("/")[0]?.toLowerCase() ?? "";
6 const usesCid = versionOrCid.startsWith("bafy");
7 const { default: artifacts } = await import(
8 `${document.location.origin}/artifacts.json`,
9 { with: { type: "json" } }
10 );
11
12 // Latest is located at the end
13 const lastArtifact = Object.values(artifacts).reverse()[0];
14
15 // Check if using latest
16 const isLatest = usesCid
17 ? versionOrCid === lastArtifact.cid
18 : versionOrCid === lastArtifact.version;
19
20 // Remove loading animation
21 status.querySelectorAll(".ph-spinner").forEach((icon) => {
22 icon.parentElement?.classList.add("hidden");
23
24 setTimeout(() => {
25 icon.parentElement?.classList.remove("animate-spin");
26 icon.classList.remove("ph-spinner");
27 icon.classList.add("ph-arrow-fat-lines-up");
28 }, 500);
29 });
30
31 // If using CID, append `/hash/` to href
32 status.querySelectorAll(`[href="/latest/"]`).forEach((a) => {
33 if (usesCid) a.setAttribute("href", "/latest/hash/");
34 if (!isLatest) {
35 setTimeout(() => {
36 a.classList.remove("hidden");
37 }, 750);
38 }
39 });
40 });
41} else {
42 document.querySelectorAll("#status").forEach((status) => {
43 status.remove();
44 });
45}