index.js 5.2 KB

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