Skip to main content
DameDaNeSpace

pyroclasticDusk

pyroclasticDusk's avatar

Oscilloscopic Symphony

he/him
18 years old
🥴

Last Login:

View: Profile | Blog

pyroclasticDusk's interests
General Coding, Writing, Thinking
Music PRS | TMBG | Lifeformed | BOC | Atronach's Aura | Neil Cic | Justice | BIG DATA | plenka | priroda | heXic HD (urbex?)
Games hendecad, Stardew, heXic HD, MYST, Castle Crashers, Noita, ROR2, The Stanley Parable, MC, Astroneer, Terraria
Books lots. maybe later ill fill this one out
Heroes Fred Hampton

importer v3 coming soon

i intend to add a song randomizer feature which works with existing themes, but also accepts multiple songs as input and picks one randomly...

something like, create an empty array m = [], add contents of theme's song url t.songURL to array: if its a string, add the string as the first item, if its an array, extend the empty array with its contents
so in shorthand

typeof t.songURL == 'object' ? t.songURL.forEach(e=>m.push(e)) : m.push(t.songURL)

then get the length l of this array and pick an item n from it, where n is ~~(Math.random()*l)

so

q('#songAudio').src = m[n]

where q() is shorthand for document.querySelector

now i just have to put it all together and upload it to github.

Comments
pyroclasticDusk
pyroclasticDusk's avatar

minified:
d=document;q=d.querySelector.bind(d);l=d.getElementsByClassName("theme");function m(){for(e in t) q(":root").style.setProperty(e, t[e]);r=t.songURL;n=t.songName;if(!Array.isArray(r)){r=new Array(r,'');n=new Array(n,'')}i=~~(Math.random()*r.length);o=q(".songName a");o.innerHTML=n[i];o.href=q('#songAudio').src=r[i]}function g(){u=this.title,fetch(u).then(e=>e.json()).then(e=>{t=e,m()}).catch(e=>{throw e})}for(j=0;j<l.length;j++)l[j].addEventListener("click",g);

minified variables / functions legend

  • d: html document
  • q(): queryselector function
  • l: all theme links
  • m(): implementer function
  • e: the go-to abbreviation for any throwaway variable, typically for iterable object properties
  • r: theme's song url(s)
  • n: theme's song name(s)
  • i: randomized integer to use when choosing song
  • o: song name element
  • g(): getter function
  • u: actual theme url
  • t: theme object
  • j: variable to iterate over all theme links