index.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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
  52. if(Cookies.get("theme_pref") == "dark")
  53. {
  54. theme.select("dark");
  55. }
  56. else {
  57. theme.select("light");
  58. }
  59. }
  60. function indexonload() {
  61. loadchanges();
  62. if (Cookies.get("cookie-consent") == "true") {
  63. if (!Cookies.get("theme_pref")) {
  64. setCookie("theme_pref", "light", 7);
  65. theme.select("light");
  66. } else if (Cookies.get("theme_pref") == "dark")
  67. theme.select("dark");
  68. else {
  69. theme.select("light");
  70. }
  71. }
  72. if (window.location.search.substring(1).includes("epilepsy"))
  73. theme.epilepsy();
  74. if (window.location.search.substring(1).includes("wtf"))
  75. rbow({
  76. "keyCode": 16
  77. });
  78. if (window.location.search.substring(1).includes("spook_mode"))
  79. getspooked();
  80. }
  81. function reload() {
  82. window.location.reload();
  83. }
  84. function loadchanges() {
  85. // if (getLang() == "de") {
  86. // document.getElementById("privacypolicy").href = "./privacypolicy_de";
  87. // document.getElementById("imprint").href = "./imprint_de";
  88. // document.getElementById("github").title = langValues.de.github_title;
  89. // document.getElementById("npm").title = langValues.de.npm_title;
  90. // document.getElementById("itch").title = langValues.de.itch_title;
  91. // document.getElementById("twitter").title = langValues.de.twitter_title;
  92. // document.getElementById("email").title = langValues.de.email_title;
  93. // document.getElementById("discord").title = langValues.de.discord_title;
  94. // document.getElementById("svcorelib").title = langValues.de.svcorelib_title;
  95. // document.getElementById("langapplier").title = langValues.de.langapplier_title;
  96. // document.getElementById("ttp").title = langValues.de.ttp_title;
  97. // document.getElementById("skribbl").title = langValues.de.skribbl_title;
  98. // document.getElementById("jokeapi").title = langValues.de.jokeapi_title;
  99. // document.getElementById("textisland").title = langValues.de.text_island_title;
  100. // document.getElementById("gamestitle").innerHTML = langValues.de.games_title;
  101. // document.getElementById("flappyswitch").title = langValues.de.flappy_switch_title;
  102. // document.getElementById("langbtn").title = langValues.de.langbtn_title;
  103. // document.getElementById("notif").querySelector("h3").textContent = langValues.de.email_copied;
  104. // document.getElementById("privacypolicy").textContent = langValues.de.privacy_policy;
  105. // document.getElementById("imprint").textContent = langValues.de.imprint;
  106. // } else {
  107. // document.getElementById("privacypolicy").href = "./privacypolicy_en";
  108. // document.getElementById("imprint").href = "./imprint_en";
  109. // document.getElementById("github").title = langValues.en.github_title;
  110. // document.getElementById("npm").title = langValues.en.npm_title;
  111. // document.getElementById("itch").title = langValues.en.itch_title;
  112. // document.getElementById("twitter").title = langValues.en.twitter_title;
  113. // document.getElementById("email").title = langValues.en.email_title;
  114. // document.getElementById("discord").title = langValues.en.discord_title;
  115. // document.getElementById("svcorelib").title = langValues.en.svcorelib_title;
  116. // document.getElementById("langapplier").title = langValues.en.langapplier_title;
  117. // document.getElementById("ttp").title = langValues.en.ttp_title;
  118. // document.getElementById("skribbl").title = langValues.en.skribbl_title;
  119. // document.getElementById("jokeapi").title = langValues.en.jokeapi_title;
  120. // document.getElementById("textisland").title = langValues.en.text_island_title;
  121. // document.getElementById("gamestitle").innerHTML = langValues.en.games_title;
  122. // document.getElementById("flappyswitch").title = langValues.en.flappy_switch_title;
  123. // document.getElementById("langbtn").title = langValues.en.langbtn_title;
  124. // document.getElementById("notif").querySelector("h3").textContent = langValues.en.email_copied;
  125. // document.getElementById("privacypolicy").textContent = langValues.en.privacy_policy;
  126. // document.getElementById("imprint").textContent = langValues.en.imprint;
  127. // }
  128. }
  129. function getLang() {
  130. var browserlang = navigator.language || navigator.userLanguage;
  131. if (Cookies.get("lang_pref"))
  132. return Cookies.get("lang_pref");
  133. if (Cookies.get("cookie-consent") == "true") {
  134. if (browserlang.includes("de")) {
  135. setCookie("lang_pref", "de", 31);
  136. return "de";
  137. } else {
  138. setCookie("lang_pref", "en", 31);
  139. return "en";
  140. }
  141. }
  142. return "en";
  143. }
  144. function switchLang() {
  145. if (Cookies.get("cookie-consent") != "true") {
  146. let notif = document.getElementById("notif");
  147. document.getElementById("cookie-consent").style.display = "flex";
  148. document.getElementById("cookie-consent").classList.add("fade-to-the-right");
  149. notif.style.backgroundColor = "#F17E7E";
  150. notif.style.color = "#931010";
  151. notif.style.borderColor = "#EF6C6C";
  152. notif.querySelector("h3").textContent = "Cookies need to be set to change the language";
  153. notif.style.visibility = "visible";
  154. notif.style.opacity = "1";
  155. setTimeout(() => {
  156. notif.style.opacity = "0";
  157. notif.style.visibility = "hidden";
  158. }, 2500);
  159. return;
  160. }
  161. var oldlang = getLang();
  162. if (Cookies.get("cookie-consent") == "true") {
  163. if (oldlang == "en")
  164. setCookie("lang_pref", "de", 31);
  165. if (oldlang == "de")
  166. setCookie("lang_pref", "en", 31);
  167. }
  168. reload();
  169. }
  170. const theme = {
  171. change: function () {
  172. if (Cookies.get("cookie-consent") != "true") {
  173. document.getElementById("cookie-consent").style.display = "flex";
  174. document.getElementById("cookie-consent").classList.add("fade-to-the-right");
  175. }
  176. var oldtheme = document.body.dataset.theme;
  177. if (oldtheme == "dark") {
  178. var newtheme = "light";
  179. document.getElementById("themebtn").title = "Switch to dark theme";
  180. } else {
  181. var newtheme = "dark";
  182. document.getElementById("themebtn").title = "Switch to light theme";
  183. }
  184. theme.select(newtheme);
  185. },
  186. select: function (newtheme) {
  187. if (Cookies.get("cookie-consent") == "true") {
  188. setCookie("theme_pref", newtheme, 7);
  189. }
  190. if (newtheme == "dark") {
  191. if (document.getElementsByClassName("ph-moon")[0]) {
  192. document.getElementsByClassName("ph-moon")[0].classList.add("ph-sun");
  193. document.getElementsByClassName("ph-moon")[0].classList.remove("ph-moon");
  194. document.getElementById("cloudflare").querySelector("img").src = "resources/images/cloudflare-dark.svg";
  195. }
  196. } else {
  197. if (document.getElementsByClassName("ph-sun")[0]) {
  198. document.getElementsByClassName("ph-sun")[0].classList.add("ph-moon");
  199. document.getElementsByClassName("ph-sun")[0].classList.remove("ph-sun");
  200. document.getElementById("cloudflare").querySelector("img").src = "resources/images/cloudflare-light.svg";
  201. }
  202. }
  203. document.body.dataset.theme = newtheme;
  204. },
  205. epilepsy: function () {
  206. setInterval(theme.change, 250);
  207. },
  208. spooky: function () {
  209. document.body.dataset.theme = "spooky";
  210. }
  211. }
  212. function copyemail() {
  213. var text = atob("Y29udGFjdEBzdjQ0My5uZXQ="); // anti crawler
  214. copyText(text);
  215. let notif = document.getElementById("notif");
  216. notif.style.backgroundColor = "#cce5ff";
  217. notif.style.color = "#004085";
  218. notif.style.borderColor = "#b8daff";
  219. notif.querySelector("h3").textContent = getLang() == "en" ? langValues.en.email_copied : langValues.de.email_copied;
  220. notif.style.visibility = "visible";
  221. notif.style.opacity = "1";
  222. setTimeout(() => {
  223. notif.style.opacity = "0";
  224. notif.style.visibility = "hidden";
  225. }, 2500);
  226. }
  227. function copyText(text)
  228. {
  229. var copyelem = document.createElement("textarea");
  230. copyelem.id = "copy";
  231. copyelem.innerHTML = text;
  232. document.body.appendChild(copyelem);
  233. document.getElementById("copy").select();
  234. document.execCommand("copy");
  235. copyelem.remove();
  236. }
  237. var donce = false;
  238. function rbow(e) {
  239. if (e.keyCode == 16 && !donce) {
  240. donce = true;
  241. document.getElementById("title").dataset.disco = "true";
  242. let stel = document.createElement("style");
  243. stel.innerHTML = "*{transform:rotate(1900deg);transition:transform 1000s linear;}";
  244. document.head.appendChild(stel);
  245. }
  246. }
  247. function getspooked() {
  248. theme.spooky();
  249. var audio = new Audio("resources/audio/spooktune.mp3");
  250. audio.play();
  251. audio.loop = true;
  252. let spook1 = document.createElement("img");
  253. spook1.style.height = "10em";
  254. spook1.src = "https://78.media.tumblr.com/828ab575b1894f3901ae7a05bb27f2cc/tumblr_n6hhknZQv91r2vz4uo1_400.gif"
  255. document.getElementsByTagName("header")[0].prepend(spook1);
  256. let spook2 = document.createElement("img");
  257. spook2.style.height = "10em";
  258. spook2.src = "https://i.kym-cdn.com/entries/icons/facebook/000/011/121/SKULL_TRUMPET_0-1_screenshot.jpg";
  259. document.getElementById("projects").appendChild(spook2);
  260. let spook3div = document.createElement("div");
  261. spook3div.style.textAlign = "center";
  262. let spook3 = document.createElement("img");
  263. spook3.style.height = "10em";
  264. spook3.src = "https://cdn03.plentymarkets.com/chg0wln2n7ix/item/images/102979/full/Jack-O-Lantern-Halloween-Kuerbis-Windlicht-21x19-c.jpg";
  265. spook3div.appendChild(spook3);
  266. document.getElementsByTagName("main")[0].append(spook3div);
  267. document.getElementById("title").innerHTML = "🎃 Spook443 🎃";
  268. }
  269. function setCookie(key, value, expires) {
  270. Cookies.set(key, value, {
  271. expires: expires,
  272. SameSite: "Strict"
  273. })
  274. }
  275. function consentGranted() {
  276. document.getElementById("cookie-consent").style.display = "none";
  277. setCookie("cookie-consent", "true", 365);
  278. setCookie("theme_pref", document.body.dataset.theme, 31);
  279. }
  280. function consentDenied() {
  281. document.getElementById("cookie-consent").style.display = "none";
  282. }