diff --git a/questions.html b/questions.html index 8567216..3a7d2da 100644 --- a/questions.html +++ b/questions.html @@ -78,41 +78,6 @@

Scenarios

More scenarios to come...

diff --git a/resources/questions/scenarios.js b/resources/questions/scenarios.js index 31baf1c..64da714 100644 --- a/resources/questions/scenarios.js +++ b/resources/questions/scenarios.js @@ -1,35 +1,34 @@ window.onload = function(){ - addScenario = function(object){ - $adultText = $("

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

"); - $description = $( - "

One of your friends is upset. Someone has been harrassing them, asking" - + "for innapropriate photos, constantly private messaging them without consent" - + "
(THEIR NAME IS FUCKING GIO)
" - + "Your friend is visibly uncomfortable, would would be your first action?

"); + addScenario = function(scenario){ + + let $liElement = $("
  • ") + + if(scenario.adult == true){ + $adultText = $("

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

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

    " + scenario.description +"

    "); $options = $(""); - $options.append($("
  • Try to listen to both sides, see what the other person has to say
  • ")); - $options.append($("
  • Go to the moderators, and report what happened.
  • ")); - $options.append($("
  • Try to cheer up your friend, diverting their attention to something else
  • ")); - $options.append($("
  • Listen to your friend, and reccommend some advice
  • ")); - $options.append($("
  • Other...
  • ")); - - $question = $("

    If this was happening to you, what would you choose instead?

    ") + for(option of scenario.options){ + $options.append($("
  • " + option + "
  • ")); + } + $question = $("

    " + scenario.question + "

    "); $input = $(""); - $liElement = $("
  • ") - $liElement.append($adultText); + $liElement.append($description); $liElement.append($options); $liElement.append($input); - console.table($liElement); $("#scenarios").append($liElement); } - $.getJSON("./resources/questions/scenarios.json", function(data){ - console.log(data); + $.getJSON("./resources/questions/scenarios.json", "", function(data){ + for(const scenario of data.scenarios){ + addScenario(scenario); + } }); -}; +} diff --git a/resources/sandbox/sandbox.js b/resources/sandbox/sandbox.js index b533423..1096de6 100644 --- a/resources/sandbox/sandbox.js +++ b/resources/sandbox/sandbox.js @@ -1,63 +1,58 @@ -/* AJAX Tutorial, By The Net Ninja -https://www.youtube.com/watch?v=h0ZUpPiV1ac -*/ +//AJAX request method +updateCell = function(path, pageType, requestType){ + path = path.toLowerCase(); + const $element = $("#hello-" + path); + $.ajax({ + type: requestType, //GET or POST + url: "https://server.figytuna.com:8080/ali/hello/" + path, + timeout: 2000, //ms + beforeSend: function(data){ + $element.html("Loading..."); + }, + success: function(data){ + if (pageType == "html"){ + $element.html($data); + }else{ + $element.text($data); + } + }, + error: function(e){ + $("#hello-" + path).html("Error " + e.status + " " + e.statusText + ""); + } + }); +} window.onload = function(){ - - const serverPath = "https://server.figytuna.com:8080/ali/hello/"; - const pages = { - "unsafe": [ - "World", - "Data", - "Post" - ], - "html":[ - "Location", - "Players", - ] + const pageList = { + "unsafe": ["World", "Data", "Post"], + "html": ["Location", "Players"], } - //Generate HTML table - for (const pageType in pages){ - for (const pagePath of pages[pageType]){ - //Adds new table row based on the data request - const $newTableRow = $("" - + "Hello " + pagePath + "" - + "" - + ""); - console.log(pagePath + " added"); + //Generate HTML table + for (const pageType in pageList){ + for (const path of pageList[pageType]){ + //Adds new table row based on the data request + const $row = $(""); + const $request = $("Hello " + path + ""); + const $response = $("") + + $row.append($request); + $row.append($response); + //Appends new table row to table - $("#hello-table").append($newTableRow); + $("#hello-table").append($row); } } - - dataRequest = function(pagePath, pageType, requestType){ - $.ajax({ - type: requestType, - url: serverPath + pagePath.toLowerCase(), - timeout: 2000, - beforeSend: function(data){ - $("#hello-" + pagePath.toLowerCase()).html("Loading..."); - }, - success: function(data){ - $element = $("#hello-" + pagePath.toLowerCase()) - if (pageType == "html"){ - $element.html($data); - }else{ - $element.text($data); - } - }, - error: function(e){ - $("#hello-" + pagePath.toLowerCase()).html("Error " + e.status + " " + e.statusText + ""); - } - }); - } - //Gets Table data from server - for (const pagePath of pages["html"]){ - dataRequest(pagePath, "safe", "GET"); + //Populate Table Data + for (const id of pageList["html"]){ + //Gets data from server, adds response to table + updateCell(id, "safe", "GET"); } - for (const pagePath of pages["unsafe"]){ - dataRequest(pagePath, "unsafe", "GET"); + for (const id of pageList["unsafe"]){ + //Gets data from server, adds response to table + updateCell(id, "unsafe", "GET"); } + + } diff --git a/sandbox.html b/sandbox.html index 387be69..3072ef1 100644 --- a/sandbox.html +++ b/sandbox.html @@ -18,8 +18,13 @@

    Developer's Sandbox

    - +

    ATOM Live Server Stuff

    + + + + + +
    Data RequestsData Responses

    ButtonPresents Stuff