Jelajahi Sumber

Merge pull request #2 from Sv443-Network/GDPR-stuff

Sven Fehler 4 tahun lalu
induk
melakukan
528aa6af4f
6 mengubah file dengan 247 tambahan dan 105 penghapusan
  1. 33 1
      css/global.css
  2. 56 3
      css/index.css
  3. 22 12
      index.html
  4. 136 89
      js/index.js
  5. TEMPAT SAMPAH
      resources/images/svcorelib.png
  6. TEMPAT SAMPAH
      resources/images/svcorelib.webp

+ 33 - 1
css/global.css

@@ -26,7 +26,7 @@ body[data-theme="light"] {
 }
 
 body[data-theme="dark"] {
-    background-color: #151515;
+    background-color: var(--bg-color-dark);
     color: white;
 }
 
@@ -90,6 +90,38 @@ body[data-theme="spooky"] footer {
     background-color: #f9ac59;
 }
 
+body[data-theme="light"] #cookie-consent {
+    background-color: #edeef4;
+}
+
+body[data-theme="dark"] #cookie-consent {
+    background-color: #101010;
+}
+
+body[data-theme="light"] #consent-button {
+    background-color: #D8D8D8;
+}
+
+body[data-theme="dark"] #consent-button {
+    background-color: #202020;    
+}
+
+body[data-theme="light"] #consent-button span {
+    color: black;
+}
+
+body[data-theme="light"] #consent-button:hover span {
+    color: #5aa469;
+}
+
+body[data-theme="dark"] #consent-button span {
+    color: white;
+}
+
+body[data-theme="dark"] #consent-button:hover span {
+    color: #5aa469;
+}
+
 body[data-theme="light"] h1 {
     color: black;
 }

+ 56 - 3
css/index.css

@@ -122,6 +122,7 @@ header {
 
 main {
     margin: 1em 15%;
+    padding-bottom: 50px;
 }
 
 #synopsis {
@@ -142,6 +143,7 @@ main {
     background-image: url(../resources/images/Sv443NetworkIcon.webp);
     background-size: cover;
     margin-left: auto;
+    margin-right: 0;
 }
 
 #projects {
@@ -220,8 +222,9 @@ img.rounded.square {
 }
 
 footer {
-    position: sticky;
+    position: fixed;
     bottom: 0;
+    width: 100vw;
     display: flex;
     flex-wrap: wrap;
     justify-content: space-between;
@@ -240,7 +243,7 @@ footer a:hover {
     display: flex;
     justify-content: center;
     align-items: center;
-    margin-left: 20px;
+    margin: 0 20px;
 }
 
 #legal {
@@ -278,14 +281,64 @@ footer a:hover {
     text-align: center;
     visibility: hidden;
     opacity: 0;
-    transition: all 0.5s;
+    transition: visibility 0.5s, opacity 0.5s;
 }
 
 #notif h3 {
     margin: 0;
 }
 
+.fade-to-the-right {
+    animation: fade-to-the-right 0.8s;
+}
+
+@keyframes fade-to-the-right {
+    0% {
+        opacity: 0.1;
+        transform: translateX(-120%);
+    }
+
+    100% {
+        opacity: 1;
+        transform: translateX(0);
+    }
+}
+
+#cookie-consent {
+    display: none;
+    justify-content: space-around;
+    align-items: center;
+    background-color: #edeef4;
+    padding: 5px 20px;
+    flex-basis: 100%;
+    font-size: 14px;
+}
+
+#consent-button {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    height: 25px;
+    background-color: #D8D8D8;
+    border-radius: 30px;
+    padding: 10px 15px;
+}
+
+#consent-button:hover span {
+    color: #5aa469;
+}
+
+@media (max-width: 768px) {
+    #cookie-consent {
+        flex-direction: column;
+    }
+}
+
 @media (max-width: 512px) {
+    #logo {
+        margin-right: auto;
+    }
+
     footer {
         flex-direction: column;
     }

+ 22 - 12
index.html

@@ -45,12 +45,12 @@
 <body onload="indexonload();">
     <header>
         <div id="options">
-            <div id="themebtn" onclick="theme.change();">
+            <div id="themebtn" onclick="theme.change()" title="Switch to dark theme">
                 <i class="ph-moon icon"></i>
             </div>
-            <div id="langbtn" title="Wechsle zu Deutsch" onclick="switchLang();">
+            <!--div id="langbtn" title="Wechsle zu Deutsch" onclick="switchLang();">
                 <i class="ph-translate icon"></i>
-            </div>
+            </div-->
         </div>
         
         <p id="title">Sv443 Network</p>
