diff --git a/questions.html b/questions.html index 3a7d2da..a714ad9 100644 --- a/questions.html +++ b/questions.html @@ -31,7 +31,7 @@
  • Date of Birth
  • Gender
    -
  • +
  • Where did you find our server?
  • What made you interested in us?
    @@ -46,6 +46,8 @@
  • Have you heard of /r/place?
  • + +

    What Questions

    diff --git a/resources/questions/scenarios.js b/resources/questions/scenarios.js index 09ac6cf..b0480ce 100644 --- a/resources/questions/scenarios.js +++ b/resources/questions/scenarios.js @@ -1,44 +1,80 @@ window.onload = function(){ - addScenario = function(scenario){ + makeScenario = function(scenario){ - let $liElement = $("
  • ") + //output element, that other elements are attached to + let $outputElement = $("
  • ") + $outputElement.attr("id", "scenarios-"+scenario.name); + //Mature Content rating if(scenario.adult == true){ - $adultText = $("

    (question for those over the age of 18... or those mature enough)

    "); - $liElement.append($adultText); - } - $description = $("

    " + scenario.description +"

    "); + $adultText = $("

    (question for those over the age of 18... or those mature enough)

    "); + $adultText.addClass("adult"); - $options = $(""); + $outputElement.append($adultText); + $outputElement.addClass("adult-scenario"); + } + + //description + $descriptionElement = $("

    " + scenario.description +"

    "); + + //option list + $optionElement = $(""); for(option of scenario.options){ - $options.append($("
  • " + option + "
  • ")); + //Create radio button + $inputTag = $(""); + $inputTag.attr("type", "radio"); + $inputTag.attr("name", "radio-"+scenario.name); + + //Populate list element + $newOption = $("
  • "); + $newOption.append($inputTag); + $newOption.append(option); + $optionElement.append($newOption); + } + //Other Question if (scenario.other){ - $options.append("
  • Other...
  • "); + $otherElement = $("
  • Other...
  • "); + $optionElement.append($otherElement); } - $why = $("

    Why would you choose this awnser?

    "); - $whyResponse = $("") + //Default question, always shows up + $whyElement = $("

    Why would you choose this awnser?

    "); - $liElement.append($description); - $liElement.append($options); - $liElement.append($why); - $liElement.append($whyResponse); + //Awnser space for the default element + $whyResponseElement = $("") + $whyResponseElement.attr("placeholder", "Enter response here"); + //Populate outputElement + $outputElement.append($descriptionElement); + $outputElement.append($optionElement); + $outputElement.append($whyElement); + $outputElement.append($whyResponseElement); + + //Extra Question if(scenario.question){ $question = $("

    " + scenario.question + "

    "); - $questionResponse = $("") - $liElement.append($question); - $liElement.append($questionResponse); + $questionResponse = $(""); + $questionResponse.attr("placeholder", "Enter response here"); + + $outputElement.append($question); + $outputElement.append($questionResponse); } - $("#scenarios").append($liElement); + //Submission button + $submitElement = $(""); + $submitElement.attr("type", "submit"); + $submitElement.append("Submit"); + $outputElement.append($("

    ")); + $outputElement.append($submitElement); + + return $outputElement; } $.getJSON("./resources/questions/scenarios.json", "", function(data){ for(const scenario of data.scenarios){ - addScenario(scenario); + $("#scenarios").append(makeScenario(scenario)); } }); } diff --git a/resources/questions/scenarios.json b/resources/questions/scenarios.json index 6f3e463..12d021d 100644 --- a/resources/questions/scenarios.json +++ b/resources/questions/scenarios.json @@ -1,7 +1,7 @@ { "scenarios": [ { - "name": "base raid", + "name": "base-raid", "description": "You find your base raided: All of your stuff is missing, chests are empty. What would be your first action?", "options": [ @@ -15,7 +15,7 @@ "other": true }, { - "name": "Rule 1", + "name": "rule-1", "description": "Someone is breaking Rule #1 and well... being a dick. They are angry about (having their base raided/being harrassed by another member/their family treating them unfairly/griefers destroying their base), and are swearing, insulting people, and generally making chat a negative enviornment. What is your first action?", "options":[ @@ -30,7 +30,7 @@ "other": true }, { - "name": "Harrassment", + "name": "harrassment", "description": "One of your friends is upset. Someone has been harrassing them, asking for innapropriate pictures, constantly private messaging them without their consent.
    Your friend is visibly uncomfortable, what would be your first action?", "options":[