diff --git a/game.html b/game.html
index effbf01..159b4a0 100644
--- a/game.html
+++ b/game.html
@@ -5,6 +5,14 @@
+
+
EffortTapper
@@ -28,18 +36,188 @@
appId: "1:1000034285154:web:a6f1e84c5f4f2a236b033b",
};
- window.app = initializeApp(firebaseConfig);
-
- window.db = getDatabase(window.app);
+ const app = initializeApp(firebaseConfig);
+ window.db = getDatabase(app);
window.dbFunctions = {
ref,
set,
}
+
+ window.onload = () => {
+ const questions = [
+ {
+ label: "01. reserved",
+ question: "I see myself as someone who is reserved",
+ },
+ {
+ label: '02. trusting',
+ question: 'I see myself as someone who is generally trusting'
+ },
+ {
+ label: '03. lazy',
+ question: 'I see myself as someone who tends to be lazy '
+ },
+ {
+ label: '04. relaxed',
+ question: 'I see myself as someone who is relaxed, handles stress well'
+ },
+ {
+ label: '05. artistic',
+ question: 'I see myself as someone who has few artistic interests'
+ },
+ {
+ label: '06. outgoing',
+ question: 'I see myself as someone who is outgoing, sociable'
+ },
+ {
+ label: '07. others_fault',
+ question: 'I see myself as someone who tends to find fault with others'
+ },
+ {
+ label: '08. thorough_job',
+ question: 'I see myself as someone who does a thorough job'
+ },
+ {
+ label: '09. nervous',
+ question: 'I see myself as someone who gets nervous easily'
+ },
+ {
+ label: '10. imagination',
+ question: 'I see myself as someone who has an active imagination'
+ },
+ ];
+ const questionsLayout = questions
+ .map(
+ ({ label, question }, index) => ``
+ )
+ .join("");
+
+ document
+ .querySelector(".row.last")
+ .insertAdjacentHTML("beforebegin", questionsLayout);
+
+ const form = document.getElementById("myForm");
+ const submitButton = document.getElementById("submit");
+
+ const toggleButtonDisabled = () => {
+ const formData = new FormData(form);
+ const values = Object.fromEntries(formData);
+ if (Object.keys(values).length === questions.length)
+ submitButton.disabled = false;
+ };
+ form.addEventListener("input", toggleButtonDisabled);
+
+ const handleSubmit = (e) => {
+ e.preventDefault();
+ submitButton.style.display = "none";
+ const wait = document.createElement("div");
+ wait.innerHTML = "Wait...";
+ form.appendChild(wait);
+ const formData = new FormData(form);
+ const values = {};
+ formData.forEach(function (value, key) {
+ values[key] = value;
+ });
+ const urlParams = new URLSearchParams(window.location.search);
+ const id = urlParams.get("UUID");
+ if (id) {
+ set(ref(db, `${id}/questionnaire`), JSON.stringify(values))
+ .then(() => {
+ wait.innerHTML = "Thank you!";
+ })
+ .catch(() => {
+ wait.remove();
+ submitButton.style.display = "block";
+ });
+ }
+ };
+ form.addEventListener("submit", handleSubmit);
+ };
+
+
+
Thank you for participation
+
+
+
+
+
+