index.js 5.2 KB

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