@@ -77,19 +77,19 @@
                         <img src="./resources/images/jokeapi.webp" alt="JokeAPI icon" class="square"></img>
                         <h4>JokeAPI</h4>
                     </div></a>
-                    <a href="https://github.com/Sv443/SvCoreLib" id="svcorelib" rel="noopener" class="img-link" title="Visit the SvCoreLib Github Repository" target="_blank"><div class="list-item-container">
-                        <img src="./resources/images/svcorelib.webp" alt="SvCoreLib icon" class="square"></img>
+                    <a href="https://github.com/Sv443/SvCoreLib" id="svcorelib" rel="noopener" class="img-link" title="Visit the SvCoreLib GitHub Repository" target="_blank"><div class="list-item-container">
+                        <img src="./resources/images/svcorelib.png" alt="SvCoreLib icon" class="square"></img>
                         <h4>SvCoreLib</h4>
                     </div></a>
-                    <a href="https://github.com/Sv443/LangApplier" id="langapplier" rel="noopener" class="img-link" title="Visit the LangApplier Gitub Repository" target="_blank"><div class="list-item-container">
+                    <a href="https://github.com/Sv443/LangApplier" id="langapplier" rel="noopener" class="img-link" title="Visit the LangApplier GitHub Repository" target="_blank"><div class="list-item-container">
                         <img src="./resources/images/langapplier.webp" alt="LangApplier icon" class="rounded square"></img>
                         <h4>LangApplier</h4>
                     </div></a>
-                    <a href="https://github.com/Sv443/TamperTubePlus" id="ttp" rel="noopener" class="img-link" title="Visit the TamperTubePlus Github Repository" target="_blank"><div class="list-item-container">
+                    <a href="https://github.com/Sv443/TamperTubePlus" id="ttp" rel="noopener" class="img-link" title="Visit the TamperTubePlus GitHub Repository" target="_blank"><div class="list-item-container">
                         <img src="./resources/images/ttp.webp" alt="TamperTubePlus icon" class="square"></img>
                         <h4>TamperTubePlus</h4>
                     </div></a>
-                    <a href="https://github.com/Sv443/skribbl.io-plus" id="skribbl" rel="noopener" class="img-link" title="Visit the Skribbl.io+ Github Repository" target="_blank"><div class="list-item-container">
+                    <a href="https://github.com/Sv443/skribbl.io-plus" id="skribbl" rel="noopener" class="img-link" title="Visit the Skribbl.io+ GitHub Repository" target="_blank"><div class="list-item-container">
                         <img src="https://raw.githubusercontent.com/Sv443/code/master/resources/favicons/skribbl.io%2B%20icon.png" alt="Skribbl.io icon" class="square"></img>
                         <h4>Skribbl.io+</h4>
                     </div></a>
@@ -117,9 +117,9 @@
                 <h1>Contact</h1>
             </div>
             <div class="list">
-                <a href="https://github.com/Sv443" id="github" rel="noopener" class="img-link" title="Sv443 on Github" target="_blank"><div class="list-item-container">
-                    <img src="./resources/images/github.webp" alt="Github icon" class="circle"></img>
-                    <h4>Github</h4>
+                <a href="https://github.com/Sv443" id="github" rel="noopener" class="img-link" title="Sv443 on GitHub" target="_blank"><div class="list-item-container">
+                    <img src="./resources/images/github.webp" alt="GitHub icon" class="circle"></img>
+                    <h4>GitHub</h4>
                 </div></a>
                 <a href="https://www.npmjs.com/~sv443" id="npm" rel="noopener" class="img-link" title="Sv443 on npm" target="_blank"><div class="list-item-container">
                     <img src="./resources/images/npm.webp" alt="npm icon" class="circle"></img>
@@ -153,13 +153,23 @@
         </div>
     </main>
     <footer>
+        <div id="cookie-consent">
+            <div>
+                <h3>This website uses cookies</h3>
+                <p>
+                    We use cookies to store site settings such as the theme.<br>
+                    Please accept the usage of cookies to enable these features.
+                </p>
+            </div>
+            <div id="consent-button" class="img-link" onclick="consentGranted();"><span>Accept Cookies</span></div>
+        </div>
         <div id="cloudflare">
             <a href="https://www.cloudflare.com" rel="noopener" class="img-link" target="_blank">
             <img src="./resources/images/cloudflare-light.svg" alt="Cloudflare icon" width="150px"></img>
             </a>
         </div>
         <div id="legal">
