diff --git a/resources/questions/scenarios.js b/resources/questions/scenarios.js index 1b13ae7..8981930 100644 --- a/resources/questions/scenarios.js +++ b/resources/questions/scenarios.js @@ -2,45 +2,48 @@ window.onload = function(){ makeScenario = function(scenario){ - //output element, that other elements are attached to + //Create output Element let $trueOutputElement = $("
  • ") $trueOutputElement.attr("id", `scenarios-${scenario.name}`); - let $outputElement = $("
    ") - //Determines whether this is a jQuery Accordion + + //Create Control Element const isAccordion = true; if(isAccordion){ $controlElement = $(""); - $controlElement.addClass("accordion-control"); - $controlElement.append(scenario.name); + .addClass("accordion-control"); + .append(scenario.name); + $trueOutputElement.append($controlElement); } + //Mature Content rating if(scenario.adult == true){ - $adultText = $("

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

    "); - $adultText.addClass("adult"); + $adultText = $("

    )

    "); + .addClass("adult"); + .append(`(question for those over the age of 18... or those mature enough)`) $outputElement.append($adultText); $outputElement.addClass("adult-scenario"); } //description - $descriptionElement = $("

    " + scenario.description +"

    "); + $descriptionElement = $(`

    ${scenario.description}

    `); //option list $optionElement = $(""); for(option of scenario.options){ //Create radio button - $inputTag = $(""); - $inputTag.attr("type", "radio"); - $inputTag.attr("name", `radio-${scenario.name}`); + $inputTag = $("") + .attr("type", "radio") + .attr("name", `radio-${scenario.name}`); //Populate list element - $newOption = $("
  • "); - $newOption.append($inputTag); - $newOption.append(option); - $optionElement.append($newOption); + $newOption = $("
  • ") + .append($inputTag) + .append(option) + .append($newOption); } //Other Question @@ -64,18 +67,19 @@ window.onload = function(){ //Extra Question if(scenario.question){ - $question = $("

    " + scenario.question + "

    "); - $questionResponse = $(""); - $questionResponse.attr("placeholder", "Enter response here"); + $question = $("

    " + scenario.question + "

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

    ")); $outputElement.append($submitElement); diff --git a/resources/spawn/progress-table.js b/resources/spawn/progress-table.js index 905572e..e4a70ac 100644 --- a/resources/spawn/progress-table.js +++ b/resources/spawn/progress-table.js @@ -1,13 +1,17 @@ window.onload = function(){ const addRow = function(building){ + + //Populate First table cell: Building Name $nameElement = $("") .attr("id", `${building.id}-progress.name`) .append(building.name); + //Populate table cell: Use $useElement = $("") .attr("id", `${building.id}-progress.use`) .append(building.use) + //Populate table cell: Designed $designedElement = $("") .attr("id", `${building.id}-progress.designed`) .addClass("checkboxCell") @@ -16,6 +20,7 @@ window.onload = function(){ .attr("id", `${building.id}.designed?`) .attr("checked", building.designed)); + //Populate table cell: Started $startedElement = $("") .attr("id", `${building.id}-progress.stated`) .addClass("checkboxCell") @@ -24,6 +29,7 @@ window.onload = function(){ .attr("id", `${building.id}.started?`) .attr("checked", building.started)); + //Populate table cell: Completed $completedElement = $("") .attr("id", `${building.id}-progress.completed`) .addClass("checkboxCell") @@ -32,6 +38,7 @@ window.onload = function(){ .attr("id", `${building.id}.completed?`) .attr("checked", building.completed)); + //Populate table cell: Populated $populatedElement = $("") .attr("id", `${building.id}-progress.populated`) .addClass("checkboxCell") @@ -40,7 +47,7 @@ window.onload = function(){ .attr("id", `${building.id}.populated?`) .attr("checked", building.populated)); - + //Create entire row, appending all elements $outputRow = $("") .attr("id", `${building.id}-progress`) .append($nameElement) @@ -49,6 +56,8 @@ window.onload = function(){ .append($startedElement) .append($completedElement) .append($populatedElement); + + //return the entire row return $outputRow; } console.info("loading");