diff options
author | RaindropsSys <raindrops@equestria.dev> | 2024-06-19 22:14:29 +0200 |
---|---|---|
committer | RaindropsSys <raindrops@equestria.dev> | 2024-06-19 22:14:29 +0200 |
commit | 38cb58bbbbe834662adf6e8eca03846907ea837e (patch) | |
tree | edae59f2c570703a67c443c69799a8c799b530e2 | |
download | likeme-38cb58bbbbe834662adf6e8eca03846907ea837e.tar.gz likeme-38cb58bbbbe834662adf6e8eca03846907ea837e.tar.bz2 likeme-38cb58bbbbe834662adf6e8eca03846907ea837e.zip |
Initial commit
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .idea/.gitignore | 5 | ||||
-rw-r--r-- | .idea/discord.xml | 12 | ||||
-rw-r--r-- | .idea/inspectionProfiles/Project_Default.xml | 14 | ||||
-rw-r--r-- | .idea/jsLibraryMappings.xml | 6 | ||||
-rw-r--r-- | .idea/likeme.iml | 9 | ||||
-rw-r--r-- | .idea/modules.xml | 8 | ||||
-rw-r--r-- | .idea/php.xml | 13 | ||||
-rw-r--r-- | index.html | 198 |
9 files changed, 266 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e985853 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vercel diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..3aef922 --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="DiscordProjectSettings"> + <option name="show" value="PROJECT_FILES" /> + <option name="description" value="" /> + <option name="theme" value="material" /> + <option name="button1Title" value="" /> + <option name="button1Url" value="" /> + <option name="button2Title" value="" /> + <option name="button2Url" value="" /> + </component> +</project>
\ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..37308ce --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,14 @@ +<component name="InspectionProjectProfileManager"> + <profile version="1.0"> + <option name="myName" value="Project Default" /> + <inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false" /> + <inspection_tool class="PyPep8Inspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" /> + <inspection_tool class="PyPep8NamingInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" /> + <inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="INFORMATION" enabled_by_default="true" /> + <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false"> + <option name="processCode" value="true" /> + <option name="processLiterals" value="true" /> + <option name="processComments" value="true" /> + </inspection_tool> + </profile> +</component>
\ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..23f5a6d --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="JavaScriptLibraryMappings"> + <file url="PROJECT" libraries="{bootstrap-icons}" /> + </component> +</project>
\ No newline at end of file diff --git a/.idea/likeme.iml b/.idea/likeme.iml new file mode 100644 index 0000000..b30cbe7 --- /dev/null +++ b/.idea/likeme.iml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="WEB_MODULE" version="4"> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$" /> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="bootstrap-icons" level="application" /> + </component> +</module>
\ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..bf59198 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/likeme.iml" filepath="$PROJECT_DIR$/.idea/likeme.iml" /> + </modules> + </component> +</project>
\ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..88cd1bc --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="MessDetectorOptionsConfiguration"> + <option name="transferred" value="true" /> + </component> + <component name="PHPCSFixerOptionsConfiguration"> + <option name="transferred" value="true" /> + </component> + <component name="PHPCodeSnifferOptionsConfiguration"> + <option name="highlightLevel" value="WARNING" /> + <option name="transferred" value="true" /> + </component> +</project>
\ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..1d20c11 --- /dev/null +++ b/index.html @@ -0,0 +1,198 @@ +<!DOCTYPE html> +<html lang="en" data-bs-theme="dark"> +<head> + <meta charset="UTF-8"> + <title>How Starscouts are you?</title> + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> + <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet" integrity="sha384-XGjxtQfXaH2tnPFa9x+ruJTuLE3Aa6LhHSWRr1XeTyhezb4abCG4ccI5AkVDxqC+" crossorigin="anonymous"> +</head> +<body> + <div class="container" style="margin-top: 3rem; margin-bottom: 3rem;"> + <div class="card" style="max-width: 36rem; margin-left: auto; margin-right: auto;"> + <div class="card-body"> + <span class="text-muted" id="header">Welcome</span> + <i class="bi-house-door" id="main-icon" style="font-size: 48px;display: block;margin-left: auto;margin-right: auto;width: max-content;"></i> + <h3 style="text-align: center;" id="title">How Starscouts are you?</h3> + + <hr> + <div id="home"> + <p>Ever wondered how similar to Starscouts you are? (no, you have not)</p> + <p>Answer a few questions to get a result right away, so you can brag about how close to 100% you are.</p> + <p>This is just a fun project with no consequences whatsoever, so have fun!</p> + + <div style="text-align: center;"> + <span class="btn btn-primary disabled" onclick="privacy();" id="start-btn">Start!</span> + </div> + + <noscript> + <style> + #start-btn { + display: none; + } + </style> + <div class="alert alert-danger" style="margin-bottom: 0;"><b>Error:</b> JavaScript is disabled on your browser. Enable JavaScript and refresh the page.</div> + </noscript> + </div> + <div id="privacy" style="display: none;"> + <p>This website asks you to answer questions that can reach into personal territory.</p> + <p>To make sure this project stays fun, all the data you enter on this website is processed locally, on your own device, + and is never sent to any server, ever. The source code for this website is + <a target="_blank" href="https://github.com/equestria-dev/likeme">publicly available</a>, and if you are really paranoid, you can disconnect + from the internet from this point forward.</p> + <p>Do note, though, that your final results will be saved on your device's internal storage. + They will never be sent to a server (at least not without your consent) and you can delete them at any time.</p> + + <div style="text-align: center;"> + <span class="btn btn-primary" onclick="start();">Continue</span> + <span class="btn btn-outline-primary" onclick="location.reload();">I don't agree</span> + </div> + </div> + <div id="questions" style="display: none;"> + <div id="answers" style="display: grid; grid-template-columns: 1fr 1fr; grid-gap: 5px;"></div> + </div> + <div id="results" style="display: none;"> + <p>That's how similar to Starscouts you are. But don't fret! Any score is good. What matters is that you are + yourself, everyone is unique in their own ways and that's what matters.</p> + <p>Did you like this? Let Starscouts know!</p> + <div style="text-align: center;"> + <span class="btn btn-outline-primary" onclick="if (confirm('Are you sure you want to delete ALL the local data associated with this website? This includes your previous scores that could potentially be shared for a leaderboard in a future version.')) { localStorage.clear(); location.reload(); }">Delete local data</span> + </div> + </div> + </div> + </div> + </div> + <div class="text-muted" style="text-align: center;">© 2024 The Starscouts, Equestria.dev Developers, All rights reserved.<br>All data is processed on-device, period.<br><br>Update: June 19th, 2024</div> + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> + + <!--suppress JSCheckFunctionSignatures --> + <script> + window.enableErrorChecks = true; + + window.onerror = (_1, _2, _3, _4, _5) => { + console.error(_1, _2, _3, _4, _5); + document.head.innerText = ""; + document.body.innerText = "An error has occurred while loading the page. Error code: 0xFFBADBAD"; + } + + window.onload = () => { + (async () => { + try { + window.questions = (await (await fetch("./questions.txt")).text()).trim().split("\n").map(i => { + i = i.split("|"); + return { + depends: !i[0].startsWith("-") ? parseInt(i[0]) - 1 : null, + name: i[1], + answers: i.slice(2) + } + }); + } catch (e) { + document.head.innerText = ""; + document.body.innerText = "An error has occurred while loading the page. Error code: 0xBAD0DA7A"; + } + + window.answers = []; + + document.getElementById("start-btn").classList.remove("disabled"); + })(); + } + + function privacy() { + document.getElementById("home").style.display = "none"; + document.getElementById("privacy").style.display = ""; + document.getElementById("main-icon").className = "bi-shield"; + document.getElementById("title").innerText = "A word about privacy"; + } + + function start() { + displayQuestion(0); + } + + function shuffle(array) { + let currentIndex = array.length, temporaryValue, randomIndex; + + while (0 !== currentIndex) { + randomIndex = Math.floor(Math.random() * currentIndex); + currentIndex -= 1; + + temporaryValue = array[currentIndex]; + array[currentIndex] = array[randomIndex]; + array[randomIndex] = temporaryValue; + } + + return array; + } + + function countCorrect() { + window.answers.push(true); + } + + function countIncorrect() { + window.answers.push(false); + } + + function displayQuestion(i) { + if (i >= questions.length) { + displayResults(); + return; + } + + if (questions[i].depends !== null && !answers[questions[i].depends]) { + while (questions[i].depends !== null && !answers[questions[i].depends]) { + countIncorrect(); + i++; + + if (i >= questions.length) { + displayResults(); + return; + } + } + + displayQuestion(i); + return; + } + + let question = questions[i]; + document.getElementById("questions").style.display = ""; + document.getElementById("privacy").style.display = "none"; + document.getElementById("main-icon").className = "bi-ui-radios"; + document.getElementById("title").innerText = question.name; + document.getElementById("header").innerText = "Question " + (i + 1) + "/" + questions.length; + document.getElementById("answers").innerHTML = shuffle(question.answers.map((j, k) => ` + <span class="btn btn-primary" onclick="count${k === 0 ? "Correct" : "Incorrect"}(); displayQuestion(${i + 1});">${j}</span> + `)).join(""); + } + + function displayResults() { + let score = (answers.filter(i => i === true).length / answers.length) * 100; + let data = JSON.parse(localStorage.getItem("scores") ?? "[]"); + data.push(score); + localStorage.setItem("scores", JSON.stringify(data)); + + document.getElementById("questions").style.display = "none"; + document.getElementById("results").style.display = ""; + document.getElementById("main-icon").className = "bi-award"; + document.getElementById("title").innerText = score.toFixed(2) + "%"; + document.getElementById("header").innerText = "Results"; + } + + function _cheat() { + if (location.hostname === "localhost" && enableErrorChecks) return; + document.head.innerText = ""; + document.body.innerText = "An error has occurred while loading the page. Error code: 0x0C4EA7E6"; + localStorage.setItem("WW91IGFyZSBhIGNoZWF0ZXIuCg==", btoa(crypto.getRandomValues(new Uint8Array(32)))); + } + + setInterval(() => { + if (location.hostname === "localhost" && enableErrorChecks) return; + let s1 = new Date().getTime(); + debugger; + let s2 = new Date().getTime(); + if (s2 - s1 > 10) _cheat(); + }); + + if (localStorage.getItem("WW91IGFyZSBhIGNoZWF0ZXIuCg==")) { + _cheat(); + } + </script> +</body> +</html> |