index.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. "use-strict";
  2. let langValues = {
  3. en: {
  4. games_title: "Games",
  5. email_copied: "(E-Mail address copied to clipboard)",
  6. about_title: "About me:",
  7. github_title: "Sv443 on Github",
  8. npm_title: "Sv443 on npm",
  9. twitter_title: "Sv443 on Twitter",
  10. itch_title: "Sv443 on itch.io",
  11. email_title: "Copies Sv443's E-Mail address to your clipboard",
  12. discord_title: "Join the Sv443 Network Discord server",
  13. flappy_switch_title: "Play Flappy Switch",
  14. langbtn_title: "Wecshle zu Deutsch",
  15. privacy_policy: "Privacy Policy",
  16. imprint: "Legal Information",
  17. svcorelib_title: "Visit the SvCoreLib Github repository",
  18. langapplier_title: "Visit the LangApplier Github repository",
  19. ttp_title: "Visit the TamperTubePlus Github repository",
  20. skribbl_title: "Visit the skribbl.io Github repository",
  21. text_island_title: "Play Text Island",
  22. jokeapi_title: "Visit the JokeAPI Website",
  23. },
  24. de: {
  25. games_title: "Spiele",
  26. email_copied: "(E-Mail Adresse in die Zwischenablage kopiert)",
  27. about_title: "Über mich:",
  28. github_title: "Sv443 auf GitHub",
  29. npm_title: "Sv443 auf npm",
  30. twitter_title: "Sv443 auf Twitter",
  31. itch_title: "Sv443 auf itch.io",
  32. email_title: "Kopiert Sv443's E-Mail Adresse in deine Zwischenablage",
  33. discord_title: "Betrete den Discord-Server vom Sv443 Network",
  34. flappy_switch_title: "Spiele Flappy Switch",
  35. langbtn_title: "Switch to English",
  36. privacy_policy: "Datenschutzerklärung",
  37. imprint: "Impressum",
  38. svcorelib_title: "Besuche die SvCoreLib GitHub-Seite",
  39. langapplier_title: "Besuche die LangApplier GitHub-Seite",
  40. ttp_title: "Besuche die TamperTubePlus GitHub-Seite",
  41. skribbl_title: "Besuche die skribbl.io+ GitHub-Seite",
  42. text_island_title: "Spiele Text Island",
  43. jokeapi_title: "Besuche die JokeAPI Website",
  44. }
  45. };
  46. function otheronload() {
  47. // if (Cookies.get("cookie-consent") == "true") {
  48. // if (!Cookies.get("theme_pref")) {
  49. // setCookie("theme_pref", "light", 7);
  50. // theme.select("light");
  51. // } else if (Cookies.get("theme_pref") == "dark")
  52. // theme.select("dark");
  53. // else {
  54. // theme.select("light");
  55. // }
  56. // }
  57. }
  58. function indexonload() {
  59. loadchanges();
  60. if (Cookies.get("cookie-consent") == "true") {
  61. if (!Cookies.get("theme_pref")) {
  62. setCookie("theme_pref", "light", 7);
  63. theme.select("light");
  64. } else if (Cookies.get("theme_pref") == "dark")
  65. theme.select("dark");
  66. else {
  67. theme.select("light");
  68. }
  69. }
  70. if (window.location.search.substring(1).includes("epilepsy"))
  71. theme.epilepsy();
  72. if (window.location.search.substring(1).includes("wtf"))
  73. rbow({
  74. "keyCode": 16
  75. });
  76. if (window.location.search.substring(1).includes("spook_mode"))
  77. getspooked();
  78. }
  79. function reload() {
  80. window.location.reload();
  81. }
  82. function loadchanges() {
  83. // if (getLang() == "de") {
  84. // document.getElementById("privacypolicy").href = "./privacypolicy_de";
  85. // document.getElementById("imprint").href = "./imprint_de";
  86. // document.getElementById("github").title = langValues.de.github_title;
  87. // document.getElementById("npm").title = langValues.de.npm_title;
  88. // document.getElementById("itch").title = langValues.de.itch_title;
  89. // document.getElementById("twitter").title = langValues.de.twitter_title;
  90. // document.getElementById("email").title = langValues.de.email_title;
  91. // document.getElementById("discord").title = langValues.de.discord_title;
  92. // document.getElementById("svcorelib").title = langValues.de.svcorelib_title;
  93. // document.getElementById("langapplier").title = langValues.de.langapplier_title;
  94. // document.getElementById("ttp").title = langValues.de.ttp_title;
  95. // document.getElementById("skribbl").title = langValues.de.skribbl_title;
  96. // document.getElementById("jokeapi").title = langValues.de.jokeapi_title;
  97. // document.getElementById("textisland").title = langValues.de.text_island_title;
  98. // document.getElementById("gamestitle").innerHTML = langValues.de.games_title;
  99. // document.getElementById("flappyswitch").title = langValues.de.flappy_switch_title;
  100. // document.getElementById("langbtn").title = langValues.de.langbtn_title;
  101. // document.getElementById("notif").querySelector("h3").textContent = langValues.de.email_copied;
  102. // document.getElementById("privacypolicy").textContent = langValues.de.privacy_policy;
  103. // document.getElementById("imprint").textContent = langValues.de.imprint;
  104. // } else {
  105. // document.getElementById("privacypolicy").href = "./privacypolicy_en";
  106. // document.getElementById("imprint").href = "./imprint_en";
  107. // document.getElementById("github").title = langValues.en.github_title;
  108. // document.getElementById("npm").title = langValues.en.npm_title;
  109. // document.getElementById("itch").title = langValues.en.itch_title;
  110. // document.getElementById("twitter").title = langValues.en.twitter_title;
  111. // document.getElementById("email").title = langValues.en.email_title;
  112. // document.getElementById("discord").title = langValues.en.discord_title;
  113. // document.getElementById("svcorelib").title = langValues.en.svcorelib_title;
  114. // document.getElementById("langapplier").title = langValues.en.langapplier_title;
  115. // document.getElementById("ttp").title = langValues.en.ttp_title;
  116. // document.getElementById("skribbl").title = langValues.en.skribbl_title;
  117. // document.getElementById("jokeapi").title = langValues.en.jokeapi_title;
  118. // document.getElementById("textisland").title = langValues.en.text_island_title;
  119. // document.getElementById("gamestitle").innerHTML = langValues.en.games_title;
  120. // document.getElementById("flappyswitch").title = langValues.en.flappy_switch_title;
  121. // document.getElementById("langbtn").title = langValues.en.langbtn_title;
  122. // document.getElementById("notif").querySelector("h3").textContent = langValues.en.email_copied;
  123. // document.getElementById("privacypolicy").textContent = langValues.en.privacy_policy;
  124. // document.getElementById("imprint").textContent = langValues.en.imprint;
  125. // }
  126. }
  127. function getLang() {
  128. var browserlang = navigator.language || navigator.userLanguage;
  129. if (Cookies.get("lang_pref"))
  130. return Cookies.get("lang_pref");
  131. if (Cookies.get("cookie-consent") == "true") {
  132. if (browserlang.includes("de")) {
  133. setCookie("lang_pref", "de", 31);
  134. return "de";
  135. } else {
  136. setCookie("lang_pref", "en", 31);
  137. return "en";
  138. }
  139. }
  140. return "en";
  141. }
  142. function switchLang() {
  143. if (Cookies.get("cookie-consent") != "true") {
  144. let notif = document.getElementById("notif");
  145. document.getElementById("cookie-consent").style.display = "flex";
  146. document.getElementById("cookie-consent").classList.add("fade-to-the-right");
  147. notif.style.backgroundColor = "#F17E7E";
  148. notif.style.color = "#931010";
  149. notif.style.borderColor = "#EF6C6C";
  150. notif.querySelector("h3").textContent = "Cookies need to be set to change the language";
  151. notif.style.visibility = "visible";
  152. notif.style.opacity = "1";
  153. setTimeout(() => {
  154. notif.style.opacity = "0";
  155. notif.style.visibility = "hidden";
  156. }, 2500);
  157. return;
  158. }
  159. var oldlang = getLang();
  160. if (Cookies.get("cookie-consent") == "true") {
  161. if (oldlang == "en")
  162. setCookie("lang_pref", "de", 31);
  163. if (oldlang == "de")
  164. setCookie("lang_pref", "en", 31);
  165. }
  166. reload();
  167. }
  168. const theme = {
  169. change: function () {
  170. if (Cookies.get("cookie-consent") != "true") {
  171. document.getElementById("cookie-consent").style.display = "flex";
  172. document.getElementById("cookie-consent").classList.add("fade-to-the-right");
  173. }
  174. var oldtheme = document.body.dataset.theme;
  175. if (oldtheme == "dark") {
  176. var newtheme = "light";
  177. document.getElementById("themebtn").title = "Switch to dark theme";
  178. } else {
  179. var newtheme = "dark";
  180. document.getElementById("themebtn").title = "Switch to light theme";
  181. }
  182. theme.select(newtheme);
  183. },
  184. select: function (newtheme) {
  185. if (Cookies.get("cookie-consent") == "true") {
  186. setCookie("theme_pref", newtheme, 7);
  187. }
  188. if (newtheme == "dark") {
  189. if (document.getElementsByClassName("ph-moon")[0]) {
  190. document.getElementsByClassName("ph-moon")[0].classList.add("ph-sun");
  191. document.getElementsByClassName("ph-moon")[0].classList.remove("ph-moon");
  192. document.getElementById("cloudflare").querySelector("img").src = "resources/images/cloudflare-dark.svg";
  193. }
  194. } else {
  195. if (document.getElementsByClassName("ph-sun")[0]) {
  196. document.getElementsByClassName("ph-sun")[0].classList.add("ph-moon");
  197. document.getElementsByClassName("ph-sun")[0].classList.remove("ph-sun");
  198. document.getElementById("cloudflare").querySelector("img").src = "resources/images/cloudflare-light.svg";
  199. }
  200. }
  201. document.body.dataset.theme = newtheme;
  202. },
  203. epilepsy: function () {
  204. setInterval(theme.change, 250);
  205. },
  206. spooky: function () {
  207. document.body.dataset.theme = "spooky";
  208. }
  209. }
  210. function copyemail() {
  211. var text = atob("Y29udGFjdEBzdjQ0My5uZXQ="); // anti crawler
  212. copyText(text);
  213. let notif = document.getElementById("notif");
  214. notif.style.backgroundColor = "#cce5ff";
  215. notif.style.color = "#004085";
  216. notif.style.borderColor = "#b8daff";
  217. notif.querySelector("h3").textContent = getLang() == "en" ? langValues.en.email_copied : langValues.de.email_copied;
  218. notif.style.visibility = "visible";
  219. notif.style.opacity = "1";
  220. setTimeout(() => {
  221. notif.style.opacity = "0";
  222. notif.style.visibility = "hidden";
  223. }, 2500);
  224. }
  225. function copyText(text)
  226. {
  227. var copyelem = document.createElement("textarea");
  228. copyelem.id = "copy";
  229. copyelem.innerHTML = text;
  230. document.body.appendChild(copyelem);
  231. document.getElementById("copy").select();
  232. document.execCommand("copy");
  233. copyelem.remove();
  234. }
  235. var donce = false;
  236. function rbow(e) {
  237. if (e.keyCode == 16 && !donce) {
  238. donce = true;
  239. document.getElementById("title").dataset.disco = "true";
  240. let stel = document.createElement("style");
  241. stel.innerHTML = "*{transform:rotate(1900deg);transition:transform 1000s linear;}";
  242. document.head.appendChild(stel);
  243. }
  244. }
  245. function getspooked() {
  246. theme.spooky();
  247. var audio = new Audio("resources/audio/spooktune.mp3");
  248. audio.play();
  249. audio.loop = true;
  250. let spook1 = document.createElement("img");
  251. spook1.style.height = "10em";
  252. spook1.src = "https://78.media.tumblr.com/828ab575b1894f3901ae7a05bb27f2cc/tumblr_n6hhknZQv91r2vz4uo1_400.gif"
  253. document.getElementsByTagName("header")[0].prepend(spook1);
  254. let spook2 = document.createElement("img");
  255. spook2.style.height = "10em";
  256. spook2.src = "https://i.kym-cdn.com/entries/icons/facebook/000/011/121/SKULL_TRUMPET_0-1_screenshot.jpg";
  257. document.getElementById("projects").appendChild(spook2);
  258. let spook3div = document.createElement("div");
  259. spook3div.style.textAlign = "center";
  260. let spook3 = document.createElement("img");
  261. spook3.style.height = "10em";
  262. spook3.src = "https://cdn03.plentymarkets.com/chg0wln2n7ix/item/images/102979/full/Jack-O-Lantern-Halloween-Kuerbis-Windlicht-21x19-c.jpg";
  263. spook3div.appendChild(spook3);
  264. document.getElementsByTagName("main")[0].append(spook3div);
  265. document.getElementById("title").innerHTML = "🎃 Spook443 🎃";
  266. }
  267. function setCookie(key, value, expires) {
  268. Cookies.set(key, value, {
  269. expires: expires,
  270. SameSite: "Strict"
  271. })
  272. }
  273. function consentGranted() {
  274. document.getElementById("cookie-consent").style.display = "none";
  275. setCookie("cookie-consent", "true", 365);
  276. setCookie("theme_pref", document.body.dataset.theme, 31);
  277. }