uni

University stuff
git clone git://git.margiolis.net/uni.git
Log | Files | Refs | README | LICENSE

main.js (1231B)


      1 const params = new URLSearchParams(window.location.search);
      2 const phrase = params.get("phrase");
      3 const element = params.get("element");
      4 const pics = [
      5 	"air1.png",
      6 	"air2.png",
      7 	"air3.png",
      8 	"earth1.png",
      9 	"earth2.png",
     10 	"earth3.png",
     11 	"fire1.png",
     12 	"fire2.png",
     13 	"fire3.png",
     14 	"water1.png",
     15 	"water2.png",
     16 	"water3.png",
     17 	"yinyang.png",
     18 ].filter(s => s.startsWith(element));
     19 
     20 var p_phrase = document.createElement("p");
     21 var p_element = document.createElement("p");
     22 var img = document.createElement("img");
     23 
     24 p_phrase.innerHTML = "Phrase: " + phrase;
     25 p_element.innerHTML = "Element: " + element;
     26 img.src = "res/" + pics[Math.floor(Math.random() * pics.length)];
     27 img.style = "width: 50%; border: 8px solid black;";
     28 
     29 document.getElementById("topright").style.transform =
     30     "rotate(" + (phrase.length * 10) % 360 + "deg)";
     31 
     32 document.body.appendChild(p_phrase);
     33 document.body.appendChild(p_element);
     34 document.body.appendChild(img);
     35 
     36 switch (element) {
     37 case "water":
     38 	document.body.style.background = "lightblue";
     39 	break;
     40 case "earth":
     41 	document.body.style.background = "darkolivegreen";
     42 	break;
     43 case "fire":
     44 	document.body.style.background = "firebrick";
     45 	break;
     46 case "air":
     47 	document.body.style.background = "lightyellow";
     48 	break;
     49 }