index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. "use-strict";
  2. const theme = Object.freeze({
  3. change: () => {
  4. if(Cookies.get("cookie_consent") != "true")
  5. {
  6. document.getElementById("cookie-consent").style.display = "flex";
  7. document.getElementById("cookie-consent").classList.add("fade-to-the-right");
  8. }
  9. var oldtheme = document.body.dataset.theme;
  10. if (oldtheme == "dark")
  11. {
  12. var newtheme = "light";
  13. document.getElementById("themebtn").title = "Switch to dark theme";
  14. }
  15. else
  16. {
  17. var newtheme = "dark";
  18. document.getElementById("themebtn").title = "Switch to light theme";
  19. }
  20. theme.select(newtheme);
  21. },
  22. select: (newtheme) => {
  23. if(Cookies.get("cookie_consent") == "true")
  24. setCookie("theme_pref", newtheme, 7);
  25. if(newtheme == "dark")
  26. {
  27. if(document.querySelector("#themeimg"))
  28. {
  29. document.querySelector("#themeimg").src = "./resources/images/sun.svg";
  30. }
  31. }
  32. else
  33. {
  34. if(document.querySelector("#themeimg"))
  35. {
  36. document.querySelector("#themeimg").src = "./resources/images/moon.svg";
  37. }
  38. }
  39. document.body.dataset.theme = newtheme;
  40. },
  41. epilepsy: () => {
  42. setInterval(theme.change, 250);
  43. },
  44. spooky: () => {
  45. document.body.dataset.theme = "spooky";
  46. },
  47. /** Applies the theme from the settings in the cookies, else applies the default theme (light) */
  48. apply: () => {
  49. const cookieConsent = Cookies.get("cookie-consent") == "true";
  50. const themePref = Cookies.get("theme_pref");
  51. if(!themePref && cookieConsent)
  52. setCookie("theme_pref", "light", 7);
  53. else if(themePref == "dark")
  54. return theme.select("dark");
  55. return theme.select("light");
  56. }
  57. });
  58. function otheronload()
  59. {
  60. theme.apply();
  61. }
  62. function indexonload()
  63. {
  64. theme.apply();
  65. const queryStr = window.location.search.substring(1);
  66. const d = new Date();
  67. if (queryStr.includes("epilepsy"))
  68. theme.epilepsy();
  69. if (queryStr.includes("wtf"))
  70. rbow({
  71. "keyCode": 16
  72. });
  73. if(d.getMonth() == 9 && d.getDate() == 31 || queryStr.includes("spook_mode"))
  74. getspooked();
  75. const logo = document.querySelector("#logo");
  76. logo.addEventListener("dblclick", () => logo.classList.add("pride"));
  77. }
  78. function reload()
  79. {
  80. window.location.reload();
  81. }
  82. function copyemail()
  83. {
  84. var text = atob("Y29udGFjdEBzdjQ0My5uZXQ=");
  85. copyText(text);
  86. let notif = document.getElementById("notif");
  87. notif.classList.add("noselect");
  88. notif.style.backgroundColor = "#ddddee";
  89. notif.style.color = "#000";
  90. notif.querySelector("h3").textContent = "(E-Mail address copied to clipboard)";
  91. notif.style.visibility = "visible";
  92. notif.style.opacity = "1";
  93. setTimeout(() => {
  94. notif.style.opacity = "0";
  95. notif.style.visibility = "hidden";
  96. }, 2500);
  97. }
  98. async function copyText(text)
  99. {
  100. await navigator.clipboard.writeText(text.toString());
  101. }
  102. var donce = false;
  103. function rbow(e) {
  104. if (e.keyCode == 16 && !donce) {
  105. donce = true;
  106. document.getElementById("title").dataset.disco = "true";
  107. let stel = document.createElement("style");
  108. stel.innerHTML = "*{transform:rotate(2300deg);transition:transform 1000s linear;}";
  109. document.head.appendChild(stel);
  110. }
  111. }
  112. function getspooked()
  113. {
  114. theme.spooky();
  115. var audio = new Audio("resources/audio/spooktune.mp3");
  116. audio.volume = 0.5;
  117. audio.play();
  118. audio.loop = true;
  119. let spook1 = document.createElement("img");
  120. spook1.style.height = "10em";
  121. spook1.src = "https://78.media.tumblr.com/828ab575b1894f3901ae7a05bb27f2cc/tumblr_n6hhknZQv91r2vz4uo1_400.gif"
  122. document.getElementsByTagName("header")[0].prepend(spook1);
  123. let spook2 = document.createElement("img");
  124. spook2.style.height = "10em";
  125. spook2.src = "https://i.kym-cdn.com/entries/icons/facebook/000/011/121/SKULL_TRUMPET_0-1_screenshot.jpg";
  126. document.getElementById("projects").appendChild(spook2);
  127. let spook3div = document.createElement("div");
  128. spook3div.style.textAlign = "center";
  129. let spook3 = document.createElement("img");
  130. spook3.style.height = "10em";
  131. spook3.src = "https://cdn03.plentymarkets.com/chg0wln2n7ix/item/images/102979/full/Jack-O-Lantern-Halloween-Kuerbis-Windlicht-21x19-c.jpg";
  132. spook3div.appendChild(spook3);
  133. document.getElementsByTagName("main")[0].append(spook3div);
  134. document.getElementById("title").innerHTML = "🎃 Spook443 Network 🎃";
  135. }
  136. function setCookie(key, value, expires)
  137. {
  138. Cookies.set(key, value, {
  139. expires: expires,
  140. SameSite: "Strict"
  141. })
  142. }
  143. function consentGranted()
  144. {
  145. document.getElementById("cookie-consent").style.display = "none";
  146. setCookie("cookie_consent", "true", 365);
  147. setCookie("theme_pref", document.body.dataset.theme, 31);
  148. }
  149. function consentDenied()
  150. {
  151. document.getElementById("cookie-consent").style.display = "none";
  152. }