-            <h4><a id="privacypolicy" href="./privacypolicy_en" target="_blank">Privacy Policy</a> &bull; <a id="imprint" href="./imprint_en" target="_blank">Legal Information</a> &bull; <a id="license" href="./LICENSE" target="_blank">License</a></h4>
+            <h4><a id="privacypolicy" href="./privacypolicy/en" target="_blank">Privacy Policy</a> &bull; <a id="imprint" href="./imprint/en" target="_blank">Legal Information</a> &bull; <a id="license" href="./LICENSE" target="_blank">License</a></h4>
         </div>
     </footer>
     <div id="notif">

+ 136 - 89
js/index.js

@@ -46,29 +46,29 @@ let langValues = {
 };
 
 function otheronload() {
-    if (!Cookies.get("theme_pref")) {
-        setCookie("theme_pref", "light", 7);
-        theme.select("light");
-    } else if (Cookies.get("theme_pref") == "dark")
-        theme.select("dark");
-    else {
-        theme.select("light");
+    if (Cookies.get("cookie-consent") == "true") {
+        if (!Cookies.get("theme_pref")) {
+            setCookie("theme_pref", "light", 7);
+            theme.select("light");
+        } else if (Cookies.get("theme_pref") == "dark")
+            theme.select("dark");
+        else {
+            theme.select("light");
+        }
     }
 }
 
 function indexonload() {
     loadchanges();
-    if (Cookies.get("lang_pref") != "de" && Cookies.get("lang_pref") != "en") {
-        Cookies.remove("lang_pref");
-        reload();
-    }
-    if (!Cookies.get("theme_pref")) {
-        setCookie("theme_pref", "light", 7);
-        theme.select("light");
-    } else if (Cookies.get("theme_pref") == "dark")
-        theme.select("dark");
-    else {
-        theme.select("light");
+    if (Cookies.get("cookie-consent") == "true") {
+        if (!Cookies.get("theme_pref")) {
+            setCookie("theme_pref", "light", 7);
+            theme.select("light");
+        } else if (Cookies.get("theme_pref") == "dark")
+            theme.select("dark");
+        else {
+            theme.select("light");
+        }
     }
 
     if (window.location.search.substring(1).includes("epilepsy"))
@@ -86,87 +86,116 @@ function reload() {
 }
 
 function loadchanges() {
-    if (getLang() == "de") {
-        document.getElementById("privacypolicy").href = "./privacypolicy_de";
-        document.getElementById("imprint").href = "./imprint_de";
-
-        document.getElementById("github").title = langValues.de.github_title;
-        document.getElementById("npm").title = langValues.de.npm_title;
-        document.getElementById("itch").title = langValues.de.itch_title;
-        document.getElementById("twitter").title = langValues.de.twitter_title;
-        document.getElementById("email").title = langValues.de.email_title;
-        document.getElementById("discord").title = langValues.de.discord_title;
-        document.getElementById("jslib").title = langValues.de.svcorelib_title;
-        document.getElementById("langapplier").title = langValues.de.langapplier_title;
-        document.getElementById("ttp").title = langValues.de.ttp_title;
-        document.getElementById("skribbl").title = langValues.de.skribbl_title;
-        document.getElementById("jokeapi").title = langValues.de.jokeapi_title;
-        document.getElementById("textisland").title = langValues.de.text_island_title;
-        document.getElementById("gamestitle").innerHTML = langValues.de.games_title;
-        document.getElementById("flappyswitch").title = langValues.de.flappy_switch_title;
-        document.getElementById("langbtn").title = langValues.de.langbtn_title;
-        document.getElementById("notif").querySelector("h3").textContent = langValues.de.email_copied;
-        document.getElementById("privacypolicy").textContent = langValues.de.privacy_policy;
-        document.getElementById("imprint").textContent = langValues.de.imprint;
-    } else {
-        document.getElementById("privacypolicy").href = "./privacypolicy_en";
-        document.getElementById("imprint").href = "./imprint_en";
-
-        document.getElementById("github").title = langValues.en.github_title;
-        document.getElementById("npm").title = langValues.en.npm_title;
-        document.getElementById("itch").title = langValues.en.itch_title;
-        document.getElementById("twitter").title = langValues.en.twitter_title;
-        document.getElementById("email").title = langValues.en.email_title;
-        document.getElementById("discord").title = langValues.en.discord_title;
-        document.getElementById("jslib").title = langValues.en.svcorelib_title;
-        document.getElementById("langapplier").title = langValues.en.langapplier_title;
-        document.getElementById("ttp").title = langValues.en.ttp_title;
-        document.getElementById("skribbl").title = langValues.en.skribbl_title;
-        document.getElementById("jokeapi").title = langValues.en.jokeapi_title;
-        document.getElementById("textisland").title = langValues.en.text_island_title;
-        document.getElementById("gamestitle").innerHTML = langValues.en.games_title;
-        document.getElementById("flappyswitch").title = langValues.en.flappy_switch_title;
-        document.getElementById("langbtn").title = langValues.en.langbtn_title;
-        document.getElementById("notif").querySelector("h3").textContent = langValues.en.email_copied;
-        document.getElementById("privacypolicy").textContent = langValues.en.privacy_policy;
-        document.getElementById("imprint").textContent = langValues.en.imprint;
-    }
+    // if (getLang() == "de") {
+    //     document.getElementById("privacypolicy").href = "./privacypolicy_de";
+    //     document.getElementById("imprint").href = "./imprint_de";
+
+    //     document.getElementById("github").title = langValues.de.github_title;
+    //     document.getElementById("npm").title = langValues.de.npm_title;
+    //     document.getElementById("itch").title = langValues.de.itch_title;
+    //     document.getElementById("twitter").title = langValues.de.twitter_title;
+    //     document.getElementById("email").title = langValues.de.email_title;
+    //     document.getElementById("discord").title = langValues.de.discord_title;
+    //     document.getElementById("svcorelib").title = langValues.de.svcorelib_title;
+    //     document.getElementById("langapplier").title = langValues.de.langapplier_title;
+    //     document.getElementById("ttp").title = langValues.de.ttp_title;
+    //     document.getElementById("skribbl").title = langValues.de.skribbl_title;
+    //     document.getElementById("jokeapi").title = langValues.de.jokeapi_title;
+    //     document.getElementById("textisland").title = langValues.de.text_island_title;
+    //     document.getElementById("gamestitle").innerHTML = langValues.de.games_title;
+    //     document.getElementById("flappyswitch").title = langValues.de.flappy_switch_title;
+    //     document.getElementById("langbtn").title = langValues.de.langbtn_title;
+    //     document.getElementById("notif").querySelector("h3").textContent = langValues.de.email_copied;
+    //     document.getElementById("privacypolicy").textContent = langValues.de.privacy_policy;
+    //     document.getElementById("imprint").textContent = langValues.de.imprint;
+    // } else {
+    //     document.getElementById("privacypolicy").href = "./privacypolicy_en";
+    //     document.getElementById("imprint").href = "./imprint_en";
+
+    //     document.getElementById("github").title = langValues.en.github_title;
+    //     document.getElementById("npm").title = langValues.en.npm_title;
+    //     document.getElementById("itch").title = langValues.en.itch_title;
+    //     document.getElementById("twitter").title = langValues.en.twitter_title;
+    //     document.getElementById("email").title = langValues.en.email_title;
+    //     document.getElementById("discord").title = langValues.en.discord_title;
+    //     document.getElementById("svcorelib").title = langValues.en.svcorelib_title;
+    //     document.getElementById("langapplier").title = langValues.en.langapplier_title;
+    //     document.getElementById("ttp").title = langValues.en.ttp_title;
+    //     document.getElementById("skribbl").title = langValues.en.skribbl_title;
+    //     document.getElementById("jokeapi").title = langValues.en.jokeapi_title;
+    //     document.getElementById("textisland").title = langValues.en.text_island_title;
+    //     document.getElementById("gamestitle").innerHTML = langValues.en.games_title;
+    //     document.getElementById("flappyswitch").title = langValues.en.flappy_switch_title;
+    //     document.getElementById("langbtn").title = langValues.en.langbtn_title;
+    //     document.getElementById("notif").querySelector("h3").textContent = langValues.en.email_copied;
+    //     document.getElementById("privacypolicy").textContent = langValues.en.privacy_policy;
+    //     document.getElementById("imprint").textContent = langValues.en.imprint;
+    // }
 }
 
 function getLang() {
     var browserlang = navigator.language || navigator.userLanguage;
     if (Cookies.get("lang_pref"))
         return Cookies.get("lang_pref");
-    if (browserlang.includes("de")) {
-        setCookie("lang_pref", "de", 31);
-        return "de";
-    } else {
-        setCookie("lang_pref", "en", 31);
-        return "en";
+    if (Cookies.get("cookie-consent") == "true") {
+        if (browserlang.includes("de")) {
+            setCookie("lang_pref", "de", 31);
+            return "de";
+        } else {
+            setCookie("lang_pref", "en", 31);
+            return "en";
+        }
     }
+    return "en";
 }
 
 function switchLang() {
+    if (Cookies.get("cookie-consent") != "true") {
+        let notif = document.getElementById("notif");
+        document.getElementById("cookie-consent").style.display = "flex";
+        document.getElementById("cookie-consent").classList.add("fade-to-the-right");
+        notif.style.backgroundColor = "#F17E7E";
+        notif.style.color = "#931010";
+        notif.style.borderColor = "#EF6C6C";
+        notif.querySelector("h3").textContent = "Cookies need to be set to change the language";
+        notif.style.visibility = "visible";
+        notif.style.opacity = "1";
+        setTimeout(() => {
+            notif.style.opacity = "0";
+            notif.style.visibility = "hidden";
+        }, 2500);
+        return;
+    }
     var oldlang = getLang();
-    if (oldlang == "en")
-        setCookie("lang_pref", "de", 31);
-    if (oldlang == "de")
-        setCookie("lang_pref", "en", 31);
+    if (Cookies.get("cookie-consent") == "true") {
+        if (oldlang == "en")
+            setCookie("lang_pref", "de", 31);
+        if (oldlang == "de")
+            setCookie("lang_pref", "en", 31);
+    }
     reload();
 }
 
-const theme = new function () {
-    this.change = function () {
+const theme = {
+    change: function () {
+        if (Cookies.get("cookie-consent") != "true") {
+            document.getElementById("cookie-consent").style.display = "flex";
+            document.getElementById("cookie-consent").classList.add("fade-to-the-right");
+        }
         var oldtheme = document.body.dataset.theme;
         if (oldtheme == "dark") {
             var newtheme = "light";
+            document.getElementById("themebtn").title = "Switch to dark theme";
         } else {
             var newtheme = "dark";
+            document.getElementById("themebtn").title = "Switch to light theme";
         }
         theme.select(newtheme);
-    }
-    this.select = function (newtheme) {
-        setCookie("theme_pref", newtheme, 7);
+    },
+    select: function (newtheme) {
+        if (Cookies.get("cookie-consent") == "true") {
+            setCookie("theme_pref", newtheme, 7);
+        }
         if (newtheme == "dark") {
             if (document.getElementsByClassName("ph-moon")[0]) {
                 document.getElementsByClassName("ph-moon")[0].classList.add("ph-sun");
@@ -181,17 +210,35 @@ const theme = new function () {
             }
         }
         document.body.dataset.theme = newtheme;
-    }
-    this.epilepsy = function () {
+    },
+    epilepsy: function () {
         setInterval(theme.change, 250);
-    }
-    this.spooky = function () {
+    },
+    spooky: function () {
         document.body.dataset.theme = "spooky";
     }
 }
 
 function copyemail() {
-    var text = atob("Y29udGFjdEBzdjQ0My5uZXQ=");
+    var text = atob("Y29udGFjdEBzdjQ0My5uZXQ="); // anti crawler
+    copyText(text);
+
+    let notif = document.getElementById("notif");
+    notif.style.backgroundColor = "#cce5ff";
+    notif.style.color = "#004085";
+    notif.style.borderColor = "#b8daff";
+    notif.querySelector("h3").textContent = getLang() == "en" ? langValues.en.email_copied : langValues.de.email_copied;
+    notif.style.visibility = "visible";
+    notif.style.opacity = "1";
+
+    setTimeout(() => {
+        notif.style.opacity = "0";
+        notif.style.visibility = "hidden";
+    }, 2500);
+}
+
+function copyText(text)
+{
     var copyelem = document.createElement("textarea");
     copyelem.id = "copy";
     copyelem.innerHTML = text;
@@ -199,12 +246,6 @@ function copyemail() {
     document.getElementById("copy").select();
     document.execCommand("copy");
     copyelem.remove();
-    document.getElementById("notif").style.visibility = "visible";
-    document.getElementById("notif").style.opacity = "1";
-    setTimeout(() => {
-        document.getElementById("notif").style.opacity = "0";
-        document.getElementById("notif").style.visibility = "hidden";
-    }, 2000);
 }
 
 var donce = false;
@@ -251,3 +292,9 @@ function setCookie(key, value, expires) {
         SameSite: "Strict"
     })
 }
+
+function consentGranted() {
+    document.getElementById("cookie-consent").style.display = "none";
+    setCookie("cookie-consent", "true", 365);
+    setCookie("theme_pref", document.body.dataset.theme, 31);
+}

TEMPAT SAMPAH
resources/images/svcorelib.png


TEMPAT SAMPAH
resources/images/svcorelib.webp