civ/resources/questions/scenarios.js

34 lines
1,022 B
JavaScript
Raw Normal View History

2017-06-15 19:28:54 +00:00
window.onload = function(){
addScenario = function(scenario){
2017-06-15 19:28:54 +00:00
2017-06-15 23:16:00 +00:00
let $liElement = $("<li id=\"scenarios-"+scenario.name+"\"></li>")
if(scenario.adult == true){
$adultText = $("<p class=\"adult\">(question for those over the age of 18... or those mature enough)</p>");
$liElement.append($adultText);
}
$description = $("<p>" + scenario.description +"</p>");
2017-06-15 19:28:54 +00:00
$options = $("<ul></ul>");
for(option of scenario.options){
2017-06-15 23:16:00 +00:00
$options.append($("<li><input type=\"radio\" name=\"radio-"+scenario.name+"\">" + option + "</radio></li>"));
}
$question = $("<p>" + scenario.question + "</p>");
2017-06-15 19:28:54 +00:00
2017-06-15 23:16:00 +00:00
$textArea = $("<textArea placeholder=\"Enter response here\"></textArea>")
$liElement.append($description);
$liElement.append($options);
2017-06-15 23:16:00 +00:00
$liElement.append($textArea);
$("#scenarios").append($liElement);
}
2017-06-15 19:28:54 +00:00
$.getJSON("./resources/questions/scenarios.json", "", function(data){
for(const scenario of data.scenarios){
addScenario(scenario);
}
});
}