From 2843bd804a9d31a41d2980ed33c87e0888828570 Mon Sep 17 00:00:00 2001 From: Pavel Tsurbeleu Date: Tue, 15 Sep 2015 00:52:15 -0700 Subject: [PATCH 001/149] add an assertion to ensure well-formed img elements in waypoint-make-images-mobile-responsive challenge, closes #1021 --- seed/challenges/bootstrap.json | 1 + 1 file changed, 1 insertion(+) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index fb4f864474..35b7a02321 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -97,6 +97,7 @@ ], "tests": [ "assert($(\"img\").length > 1, 'You should have a total of two images.')", + "assert(editor.match(//g).length === 2 && editor.match(/img element has a closing angle bracket.')", "assert($(\"img\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')", "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Add a second image with the src of http://bit.ly/fcc-running-cats.')" ], From 165cb41080443f0f061185c6fb5a87f22c16bcd1 Mon Sep 17 00:00:00 2001 From: Pavel Tsurbeleu Date: Wed, 16 Sep 2015 18:04:37 -0700 Subject: [PATCH 002/149] fix count img elements assertion in waypoint-make-images-mobile-responsive challenge to be strict --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index 35b7a02321..f953d8e58a 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -96,7 +96,7 @@ "Fortunately, with Bootstrap, all we need to do is add the img-responsive class to your image. Do this, and the image should perfectly fit the width of your page." ], "tests": [ - "assert($(\"img\").length > 1, 'You should have a total of two images.')", + "assert($(\"img\").length === 2, 'You should have a total of two images.')", "assert(editor.match(//g).length === 2 && editor.match(/img element has a closing angle bracket.')", "assert($(\"img\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')", "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Add a second image with the src of http://bit.ly/fcc-running-cats.')" From be373787831a45bfce00b92ab70e35dc4f5cd676 Mon Sep 17 00:00:00 2001 From: Pavel Tsurbeleu Date: Wed, 16 Sep 2015 18:10:16 -0700 Subject: [PATCH 003/149] fix wording of src attribute assertion's message to be consistent with other messages in waypoint-make-images-mobile-responsive challenge --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index f953d8e58a..bfc812b897 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -99,7 +99,7 @@ "assert($(\"img\").length === 2, 'You should have a total of two images.')", "assert(editor.match(//g).length === 2 && editor.match(/img element has a closing angle bracket.')", "assert($(\"img\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')", - "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Add a second image with the src of http://bit.ly/fcc-running-cats.')" + "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Your new image should have a src attribute of http://bit.ly/fcc-running-cats.')" ], "challengeSeed": [ "", From 8424fef76f62b65b8e8a71bd49561ed9160ccb85 Mon Sep 17 00:00:00 2001 From: Arsen Melikyan Date: Sat, 19 Sep 2015 15:58:58 +0400 Subject: [PATCH 004/149] adds a switch case to highlight bonfires' code in GitHub issues --- client/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/main.js b/client/main.js index 36aa44fe8c..7e56054143 100644 --- a/client/main.js +++ b/client/main.js @@ -130,6 +130,7 @@ $(document).ready(function() { type = 'html'; break; case challengeTypes.JAVASCRIPT: + case challengeTypes.BONFIRE: type = 'javascript'; break; default: From 4c48547b0d160b90531a9fa1e2f6bc17723a67fc Mon Sep 17 00:00:00 2001 From: Joel Bentley Date: Sat, 19 Sep 2015 14:50:54 -0400 Subject: [PATCH 005/149] Fix test on Waypoint Create Unordered List --- seed/challenges/html5-and-css.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/html5-and-css.json b/seed/challenges/html5-and-css.json index 8f5f48cbec..fcfe7314b7 100644 --- a/seed/challenges/html5-and-css.json +++ b/seed/challenges/html5-and-css.json @@ -1434,7 +1434,7 @@ "assert($(\"ul\").length > 0, 'Create a ul element.')", "assert($(\"ul li\").length > 2, 'You should have three li elements within your ul element.')", "assert(editor.match(/<\\/ul>/g) && editor.match(/
    /g).length === editor.match(/
      ul element has a closing tag.')", - "assert(editor.match(/<\\/li>/g) && editor.match(/
    • /g) && editor.match(/<\\/li>/g).length === editor.match(/
    • /g).length, 'Make sure your li element has a closing tag.')" + "assert(editor.match(/<\\/li>/g) && editor.match(/]/g) && editor.match(/<\\/li>/g).length === editor.match(/]/g).length, 'Make sure your li elements have closing tags.')" ], "challengeSeed": [ "", From 12ef390288288670374a2219dbaf338a85165b5d Mon Sep 17 00:00:00 2001 From: Arsen Melikyan Date: Sun, 20 Sep 2015 00:42:01 +0400 Subject: [PATCH 006/149] new test checks if all elements are nested in container-fluid --- seed/challenges/bootstrap.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index fb4f864474..2e83b66f8d 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -14,8 +14,9 @@ "To get started, we should nest all of our HTML in a div element with the class container-fluid." ], "tests": [ - "assert($(\"div\").hasClass(\"container-fluid\"), 'Your div element should have the class container-fluid')", - "assert(editor.match(/<\\/div>/g) && editor.match(/
      /g).length === editor.match(/
      div elements has a closing tag.')" + "assert($(\"div\").hasClass(\"container-fluid\"), 'Your div element should have the class container-fluid.')", + "assert(editor.match(/<\\/div>/g) && editor.match(/
      /g).length === editor.match(/
      div elements has a closing tag.')", + "assert($(\".container-fluid\").children().length >= 8, 'Make sure you have nested all HTML elements in .container-fluid.')" ], "challengeSeed": [ "", From 0a455fcd9231d2a13374380be6722d71a1f53d6b Mon Sep 17 00:00:00 2001 From: Aniruddh Agarwal Date: Fri, 18 Sep 2015 15:31:25 +0800 Subject: [PATCH 007/149] Fixes basic bonfire's permissive test --- seed/challenges/basic-bonfires.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json index cbcdbd1b83..a5df1ea9ec 100644 --- a/seed/challenges/basic-bonfires.json +++ b/seed/challenges/basic-bonfires.json @@ -313,7 +313,7 @@ "tests": [ "assert(end(\"Bastian\", \"n\") === true, '\"Bastian\", \"n\" should return true.');", "assert(end(\"Connor\", \"n\") === false, '\"Connor\", \"n\" should return false.');", - "assert(end(\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") === false, '\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") should return false.');", + "assert(end(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") === false, '\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") should return false.');", "assert(end(\"He has to give me a new name\", \"name\") === true, '\"He has to give me a new name\", \"name\" should return true.');", "assert(end(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") === false, '\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\" should return false.');" ], From 182960af04cd8b65ff47aafe735a3c27b1120cfc Mon Sep 17 00:00:00 2001 From: Joel Bentley Date: Sun, 20 Sep 2015 15:52:54 -0400 Subject: [PATCH 008/149] Fix tests on Waypoint Mobile Responsive Images --- seed/challenges/bootstrap.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index fb4f864474..d56663a44d 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -97,8 +97,8 @@ ], "tests": [ "assert($(\"img\").length > 1, 'You should have a total of two images.')", - "assert($(\"img\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')", - "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Add a second image with the src of http://bit.ly/fcc-running-cats.')" + "assert($(\"img:eq(1)\").attr(\"src\") === \"http://bit.ly/fcc-running-cats\", 'Your new image should have an src of http://bit.ly/fcc-running-cats.')", + "assert($(\"img:eq(1)\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')" ], "challengeSeed": [ "", From e0df3171f42d67c5648f1274cb212ec6d8cad350 Mon Sep 17 00:00:00 2001 From: Rich Churcher Date: Mon, 21 Sep 2015 08:34:22 +1200 Subject: [PATCH 009/149] Make plain that the array is not already sorted. --- seed/challenges/basic-bonfires.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seed/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json index cbcdbd1b83..e537eda1e6 100644 --- a/seed/challenges/basic-bonfires.json +++ b/seed/challenges/basic-bonfires.json @@ -613,8 +613,9 @@ "title": "Where do I belong", "difficulty": "1.61", "description": [ - "Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).", - "For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (0th index), but less than 2 (1st index).", + "Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.", + "For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1).", + "Likewise, where([20,3,5], 19) should return 2 because it is less than 20 (index 2) and greater than 5 (index 1).", "Remember to use Read-Search-Ask if you get stuck. Write your own code." ], "challengeSeed": [ From 82605bbcb06f7a76be2596acd7c2da7ea6c41a8b Mon Sep 17 00:00:00 2001 From: Joel Bentley Date: Sun, 20 Sep 2015 16:48:09 -0400 Subject: [PATCH 010/149] Fix test on Waypoint Use Comments to Clarify Code --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index fb4f864474..9c6d924f41 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -2141,7 +2141,7 @@ "tests": [ "assert(editor.match(//g) && editor.match(/-->/g).length > 0, 'Be sure to close your comment with -->.')" + "assert(editor.match(/-->.*\\n.+/g), 'Be sure to close your comment with -->.')" ], "challengeSeed": [ "
      ", From d9d558a8a9c2b03f01882d60cc646c3d1b57e61d Mon Sep 17 00:00:00 2001 From: ahstro Date: Mon, 21 Sep 2015 23:10:13 +0200 Subject: [PATCH 011/149] Slot Machine false positives The 'Add your JavaScript Slot Machine Slots' waypoint would throw false positives if all slot numbers were the same, effectively allowing the campers to pass the test without having written any code. --- seed/challenges/basic-javascript.json | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index e3542ee41d..53cc76410b 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1302,7 +1302,7 @@ "}" ], "tests":[ - "assert((function(){var data = runSlots();if(data === null){return true}else{if(data[0] === data[1] && data[1] === data[2]){return true;}else{return false;}}})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return null.')" + "assert((function(){var data = runSlots();return data === null || data.toString().length === 1;})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return null.')" ], "challengeSeed":[ "fccss", @@ -1485,9 +1485,10 @@ " ", " // Only change code above this line.", " ", - " if(slotOne !== slotTwo || slotTwo !== slotThree){", - " return null;", + " if(slotOne === slotTwo && slotTwo === slotThree){", + " return slotOne;", " }", + " return null;", " ", " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", " $(\".logger\").html(slotOne);", @@ -1655,9 +1656,10 @@ " ", " // Only change code above this line.", " ", - " if(slotOne !== slotTwo || slotTwo !== slotThree){", - " return null;", + " if(slotOne === slotTwo && slotTwo === slotThree){", + " return slotOne;", " }", + " return null;", " ", " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", " $('.logger').html(slotOne);", From a75db9c7f2f9490424de7d92e6a93f711a34c35f Mon Sep 17 00:00:00 2001 From: Joel Bentley Date: Wed, 23 Sep 2015 18:21:16 -0400 Subject: [PATCH 012/149] Modify test to allow for blank line after comment --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index 9c6d924f41..927f17a6fa 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -2141,7 +2141,7 @@ "tests": [ "assert(editor.match(/.*\\n.+/g), 'Be sure to close your comment with -->.')" + "assert(editor.match(/-->.*\\n+.+/g), 'Be sure to close your comment with -->.')" ], "challengeSeed": [ "
      ", From e2459fa869f3c05cf659b2cb41d0f7bdd1aadec6 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Mon, 28 Sep 2015 23:24:42 +0100 Subject: [PATCH 013/149] Foundation fo AJAX stuff is done. Going to move on to process fetched data and creating a UI generating function for each individual object --- seed/challenges/json-apis-and-ajax.json | 116 ++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 seed/challenges/json-apis-and-ajax.json diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json new file mode 100644 index 0000000000..8ece73714b --- /dev/null +++ b/seed/challenges/json-apis-and-ajax.json @@ -0,0 +1,116 @@ +{ + "name": "JSON APIs and Ajax", + "order": 0.0065, + "challenges": [ + { + "id": "bad87fed1348bd9aeca08826", + "title": "Trigger on click Events with jQuery", + "difficulty": 3.19, + "description": [ + "With jQuery we are able to get data from APIs via Ajax", + "This data normally comes in the form of JSON", + "Let's get the Get Message button to set the text of a div", + "We will later use this to display the result of out API request", + "$(\"#getMessage\").on(\"click\", function(){", + "  $(\".message\").html(\"Here is the message\");", + "});" + ], + "tests": [ + "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\#getMessage(?:'|\")\\s*?\\)\\s*?\\.on\\s*?\\(\\s*?(?:'|\")click(?:'|\")\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have bound the click event to the getMessage button')", + "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\.message(?:'|\")\\s*?\\)\\s*?\\.html\\s*?\\(\\s*?(?:'|\")Here\\sis\\sthe\\smessage(?:'|\")\\s*?\\);/gi), 'You should set te value of the #message box to be the message given in the description')", + "assert(editor.match(/\\n*?\\s*?\\}\\n*?\\s*?\\);/gi) && editor.match(/\\n*?\\s*?\\}\\);/gi).length >= 2, 'Make sure that you close off all of your functions')" + ], + "challengeSeed": [ + "fccss", + " $(document).ready(function() {", + " ", + " });", + "fcces", + "", + "", + "", + "
      ", + "
      ", + "

      Cat Photo Finder

      ", + "
      ", + "
      ", + "
      ", + "
      ", + " The message will go here", + "
      ", + "
      ", + "
      ", + "
      ", + "
      ", + " ", + "
      ", + "
      ", + "
      " + ], + "challengeType": 0, + "type": "waypoint" + }, + { + "id": "bad87fee1348bd9aebc08826", + "title": "Get Data from an URL Using jQuery", + "dashedName": "waypoint-get-data-from-a-url-using-jquery", + "difficulty": 3.21, + "description": [ + "", + "We are now going to request data from an external source. (a file on FCC for the purposes of this exercise) The request will load in the data an run the code in the function we provide the data to which is known as the callback.", + "$(\"#getMessage\").on(\"click\", function() {", + "  $.getJSON(\"/json/cats.json?callback=?\", function( json ) {", + "    //Code to run when request is complete", + "    $(\".message\").html(JSON.stringify(json))", + "  });", + "});", + "Let's make it so that the data sent from the request is appended to the .message div", + "" + ], + "tests": [ + "assert(editor.match(/\\$\\s*?\\(\\s*?(\\\"|\\')\\#getMessage(\\\"|\\')\\s*?\\)\\s*?\\.\\s*?on\\s*?\\(\\s*?(\\\"|\\')click(\\\"|\\')\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have a click handler on the getMessage button to trigger the AJAX request')", + "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi), 'You should have at least on closing set of brackets and parenthesis')", + "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi) && editor.match(/\\,\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi) && editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi).length === editor.match(/\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi).length, 'Each callback function should have a closing set of brackets and parenthesis')", + "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\\?\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file')", + "assert(editor.match(/\\$\\s*?\\(\\s*?\\\"\\.message\\\"\\s*?\\)\\s*?\\.\\s*?html\\s*?\\(\\s*?JSON\\s*?\\.\\s*?stringify\\s*?\\(\\s*?json\\s*?\\)\\s*?\\)/gi), 'Don\\'t forget to make the .html change the contents of the message box so that it contains the result of the getJSON')" + ], + "challengeSeed": [ + "fccss", + " $(document).ready(function() {", + " ", + " $(\"#getMessage\").on(\"click\", function(){", + " $(\".message\").html(\"Make the result of the getJSON request appear here\")", + " });", + " ", + " });", + "fcces", + "", + "", + "", + "
      ", + "
      ", + "

      Cat Photo Finder

      ", + "
      ", + "
      ", + "
      ", + "
      ", + " The message will go here", + "
      ", + "
      ", + "
      ", + "
      ", + "
      ", + " ", + "
      ", + "
      ", + "
      " + ], + "challengeType": 0, + "type": "waypoint" + } + ] +} From 963856b278f98948feef9a0d8c1af95036aca934 Mon Sep 17 00:00:00 2001 From: Ricky Ng-Adam Date: Tue, 29 Sep 2015 19:00:50 +0800 Subject: [PATCH 014/149] Additional tweaks to doc to get it working --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b0c87d631..90e6cd40cd 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ touch .env npm install -g gulp ``` -Edit your `.env` file with the following API keys accordingly (if you only use email login, only the `MONGOHQ_URL`, `SESSION_SECRET`, `MANDRILL_USER` and `MANDRILL_PASSWORD` fields are necessary. Keep in mind if you want to use more services you'll have to get your own API keys for those services. +Edit your `.env` file with the following API keys accordingly. If you only use email login, only the `MONGOHQ_URL`, `SESSION_SECRET`, `MANDRILL_USER` and `MANDRILL_PASSWORD` fields are necessary. Keep in mind if you want to use more services you'll have to get your own API keys for those services. If you only use a subset or no OAuth2 authentication methods, you have to remove them from ```server/passport-providers.js``` otherwise the server will complain of missing clientID at launch. ``` MONGOHQ_URL='mongodb://localhost:27017/freecodecamp' @@ -122,6 +122,8 @@ node seed/ gulp ``` +Note that you may need to run gulp before ```node seed/``` one time to create ```server/rev-manifest.json``` (on which the seeding scripts also depend). + License ------- From 90230ec907db1536af7386ac7ff2ffd0746f0db1 Mon Sep 17 00:00:00 2001 From: natac13 Date: Wed, 30 Sep 2015 05:13:13 -0400 Subject: [PATCH 015/149] fix test so it does not match code not in the answer --- seed/challenges/basic-javascript.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 13c28c2021..5c15e74bf5 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1491,7 +1491,7 @@ " }", " ", " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", - " $(\".logger\").html(slotOne);", + " $(\".logger\").text(slotOne);", " $(\".logger\").append(\" \" + slotTwo);", " $(\".logger\").append(\" \" + slotThree);", " }", From 2d6c91b51326c4b6c0fdb00f54604afa868485f5 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Wed, 30 Sep 2015 23:01:56 +0100 Subject: [PATCH 016/149] Three complete. More to come --- seed/challenges/json-apis-and-ajax.json | 87 ++- .../json-apis-and-ajax.json | 535 ------------------ 2 files changed, 80 insertions(+), 542 deletions(-) delete mode 100644 seed/under-construction/json-apis-and-ajax.json diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index 8ece73714b..9f96865672 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -3,7 +3,7 @@ "order": 0.0065, "challenges": [ { - "id": "bad87fed1348bd9aeca08826", + "id": "bb000000000000000000000", "title": "Trigger on click Events with jQuery", "difficulty": 3.19, "description": [ @@ -53,15 +53,14 @@ "type": "waypoint" }, { - "id": "bad87fee1348bd9aebc08826", - "title": "Get Data from an URL Using jQuery", - "dashedName": "waypoint-get-data-from-a-url-using-jquery", - "difficulty": 3.21, + "id": "bb000000000000000000001", + "title": "Creating HTML from Data from an AJAX request Using jQuery", + "difficulty": 3.20, "description": [ "", "We are now going to request data from an external source. (a file on FCC for the purposes of this exercise) The request will load in the data an run the code in the function we provide the data to which is known as the callback.", "$(\"#getMessage\").on(\"click\", function() {", - "  $.getJSON(\"/json/cats.json?callback=?\", function( json ) {", + "  $.getJSON(\"/json/cats.json?callback=\", function( json ) {", "    //Code to run when request is complete", "    $(\".message\").html(JSON.stringify(json))", "  });", @@ -73,7 +72,7 @@ "assert(editor.match(/\\$\\s*?\\(\\s*?(\\\"|\\')\\#getMessage(\\\"|\\')\\s*?\\)\\s*?\\.\\s*?on\\s*?\\(\\s*?(\\\"|\\')click(\\\"|\\')\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have a click handler on the getMessage button to trigger the AJAX request')", "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi), 'You should have at least on closing set of brackets and parenthesis')", "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi) && editor.match(/\\,\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi) && editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi).length === editor.match(/\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi).length, 'Each callback function should have a closing set of brackets and parenthesis')", - "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\\?\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file')", + "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file')", "assert(editor.match(/\\$\\s*?\\(\\s*?\\\"\\.message\\\"\\s*?\\)\\s*?\\.\\s*?html\\s*?\\(\\s*?JSON\\s*?\\.\\s*?stringify\\s*?\\(\\s*?json\\s*?\\)\\s*?\\)/gi), 'Don\\'t forget to make the .html change the contents of the message box so that it contains the result of the getJSON')" ], "challengeSeed": [ @@ -111,6 +110,80 @@ ], "challengeType": 0, "type": "waypoint" + }, + { + "id": "bb000000000000000000002", + "title": "Convert json data to html", + "difficulty": 3.21, + "description": [ + "", + "Now that we have the data let's re-arrange it so that ", + "", + "", + "  json.map(function(val){", + "    ", + "    html = html + \"<div class = 'cat'>\"", + "    ", + "    for(var key in val){", + "      html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';", + "  }", + "    ", + "    html = html + \"</div><br/>\"", + "    ", + "  });", + "", + "" + ], + "tests": [ + "assert($(\".message\").html() !== '', 'The message box should have something in it')", + "assert($(\".message div\").html() !== undefined, 'you should have made created some sort of view from the json data')" + ], + "challengeSeed": [ + "fccss", + " $(document).ready(function() {", + " ", + " $(\"#getMessage\").on(\"click\", function() {", + "   $.getJSON(\"/json/cats.json?callback=\", function( json ) {", + " ", + " var html = \"\";", + " ", + " //Add you code to modify the data here. It should add it to the html sting for use in the view", + " ", + " ", + " ", + " //Don't modify above here", + " ", + "     $(\".message\").html(html);", + " ", + "   });", + " });", + " ", + " });", + "fcces", + "", + "", + "", + "
      ", + "
      ", + "

      Cat Photo Finder

      ", + "
      ", + "
      ", + "
      ", + "
      ", + " The message will go here","
      ", + "
      ", + "
      ", + "
      ", + "
      ", + " ", + "
      ", + "
      ", + "
      " + ], + "challengeType": 0, + "type": "waypoint" } ] } diff --git a/seed/under-construction/json-apis-and-ajax.json b/seed/under-construction/json-apis-and-ajax.json deleted file mode 100644 index ab12090b02..0000000000 --- a/seed/under-construction/json-apis-and-ajax.json +++ /dev/null @@ -1,535 +0,0 @@ -{ - "name": "JSON APIs and Ajax", - "order": 0.0065, - "challenges": [ - { - "id": "bad87fed1348bd9aeca08826", - "title": "Trigger on click Events with jQuery", - "difficulty": 3.19, - "description": [ - "With jQuery we are able to get data from APIs via Ajax", - "This data normally comes in the form of JSON", - "Let's get the Get Message button to set the text of a div", - "We will later use this to display the result of out API request", - "$(\"#getMessage\").on(\"click\", function(){", - "  $(\".message\").html(\"Here is the message\");", - "});" - ], - "tests": [ - "assert(editor.match(/\\$\\(\\s?\\\"\\#getMessage\\\"\\s?\\)\\.on\\s?\\(\\s?\\\"click\\\"\\,\\s?function\\s?\\(\\)\\s?\\{/gi), 'You should have bound the click event to the getMessage button')", - "assert(editor.match(/\\$\\(\\s?\\\"\\.message\\\"\\s?\\)\\.html\\(\\s?\\\"Here\\sis\\sthe\\smessage\\\"\\s?\\);/gi), 'You should set te value of the #message box to be the message given in the description')", - "assert(editor.match(/\\}\\);/gi) && editor.match(/\\}\\);/gi).length >= 2, 'Make sure that you close off all of your functions')" - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " ", - " });", - "fcces", - "", - "", - "", - "
      ", - "
      ", - "

      Cat Photo Finder

      ", - "
      ", - "
      ", - "
      ", - "
      ", - " The message will go here", - "
      ", - "
      ", - "
      ", - "
      ", - "
      ", - " ", - "
      ", - "
      ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - { - "id": "bad87fee1348bd9aebc08726", - "title": "Learn JSON Syntax", - "description": [ - "JSON stands for \"JavaScript Object Notation\". It\"s how you create objects in JavaScript.", - "JSON is a series of \"key-value pairs\". Everything on the left of the colon (:) is the \"key\" you use to unlock the \"value\" on the right of the colon." - ], - "tests": [ - "assert(typeof data != \"undefined\", \"Whoops! It looks like you deleted the data variable!\");", - "assert(typeof getAnId != \"undefined\", \"Whoops! It looks like you deleted the getAnId function!\");", - "assert(data[0]['id'] === getAnId(), \"The duntion getFirstId should return the id of the first element in the array\");" - ], - "challengeSeed": [ - "fccss", - "var data = [", - " {", - " \"id\": 0,", - " \"imageLink\": \"http://rs611.pbsrc.com/albums/tt194/allypopper423/Funny-Cat-Green-Avacado.jpg~c200\",", - " \"codeNames\": [", - " \"Juggernaut\",", - " \"Mrs. Wallace\",", - " \"Buttercup\"", - " ]", - " },", - " {", - " \"id\": 1,", - " \"imageLink\": \"http://cdn.grumpycats.com/wp-content/uploads/2012/09/GC-Gravatar-copy.png\",", - " \"codeNames\": [", - " \"Oscar\",", - " \"Scrooge\",", - " \"Tyrion\"", - " ]", - " },", - " {", - " \"id\": 2,", - " \"imageLink\": \"http://www.kittenspet.com/wp-content/uploads/2012/08/cat_with_funny_face_3-200x200.jpg\",", - " \"codeNames\": [", - " \"The Doctor\",", - " \"Loki\",", - " \"Joker\"", - " ]", - " }", - "]", - "function getAnId(){", - " return();", - "}", - "fcces" - ], - "challengeType": 0, - "type": "waypoint" - }, - { - "id": "bad87fee1348bd9aeca08826", - "title": "Displaying JSON data in HTML", - "difficulty": 3.19, - "description": [ - "JSON stands for \"JavaScript Object Notation\". It\"s how you create objects in JavaScript.", - "JSON is a series of \"key-value pairs\". Everything on the left of the colon (:) is the \"key\" you use to unlock the \"value\" on the right of the colon." - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"#getMessage\").on(\"click\", function(){", - " $(\".message\").html(\"Here is the message\");", - " });", - " });", - "fcces", - "", - "", - "", - "
      ", - "
      ", - "

      Cat Photo Finder

      ", - "
      ", - "
      ", - "
      ", - "
      ", - " The message will go here", - "
      ", - "
      ", - "
      ", - "
      ", - "
      ", - " ", - "
      ", - "
      ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad84fee1348bd9aecc48826", - "title": "Read Data from an Element Using jQuery", - "dashedName": "waypoint-read-data-from-an-element-using-jquery", - "difficulty": 3.17, - "description": [ - "Let's make everything roll with rollOut." - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"button\").on(\"click\", function() {", - " $(\"#click-me\").addClass(\"animated shake\");", - " });", - " });", - "fcces", - "", - "", - "", - "
      ", - "
      ", - "
      ", - " ", - "
      ", - "
      ", - "

      #check-me

      ", - "
      ", - " ", - " Is the checkbox checked?", - " ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad84fee1348bd9aecc38826", - "title": "Read Data from an Element Using jQuery", - "dashedName": "waypoint-read-data-from-an-element-using-jquery", - "difficulty": 3.17, - "description": [ - "Let's make everything roll with rollOut." - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"button\").on(\"click\", function() {", - " $(\"#click-me\").addClass(\"animated shake\");", - " $(\"#checked-state\").text(\"happy text\");", - " });", - " });", - "fcces", - "", - "", - "", - "
      ", - "
      ", - "
      ", - " ", - "
      ", - "
      ", - "

      #check-me

      ", - "
      ", - " ", - " Is the checkbox checked?", - " ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad84fee1348bd9aecc28826", - "title": "Read Data from an Element Using jQuery", - "dashedName": "waypoint-read-data-from-an-element-using-jquery", - "difficulty": 3.17, - "description": [ - "Let's make everything roll with rollOut." - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"button\").on(\"click\", function() {", - " $(\"#click-me\").addClass(\"animated shake\");", - " $(\"#checked-state\").text($(\"#check-me\").prop(\"checked\"));", - " });", - " });", - "fcces", - "", - "", - "", - "
      ", - "
      ", - "
      ", - " ", - "
      ", - "
      ", - "

      #check-me

      ", - "
      ", - " ", - " Is the checkbox checked?", - " ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad84fee1348bd9aecc18826", - "title": "Read Data from an Element Using jQuery", - "dashedName": "waypoint-read-data-from-an-element-using-jquery", - "difficulty": 3.17, - "description": [ - - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"button\").on(\"click\", function() {", - " $(\"#click-me\").addClass(\"animated shake\");", - " $(\"#checked-state\").text($(\"#check-me\").prop(\"checked\"));", - " });", - " });", - "fcces", - "", - "", - "", - "
      ", - "
      ", - "
      ", - " ", - "
      ", - "
      ", - "

      #check-me

      ", - "
      ", - " ", - " Is the checkbox checked?", - " ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad87fee1348bd9aecc08826", - "title": "Trigger onHover Events with jQuery", - "dashedName": "waypoint-trigger-onhover-events-with-jquery", - "difficulty": 3.18, - "description": [ - - ], - "tests": [ - - ], - "challengeSeed": [ - - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad87fee1348bd9aebc08826", - "title": "Get Data from an URL Using jQuery", - "dashedName": "waypoint-get-data-from-a-url-using-jquery", - "difficulty": 3.21, - "description": [ - - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - "", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - "", - " });", - " });", - "", - " });", - "fcces", - "
      ", - " ", - "
      ", - "
      ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad87fee1348bd9ae9c08826", - "title": "Loop through JSON Data Using jQuery", - "dashedName": "waypoint-loop-through-json-data-using-jquery", - "difficulty": 3.22, - "description": [ - - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - "", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - "", - " });", - " });", - "", - " });", - "fcces", - "
      ", - " ", - "
      ", - "
      ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad88fee1348bd9ae8c08726", - "title": "Wire AJAX Call into a jQuery Click Event", - "dashedName": "waypoint-wire-ajax-call-into-a-jquery-click-event", - "difficulty": 3.24, - "description": [ - "" - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " var random = function() { return Math.floor(Math.random() * 3) }", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - "", - " });", - " });", - "", - " });", - "fcces", - "
      ", - " ", - "
      ", - "
      ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad88fee1348bd9ae8c08626", - "title": "Wire AJAX Call into a jQuery Click Event", - "dashedName": "waypoint-wire-ajax-call-into-a-jquery-click-event", - "difficulty": 3.24, - "description": [ - "" - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " var random = function() { return Math.floor(Math.random() * 3) }", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - " var kitten = json[random()];", - " });", - " });", - "", - " });", - "fcces", - "
      ", - " ", - "
      ", - "
      ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad88fee1348bd9ae8c08526", - "title": "Wire AJAX Call into a jQuery Click Event", - "dashedName": "waypoint-wire-ajax-call-into-a-jquery-click-event", - "difficulty": 3.24, - "description": [ - "" - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " var random = function() { return Math.floor(Math.random() * 3) }", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - " var kitten = json[random()];", - " $(\"\").appendTo(\"#output\");", - " });", - " });", - "", - " });", - "
      ", - " ", - "
      ", - "
      ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad88fee1348bd9ae8c08426", - "title": "Wire AJAX Call into a jQuery Click Event", - "dashedName": "waypoint-wire-ajax-call-into-a-jquery-click-event", - "difficulty": 3.24, - "description": [ - "" - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " var random = function() { return Math.floor(Math.random() * 3) }", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - " var kitten = json[random()];", - " $(\"\").appendTo(\"#output\");", - " $(\"

      Code name: \" + kitten.codeNames[random()] + \"

      \").appendTo(\"#output\");", - " });", - " });", - "", - " });", - "fcces", - "
      ", - " ", - "
      ", - "
      ", - "
      " - ], - "challengeType": 0, - "type": "waypoint" - } - ] -} From 1b13ad2601452eb83364fd00f9c998a2d9f91802 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Wed, 30 Sep 2015 23:23:58 +0100 Subject: [PATCH 017/149] Added the skeleton for the fourth challenge. Challenge three needs some refinement in the testing system --- seed/challenges/json-apis-and-ajax.json | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index 9f96865672..e826927a0d 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -113,7 +113,7 @@ }, { "id": "bb000000000000000000002", - "title": "Convert json data to html", + "title": "Convert JSON data to HTML", "difficulty": 3.21, "description": [ "", @@ -184,6 +184,25 @@ ], "challengeType": 0, "type": "waypoint" + }, + { + "id": "bb000000000000000000003", + "title": "Pre-filtering the JSON", + "difficulty": 3.22, + "description": [ + "", + "If we want to filter the data we have so that we are searching through results based on users inout. It is far more efficient to filter and display a copy of the data we have instead of requesting a new copy each time.", + "This means we should never hit API limits and it will make the process more efficient.", + "" + ], + "tests": [ + "/*be assertive!*/" + ], + "challengeSeed": [ + "TODO: get the result of the previous challenge" + ], + "challengeType": 0, + "type": "waypoint" } ] } From 4e33b355b0e947b015cf8526e85a355b29b51388 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Sat, 3 Oct 2015 23:59:54 +0100 Subject: [PATCH 018/149] 90% complete without QA or refined descriptions/tests --- seed/challenges/json-apis-and-ajax.json | 223 ++++++++++++++++++++++-- 1 file changed, 213 insertions(+), 10 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index e826927a0d..fda516722e 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -4,6 +4,29 @@ "challenges": [ { "id": "bb000000000000000000000", + "title": "Understanding JSON", + "difficulty": 3.19, + "description": [ + "", + "JSON is a way of creating a file or a db record from a javascript object.", + "JSON works in the exact same way as javascript objects that you should be familiar with.", + "" + ], + "tests": [ + "assert(typeof json !== 'undefined')" + ], + "challengeSeed": [ + "var json = {", + " name: \"Happy Camper\"", + " age: 35", + " height: \"5ft 8\"", + "}" + ], + "challengeType": 0, + "type": "waypoint" + }, + { + "id": "bb000000000000000000001", "title": "Trigger on click Events with jQuery", "difficulty": 3.19, "description": [ @@ -53,7 +76,7 @@ "type": "waypoint" }, { - "id": "bb000000000000000000001", + "id": "bb000000000000000000002", "title": "Creating HTML from Data from an AJAX request Using jQuery", "difficulty": 3.20, "description": [ @@ -112,7 +135,7 @@ "type": "waypoint" }, { - "id": "bb000000000000000000002", + "id": "bb000000000000000000003", "title": "Convert JSON data to HTML", "difficulty": 3.21, "description": [ @@ -135,8 +158,7 @@ "" ], "tests": [ - "assert($(\".message\").html() !== '', 'The message box should have something in it')", - "assert($(\".message div\").html() !== undefined, 'you should have made created some sort of view from the json data')" + "assert($(\".message\").html() !== '', 'The message box should have something in it')" ], "challengeSeed": [ "fccss", @@ -149,10 +171,12 @@ " ", " //Add you code to modify the data here. It should add it to the html sting for use in the view", " ", - " ", - " ", " //Don't modify above here", " ", + " ", + " ", + " //Don't modify below here", + " ", "     $(\".message\").html(html);", " ", "   });", @@ -186,20 +210,199 @@ "type": "waypoint" }, { - "id": "bb000000000000000000003", + "id": "bb000000000000000000004", + "title": "render those images!", + "difficulty": 3.22, + "description": [ + "", + "instead of just placing everything in a div we should check if the value is an image.", + "If it is an image we should use it as an ima tag instead so that the image is rendered", + "", + "if(key === \"imageLink\"){", + "html = html + '<img class = \"' + key + '\"src = \"' + val[key] + '\">';", + "}", + "else{", + " html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';", + "}", + "", + "" + ], + "tests": [ + "assert(editor.match(/imageLink/gi), 'You should have accessed the imageLink of each cat object')" + ], + "challengeSeed": [ + "fccss", + "$(document).ready(function() {", + " ", + " $(\"#getMessage\").on(\"click\", function() {", + "   $.getJSON(\"/json/cats.json?callback=\", function( json ) {", + " ", + " var html = \"\";", + " ", + " //Add you code to modify the data here. It should add it to the html sting for use in the view", + " ", + "  json.map(function(val){", + "", + " html = html + \"
      \"", + "", + "", + "", + " for(var key in val){", + "", + " //Don't modify above here", + " ", + " ", + " ", + " //Don't modify below here", + "", + " }", + " ", + " html = html + \"

      \"", + "", + " });", + " ", + " //Don't modify above here", + " ", + "     $(\".message\").html(html);", + " ", + "   });", + " });", + " ", + " });", + "fcces", + "", + "", + "", + "
      ", + "
      ", + "

      Cat Photo Finder

      ", + "
      ", + "
      ", + "
      ", + "
      ", + " The message will go here", + "
      ", + "
      ", + "
      ", + "
      ", + "
      ", + " ", + "
      ", + "
      ", + "
      ", + "" + ], + "challengeType": 0, + "type": "waypoint" + }, + { + "id": "bb000000000000000000005", "title": "Pre-filtering the JSON", "difficulty": 3.22, "description": [ "", - "If we want to filter the data we have so that we are searching through results based on users inout. It is far more efficient to filter and display a copy of the data we have instead of requesting a new copy each time.", "This means we should never hit API limits and it will make the process more efficient.", + "Let's try pre-filtering the json before we map it", + "We can use the pre-made filter method like this to remove the cat with the id of 1", + "", + "json = json.filter(function(val){", + " return(val.id !== 1);", + "});", + "", "" ], "tests": [ - "/*be assertive!*/" + "assert(editor.match(/filter/gi), 'You should be making use of the .filter method')" ], "challengeSeed": [ - "TODO: get the result of the previous challenge" + "fccss", + "$(document).ready(function() {", + " ", + " $(\"#getMessage\").on(\"click\", function() {", + "   $.getJSON(\"/json/cats.json?callback=\", function( json ) {", + " ", + " var html = \"\";", + " ", + " //Add you code to modify the data here. It should add it to the html sting for use in the view", + " ", + "  json.map(function(val){", + "", + "    val = \"\" ", + "", + " html = html + \"
      \"", + "", + " //Don't modify above here", + " ", + " ", + " ", + " //Don't modify below here", + "", + " for(var key in val){", + "", + " html = html + '
      ' + val[key] + '
      ';", + "", + " }", + "", + " ", + " html = html + \"

      \"", + "", + " });", + " ", + " //Don't modify above here", + " ", + "     $(\".message\").html(html);", + " ", + "   });", + " });", + " ", + " });", + "fcces", + "", + "", + "", + "
      ", + "
      ", + "

      Cat Photo Finder

      ", + "
      ", + "
      ", + "
      ", + "
      ", + " The message will go here", + "
      ", + "
      ", + "
      ", + "
      ", + "
      ", + " ", + "
      ", + "
      ", + "
      ", + "" + ], + "challengeType": 0, + "type": "waypoint" + }, + { + "id": "bb000000000000000000006", + "title": "Getting Geo-location data for use in APIs", + "difficulty": 3.19, + "description": [ + "", + "Be descriptive!" + ], + "tests": [ + "/*Be Assertive*/')" + ], + "challengeSeed": [ + "var json = {", + " name: \"Happy Camper\"", + " age: 35", + " height: \"5ft 8\"", + "}" ], "challengeType": 0, "type": "waypoint" From 89e1ebb952e1ce407b293acba40487196d1bb579 Mon Sep 17 00:00:00 2001 From: SaintPeter Date: Sat, 3 Oct 2015 19:56:10 -0700 Subject: [PATCH 019/149] New for loop waypoints and verbiage improvements --- seed/challenges/basic-javascript.json | 88 ++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index c10af0def1..2dbe909815 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -790,6 +790,14 @@ "description":[ "You can run the same code multiple times by using a loop.", "The most common type of JavaScript loop is called a \"for loop\" because it runs \"for\" a specific number of times.", + "", + "For loops are declared with three optional expressions seperated by semicolons:", + "for([initialization]; [condition]; [final-expression])", + "The initialization statement is executed one time only before the loop starts. It is typically used to define and setup your loop varaible.", + "The condition statement is evaluated at the beginning of every loop and will continue as long as it evalutes true. When condition is false at the start of the loop, the loop will stop executing. This means if condition starts as false, your loop will never execute.", + "The final-expression is executed at the end of each loop iteration, prior to the next condition check and is usually used to increment or decrement your loop counter.", + "", + "We'll initialize with i = 0 and loop while our condition i < 5 is true. We'll increment i by 1 each loop with i++ as our final-expression.", "var ourArray = [];", "for(var i = 0; i < 5; i++) {", "  ourArray.push(i);", @@ -798,7 +806,7 @@ "Let's try getting a for loop to work by pushing values to an array." ], "tests":[ - "assert(editor.getValue().match(/for/g), 'message: You should be using a for loop for this.');", + "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for loop for this.');", "assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray should equal [0,1,2,3,4].');" ], "challengeSeed":[ @@ -821,6 +829,84 @@ "type": "waypoint", "challengeType": 1 }, + { + "id":"56104e9e514f539506016a5c", + "title": "Iterate Odd Numbers With a For Loop", + "difficulty":"9.9824", + "description":[ + "For loops don't have to iterate one at a time. By changing our final-expression, we can count by even numbers.", + "We'll start at i = 0 and loop while i < 10. We'll increment i by 2 each loop with i += 2.", + "var ourArray = [];", + "for(var i = 0; i < 10; i += 2) {", + "  ourArray.push(i);", + "}", + "ourArray will now contain [0,2,4,6,8] ", + "Let's change our initialization and final-expression so we can count by odd numbers." + ], + "tests":[ + "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for loop for this.');", + "assert.deepEqual(myArray, [1,3,5,7,9], 'message: myArray should equal [1,3,5,7,9].');" + ], + "challengeSeed":[ + "ourArray = [];", + "for(var i = 1; i < 10; i += 2){", + " ourArray.push(i);", + "}", + "var myArray = [];", + "", + "// Only change code below this line.", + "", + "// Push the odd numbers from one through nine to myArray using a \"for loop\" like above.", + "", + "// Only change code above this line.", + "// We use this function to show you the value of your variable in your output box.", + "// You'll learn about functions soon.", + "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}", + "" + ], + "type": "waypoint", + "challengeType": 1 + }, + { + "id":"56105e7b514f539506016a5e", + "title": "Count Backwards With a For Loop", + "difficulty":"9.9824", + "description":[ + "A for loop can also count backwards, so long as we can define the right conditions.", + "", + "In order to count backwards by twos, we'll need to change our initialization, condition, and final-expression.", + "We'll start at i = 10 and loop while i > 0. We'll decrement i by 2 each loop with i -= 2.", + "var ourArray = [];", + "for(var i = 10; i > 0; i -= 2) {", + "  ourArray.push(i);", + "}", + "ourArray will now contain [10,8,6,4,2] ", + "Let's change our initialization and final-expression so we can count backward by twos for numbers." + ], + "tests":[ + "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for loop for this.');", + "assert.deepEqual(myArray, [9,7,5,3,1], 'message: myArray should equal [9,7,5,3,1].');" + ], + "challengeSeed":[ + "ourArray = [];", + "for(var i = 9; i > 0; i -= 2){", + " ourArray.push(i);", + "}", + "var myArray = [];", + "", + "// Only change code below this line.", + "", + "// Push the odd numbers from nine through one to myArray using a \"for loop\" like above.", + "", + "// Only change code above this line.", + "// We use this function to show you the value of your variable in your output box.", + "// You'll learn about functions soon.", + "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}", + "" + ], + "type": "waypoint", + "challengeType": 1 + }, { "id":"cf1111c1c11feddfaeb1bdef", "title": "Iterate with JavaScript While Loops", From fe3e94e69b5005d8c16dfac008a3e785065d5174 Mon Sep 17 00:00:00 2001 From: Abhisek Pattnaik Date: Mon, 21 Sep 2015 01:55:21 +0530 Subject: [PATCH 020/149] Modify tests for Bonfire - Where do I belong close FreeCodeCamp/FreeCodeCamp#3381 --- seed/challenges/basic-bonfires.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seed/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json index 931c157ce1..c81733da04 100644 --- a/seed/challenges/basic-bonfires.json +++ b/seed/challenges/basic-bonfires.json @@ -617,8 +617,8 @@ "assert(where([10, 20, 30, 40, 50], 35) === 3, 'message: where([10, 20, 30, 40, 50], 35) should return 3.');", "assert(where([10, 20, 30, 40, 50], 30) === 2, 'message: where([10, 20, 30, 40, 50], 30) should return 2.');", "assert(where([40, 60], 50) === 1, 'message: where([40, 60,], 50) should return 1.');", - "assert(where([5, 3, 20, 3], 3) === 0, 'message: where([5, 3, 20, 3], 3) should return 0.');", - "assert(where([2, 20, 10], 1) === 0, 'message: where([2, 20, 10], 1) should return 0.');", + "assert(where([5, 3, 20, 3], 5) === 2, 'message: where([5, 3, 20, 3], 5) should return 2.');", + "assert(where([2, 20, 10], 19) === 2, 'message: where([2, 20, 10], 19) should return 2.');", "assert(where([2, 5, 10], 15) === 3, 'message: where([2, 5, 10], 15) should return 3.');" ], "type": "bonfire", From e07941936759f6dc4da0f43ba4ccb94d4692f45c Mon Sep 17 00:00:00 2001 From: ahstro Date: Mon, 5 Oct 2015 18:01:28 +0200 Subject: [PATCH 021/149] Confirm the Ending: Add test case Add a test case that makes sure the user can't just check the last character or word. --- seed/challenges/basic-bonfires.json | 1 + 1 file changed, 1 insertion(+) diff --git a/seed/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json index 931c157ce1..3e6b8aa1bc 100644 --- a/seed/challenges/basic-bonfires.json +++ b/seed/challenges/basic-bonfires.json @@ -307,6 +307,7 @@ "assert(end(\"Connor\", \"n\") === false, 'message: end(\"Connor\", \"n\") should return false.');", "assert(end(\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") === false, 'message: end(\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") should return false.');", "assert(end(\"He has to give me a new name\", \"name\") === true, 'message: end(\"He has to give me a new name\", \"name\") should return true.');", + "assert(end(\"He has to give me a new name\", \"me\") === true, 'message: end(\"He has to give me a new name\", \"me\") should return true.');", "assert(end(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") === false, 'message: end(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") should return false.');" ], "MDNlinks": [ From 5b771e18e66eb53157acd1bc10d8d90ce4951e0a Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Mon, 5 Oct 2015 22:46:29 +0100 Subject: [PATCH 022/149] Finished the geolocation waypoint. Ready for QA and copy fixes --- seed/challenges/json-apis-and-ajax.json | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index fda516722e..cec38c8b65 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -392,10 +392,22 @@ "difficulty": 3.19, "description": [ "", - "Be descriptive!" + "We can access the users current location by using the built in navigator in the browser.", + "The navigator will get the users current longitude and latitude with a decent level of accuracy.", + "", + "if (navigator.geolocation) {", + " navigator.geolocation.getCurrentPosition(function(position){", + " // Do something in here with the coordinates!", + " ", + " console.log(\"latitiude\", position.coords.latitude);", + " console.log(\"longitude\", position.coords.longitude);", + " ", + " });", + "}", + "" ], "tests": [ - "/*Be Assertive*/')" + "assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'you should make use of the navigator.geolocation to access the users current location')" ], "challengeSeed": [ "var json = {", From da09a7b650ab40b316dc42c64978dda76999b21b Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Mon, 5 Oct 2015 23:42:30 +0100 Subject: [PATCH 023/149] Brought in line with staging and added spoofigator! --- client/commonFramework.js | 14 ++++++++++++++ seed/challenges/json-apis-and-ajax.json | 25 +++++++++++++------------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/client/commonFramework.js b/client/commonFramework.js index 8abcb6a9dc..ced143db58 100644 --- a/client/commonFramework.js +++ b/client/commonFramework.js @@ -481,6 +481,20 @@ function safeHTMLRun(test) { // add feuxQuery s = 'var document = \"\"; var $ = function() {return(new function() {this.add=function() {return(this);};this.addBack=function() {return(this);};this.addClass=function() {return(this);};this.after=function() {return(this);};this.ajaxComplete=function() {return(this);};this.ajaxError=function() {return(this);};this.ajaxSend=function() {return(this);};this.ajaxStart=function() {return(this);};this.ajaxStop=function() {return(this);};this.ajaxSuccess=function() {return(this);};this.andSelf=function() {return(this);};this.animate=function() {return(this);};this.append=function() {return(this);};this.appendTo=function() {return(this);};this.attr=function() {return(this);};this.before=function() {return(this);};this.bind=function() {return(this);};this.blur=function() {return(this);};this.callbacksadd=function() {return(this);};this.callbacksdisable=function() {return(this);};this.callbacksdisabled=function() {return(this);};this.callbacksempty=function() {return(this);};this.callbacksfire=function() {return(this);};this.callbacksfired=function() {return(this);};this.callbacksfireWith=function() {return(this);};this.callbackshas=function() {return(this);};this.callbackslock=function() {return(this);};this.callbackslocked=function() {return(this);};this.callbacksremove=function() {return(this);};this.change=function() {return(this);};this.children=function() {return(this);};this.clearQueue=function() {return(this);};this.click=function() {return(this);};this.clone=function() {return(this);};this.closest=function() {return(this);};this.contents=function() {return(this);};this.context=function() {return(this);};this.css=function() {return(this);};this.data=function() {return(this);};this.dblclick=function() {return(this);};this.delay=function() {return(this);};this.delegate=function() {return(this);};this.dequeue=function() {return(this);};this.detach=function() {return(this);};this.die=function() {return(this);};this.each=function() {return(this);};this.empty=function() {return(this);};this.end=function() {return(this);};this.eq=function() {return(this);};this.error=function() {return(this);};this.fadeIn=function() {return(this);};this.fadeOut=function() {return(this);};this.fadeTo=function() {return(this);};this.fadeToggle=function() {return(this);};this.filter=function() {return(this);};this.find=function() {return(this);};this.finish=function() {return(this);};this.first=function() {return(this);};this.focus=function() {return(this);};this.focusin=function() {return(this);};this.focusout=function() {return(this);};this.get=function() {return(this);};this.has=function() {return(this);};this.hasClass=function() {return(this);};this.height=function() {return(this);};this.hide=function() {return(this);};this.hover=function() {return(this);};this.html=function() {return(this);};this.index=function() {return(this);};this.innerHeight=function() {return(this);};this.innerWidth=function() {return(this);};this.insertAfter=function() {return(this);};this.insertBefore=function() {return(this);};this.is=function() {return(this);};this.jQuery=function() {return(this);};this.jquery=function() {return(this);};this.keydown=function() {return(this);};this.keypress=function() {return(this);};this.keyup=function() {return(this);};this.last=function() {return(this);};this.length=function() {return(this);};this.live=function() {return(this);};this.load=function() {return(this);};this.load=function() {return(this);};this.map=function() {return(this);};this.mousedown=function() {return(this);};this.mouseenter=function() {return(this);};this.mouseleave=function() {return(this);};this.mousemove=function() {return(this);};this.mouseout=function() {return(this);};this.mouseover=function() {return(this);};this.mouseup=function() {return(this);};this.next=function() {return(this);};this.nextAll=function() {return(this);};this.nextUntil=function() {return(this);};this.not=function() {return(this);};this.off=function() {return(this);};this.offset=function() {return(this);};this.offsetParent=function() {return(this);};this.on=function() {return(this);};this.one=function() {return(this);};this.outerHeight=function() {return(this);};this.outerWidth=function() {return(this);};this.parent=function() {return(this);};this.parents=function() {return(this);};this.parentsUntil=function() {return(this);};this.position=function() {return(this);};this.prepend=function() {return(this);};this.prependTo=function() {return(this);};this.prev=function() {return(this);};this.prevAll=function() {return(this);};this.prevUntil=function() {return(this);};this.promise=function() {return(this);};this.prop=function() {return(this);};this.pushStack=function() {return(this);};this.queue=function() {return(this);};this.ready=function() {return(this);};this.remove=function() {return(this);};this.removeAttr=function() {return(this);};this.removeClass=function() {return(this);};this.removeData=function() {return(this);};this.removeProp=function() {return(this);};this.replaceAll=function() {return(this);};this.replaceWith=function() {return(this);};this.resize=function() {return(this);};this.scroll=function() {return(this);};this.scrollLeft=function() {return(this);};this.scrollTop=function() {return(this);};this.select=function() {return(this);};this.selector=function() {return(this);};this.serialize=function() {return(this);};this.serializeArray=function() {return(this);};this.show=function() {return(this);};this.siblings=function() {return(this);};this.size=function() {return(this);};this.slice=function() {return(this);};this.slideDown=function() {return(this);};this.slideToggle=function() {return(this);};this.slideUp=function() {return(this);};this.stop=function() {return(this);};this.submit=function() {return(this);};this.text=function() {return(this);};this.toArray=function() {return(this);};this.toggle=function() {return(this);};this.toggle=function() {return(this);};this.toggleClass=function() {return(this);};this.trigger=function() {return(this);};this.triggerHandler=function() {return(this);};this.unbind=function() {return(this);};this.undelegate=function() {return(this);};this.unload=function() {return(this);};this.unwrap=function() {return(this);};this.val=function() {return(this);};this.width=function() {return(this);};this.wrap=function() {return(this);};this.wrapAll=function() {return(this);};this.wrapInner=function() {return(this);}});};$.ajax=function() {return($);};$.ajaxPrefilter=function() {return($);};$.ajaxSetup=function() {return($);};$.ajaxTransport=function() {return($);};$.boxModel=function() {return($);};$.browser=function() {return($);};$.Callbacks=function() {return($);};$.contains=function() {return($);};$.cssHooks=function() {return($);};$.cssNumber=function() {return($);};$.data=function() {return($);};$.Deferred=function() {return($);};$.dequeue=function() {return($);};$.each=function() {return($);};$.error=function() {return($);};$.extend=function() {return($);};$.fnextend=function() {return($);};$.fxinterval=function() {return($);};$.fxoff=function() {return($);};$.get=function() {return($);};$.getJSON=function() {return($);};$.getScript=function() {return($);};$.globalEval=function() {return($);};$.grep=function() {return($);};$.hasData=function() {return($);};$.holdReady=function() {return($);};$.inArray=function() {return($);};$.isArray=function() {return($);};$.isEmptyObject=function() {return($);};$.isFunction=function() {return($);};$.isNumeric=function() {return($);};$.isPlainObject=function() {return($);};$.isWindow=function() {return($);};$.isXMLDoc=function() {return($);};$.makeArray=function() {return($);};$.map=function() {return($);};$.merge=function() {return($);};$.noConflict=function() {return($);};$.noop=function() {return($);};$.now=function() {return($);};$.param=function() {return($);};$.parseHTML=function() {return($);};$.parseJSON=function() {return($);};$.parseXML=function() {return($);};$.post=function() {return($);};$.proxy=function() {return($);};$.queue=function() {return($);};$.removeData=function() {return($);};$.sub=function() {return($);};$.support=function() {return($);};$.trim=function() {return($);};$.type=function() {return($);};$.unique=function() {return($);};$.when=function() {return($);};$.always=function() {return($);};$.done=function() {return($);};$.fail=function() {return($);};$.isRejected=function() {return($);};$.isResolved=function() {return($);};$.notify=function() {return($);};$.notifyWith=function() {return($);};$.pipe=function() {return($);};$.progress=function() {return($);};$.promise=function() {return($);};$.reject=function() {return($);};$.rejectWith=function() {return($);};$.resolve=function() {return($);};$.resolveWith=function() {return($);};$.state=function() {return($);};$.then=function() {return($);};$.currentTarget=function() {return($);};$.data=function() {return($);};$.delegateTarget=function() {return($);};$.isDefaultPrevented=function() {return($);};$.isImmediatePropagationStopped=function() {return($);};$.isPropagationStopped=function() {return($);};$.metaKey=function() {return($);};$.namespace=function() {return($);};$.pageX=function() {return($);};$.pageY=function() {return($);};$.preventDefault=function() {return($);};$.relatedTarget=function() {return($);};$.result=function() {return($);};$.stopImmediatePropagation=function() {return($);};$.stopPropagation=function() {return($);};$.target=function() {return($);};$.timeStamp=function() {return($);};$.type=function() {return($);};$.which=function() {return($);};' + s; + // add spoofigator + + s = " var navigator = " + + "function(){" + + " this.geolocation=function(){" + + " this.getCurrentPosition=function(){" + + " this.coords = {latitude: \"\", longitude: \"\"};" + + " return(this);" + + " };" + + " return(this);" + + " };" + + " return(this);" + + "};" + s; + sandBox.submit(scopejQuery(s), function(cls, message) { if (cls) { console.log(message.error); diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index cec38c8b65..9ea8bfd0e8 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -396,13 +396,12 @@ "The navigator will get the users current longitude and latitude with a decent level of accuracy.", "", "if (navigator.geolocation) {", - " navigator.geolocation.getCurrentPosition(function(position){", - " // Do something in here with the coordinates!", - " ", - " console.log(\"latitiude\", position.coords.latitude);", - " console.log(\"longitude\", position.coords.longitude);", - " ", - " });", + "  navigator.geolocation.getCurrentPosition(function(position){", + "    // Do something in here with the coordinates!", + "    ", + "    $(\"#data\").html(\"latitiude\" + position.coords.latitude + \"longitude\" + position.coords.longitude);", + "    ", + "  });", "}", "" ], @@ -410,11 +409,13 @@ "assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'you should make use of the navigator.geolocation to access the users current location')" ], "challengeSeed": [ - "var json = {", - " name: \"Happy Camper\"", - " age: 35", - " height: \"5ft 8\"", - "}" + "fccss", + "", + "fcces", + "
      ", + "

      You are here!

      ", + " ", + "
      " ], "challengeType": 0, "type": "waypoint" From 91708a33162e3cd2b4c2c0da164c14b74f2e3afa Mon Sep 17 00:00:00 2001 From: Logan Tegman Date: Mon, 5 Oct 2015 22:50:09 -0700 Subject: [PATCH 024/149] Fix Waypoint: Find White Space Explaination Changed text description to make it clear that `\s` is used to find all types of whitespace characters, not just `" "`. Closes #2838 --- seed/challenges/basic-javascript.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 13c28c2021..213a5f745e 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1081,10 +1081,11 @@ "title": "Find White Space with Regular Expressions", "difficulty":"9.986", "description":[ - "We can also use selectors like \\s to find spaces in a string.", + "We can also use selectors like \\s to find white space in a string.", + "The white space characters are \" \" (space), \\r (carriage return), \\n (newline), \\t (tab), \\f (form feed).", "It is used like this:", "/\\s+/g", - "Select all the spaces in the sentence string." + "Select all the white space characters in the sentence string." ], "tests":[ "assert(test === 7, 'Your RegEx should have found seven spaces in the testString.');", From a17687116e9b7bad14dee5c66aae7d5e19836122 Mon Sep 17 00:00:00 2001 From: Logan Tegman Date: Tue, 6 Oct 2015 08:45:21 -0700 Subject: [PATCH 025/149] Fix Waypoint: Find Whitespace spelling and grammar. --- seed/challenges/basic-javascript.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 213a5f745e..47790e5e0e 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1078,14 +1078,14 @@ }, { "id":"cf1111c1c12feddfaeb8bdef", - "title": "Find White Space with Regular Expressions", + "title": "Find Whitespace with Regular Expressions", "difficulty":"9.986", "description":[ - "We can also use selectors like \\s to find white space in a string.", - "The white space characters are \" \" (space), \\r (carriage return), \\n (newline), \\t (tab), \\f (form feed).", + "We can also use selectors like \\s to find whitespace in a string.", + "The whitespace characters are \" \" (space), \\r (carriage return), \\n (newline), \\t (tab), and \\f (form feed).", "It is used like this:", "/\\s+/g", - "Select all the white space characters in the sentence string." + "Select all the whitespace characters in the sentence string." ], "tests":[ "assert(test === 7, 'Your RegEx should have found seven spaces in the testString.');", From 9f298cbe9409dbd49b427bb0a1855fd3b0df1930 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Tue, 6 Oct 2015 21:47:29 +0100 Subject: [PATCH 026/149] Fixed tests --- seed/challenges/json-apis-and-ajax.json | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index 9ea8bfd0e8..de5feb033c 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -10,19 +10,18 @@ "", "JSON is a way of creating a file or a db record from a javascript object.", "JSON works in the exact same way as javascript objects that you should be familiar with.", - "" + "Lets add a string property to out object." ], "tests": [ - "assert(typeof json !== 'undefined')" + "assert(typeof json !== 'undefined' && Object.keys(json).length === 3 && typeof(json[Object.keys(json)[Object.keys(json).length-1]]) === 'string', 'message: You should have added a string value to your object.')" ], "challengeSeed": [ "var json = {", - " name: \"Happy Camper\"", - " age: 35", - " height: \"5ft 8\"", + " \"name\": \"Happy Camper\"", + " \"height\": \"160cm\"", "}" ], - "challengeType": 0, + "challengeType": 1, "type": "waypoint" }, { @@ -158,8 +157,8 @@ "" ], "tests": [ - "assert($(\".message\").html() !== '', 'The message box should have something in it')" - ], + "assert(/json\\.map/gi, 'The message box should have something in it')" + ], "challengeSeed": [ "fccss", " $(document).ready(function() {", From a27aa2d9f62e373b689684724a17a485df1139f2 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Tue, 6 Oct 2015 22:54:20 +0100 Subject: [PATCH 027/149] More test and copy fixes. Removed weird bugged challenge --- seed/challenges/json-apis-and-ajax.json | 64 ++++++++----------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index de5feb033c..c522e2441b 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -2,45 +2,23 @@ "name": "JSON APIs and Ajax", "order": 0.0065, "challenges": [ - { - "id": "bb000000000000000000000", - "title": "Understanding JSON", - "difficulty": 3.19, - "description": [ - "", - "JSON is a way of creating a file or a db record from a javascript object.", - "JSON works in the exact same way as javascript objects that you should be familiar with.", - "Lets add a string property to out object." - ], - "tests": [ - "assert(typeof json !== 'undefined' && Object.keys(json).length === 3 && typeof(json[Object.keys(json)[Object.keys(json).length-1]]) === 'string', 'message: You should have added a string value to your object.')" - ], - "challengeSeed": [ - "var json = {", - " \"name\": \"Happy Camper\"", - " \"height\": \"160cm\"", - "}" - ], - "challengeType": 1, - "type": "waypoint" - }, { "id": "bb000000000000000000001", "title": "Trigger on click Events with jQuery", "difficulty": 3.19, "description": [ - "With jQuery we are able to get data from APIs via Ajax", - "This data normally comes in the form of JSON", - "Let's get the Get Message button to set the text of a div", - "We will later use this to display the result of out API request", + "With jQuery we are able to get data from APIs via Ajax.", + "This data normally comes in the form of JSON.", + "Let's get the Get Message button to set the text of a div.", + "We will later use this to display the result of out API request.", "$(\"#getMessage\").on(\"click\", function(){", "  $(\".message\").html(\"Here is the message\");", "});" ], "tests": [ - "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\#getMessage(?:'|\")\\s*?\\)\\s*?\\.on\\s*?\\(\\s*?(?:'|\")click(?:'|\")\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have bound the click event to the getMessage button')", - "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\.message(?:'|\")\\s*?\\)\\s*?\\.html\\s*?\\(\\s*?(?:'|\")Here\\sis\\sthe\\smessage(?:'|\")\\s*?\\);/gi), 'You should set te value of the #message box to be the message given in the description')", - "assert(editor.match(/\\n*?\\s*?\\}\\n*?\\s*?\\);/gi) && editor.match(/\\n*?\\s*?\\}\\);/gi).length >= 2, 'Make sure that you close off all of your functions')" + "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\#getMessage(?:'|\")\\s*?\\)\\s*?\\.on\\s*?\\(\\s*?(?:'|\")click(?:'|\")\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have bound the click event to the getMessage button.')", + "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\.message(?:'|\")\\s*?\\)\\s*?\\.html\\s*?\\(\\s*?(?:'|\")Here\\sis\\sthe\\smessage(?:'|\")\\s*?\\);/gi), 'You should set te value of the #message box to be the message given in the description.')", + "assert(editor.match(/\\n*?\\s*?\\}\\n*?\\s*?\\);/gi) && editor.match(/\\n*?\\s*?\\}\\);/gi).length >= 2, 'Make sure that you close off all of your functions.')" ], "challengeSeed": [ "fccss", @@ -87,15 +65,15 @@ "    $(\".message\").html(JSON.stringify(json))", "  });", "});
      ", - "Let's make it so that the data sent from the request is appended to the .message div", + "Let's make it so that the data sent from the request is appended to the .message div.", "" ], "tests": [ - "assert(editor.match(/\\$\\s*?\\(\\s*?(\\\"|\\')\\#getMessage(\\\"|\\')\\s*?\\)\\s*?\\.\\s*?on\\s*?\\(\\s*?(\\\"|\\')click(\\\"|\\')\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have a click handler on the getMessage button to trigger the AJAX request')", - "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi), 'You should have at least on closing set of brackets and parenthesis')", - "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi) && editor.match(/\\,\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi) && editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi).length === editor.match(/\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi).length, 'Each callback function should have a closing set of brackets and parenthesis')", - "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file')", - "assert(editor.match(/\\$\\s*?\\(\\s*?\\\"\\.message\\\"\\s*?\\)\\s*?\\.\\s*?html\\s*?\\(\\s*?JSON\\s*?\\.\\s*?stringify\\s*?\\(\\s*?json\\s*?\\)\\s*?\\)/gi), 'Don\\'t forget to make the .html change the contents of the message box so that it contains the result of the getJSON')" + "assert(editor.match(/\\$\\s*?\\(\\s*?(\\\"|\\')\\#getMessage(\\\"|\\')\\s*?\\)\\s*?\\.\\s*?on\\s*?\\(\\s*?(\\\"|\\')click(\\\"|\\')\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have a click handler on the getMessage button to trigger the AJAX request.')", + "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi), 'You should have at least on closing set of brackets and parenthesis.')", + "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi) && editor.match(/\\,\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi) && editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi).length === editor.match(/\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi).length, 'Each callback function should have a closing set of brackets and parenthesis.')", + "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file.')", + "assert(editor.match(/\\$\\s*?\\(\\s*?\\\"\\.message\\\"\\s*?\\)\\s*?\\.\\s*?html\\s*?\\(\\s*?JSON\\s*?\\.\\s*?stringify\\s*?\\(\\s*?json\\s*?\\)\\s*?\\)/gi), 'Don\\'t forget to make the .html change the contents of the message box so that it contains the result of the getJSON.')" ], "challengeSeed": [ "fccss", @@ -139,7 +117,7 @@ "difficulty": 3.21, "description": [ "", - "Now that we have the data let's re-arrange it so that ", + "Now that we have the data let's re-arrange it so that it can be displayed in a user friendly way.", "", "", "  json.map(function(val){", @@ -157,7 +135,7 @@ "" ], "tests": [ - "assert(/json\\.map/gi, 'The message box should have something in it')" + "assert(/json\\.map/gi, 'The message box should have something in it.')" ], "challengeSeed": [ "fccss", @@ -215,7 +193,7 @@ "description": [ "", "instead of just placing everything in a div we should check if the value is an image.", - "If it is an image we should use it as an ima tag instead so that the image is rendered", + "If it is an image we should use it as an ima tag instead so that the image is rendered.", "", "if(key === \"imageLink\"){", "html = html + '<img class = \"' + key + '\"src = \"' + val[key] + '\">';", @@ -227,7 +205,7 @@ "" ], "tests": [ - "assert(editor.match(/imageLink/gi), 'You should have accessed the imageLink of each cat object')" + "assert(editor.match(/imageLink/gi), 'You should have accessed the imageLink of each cat object.')" ], "challengeSeed": [ "fccss", @@ -303,8 +281,8 @@ "description": [ "", "This means we should never hit API limits and it will make the process more efficient.", - "Let's try pre-filtering the json before we map it", - "We can use the pre-made filter method like this to remove the cat with the id of 1", + "Let's try pre-filtering the json before we map it.", + "We can use the pre-made filter method like this to remove the cat with the id of 1.", "", "json = json.filter(function(val){", " return(val.id !== 1);", @@ -313,7 +291,7 @@ "" ], "tests": [ - "assert(editor.match(/filter/gi), 'You should be making use of the .filter method')" + "assert(editor.match(/filter/gi), 'You should be making use of the .filter method.')" ], "challengeSeed": [ "fccss", @@ -405,7 +383,7 @@ "" ], "tests": [ - "assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'you should make use of the navigator.geolocation to access the users current location')" + "assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'you should make use of the navigator.geolocation to access the users current location.')" ], "challengeSeed": [ "fccss", From 56b7b6f29bd8979f3e7cab5b3419ba8e2752b18a Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 6 Oct 2015 15:37:43 -0700 Subject: [PATCH 028/149] improve markup and titles of challenges --- seed/challenges/json-apis-and-ajax.json | 145 ++++++++---------------- 1 file changed, 46 insertions(+), 99 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index c522e2441b..1148756772 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -5,11 +5,10 @@ { "id": "bb000000000000000000001", "title": "Trigger on click Events with jQuery", - "difficulty": 3.19, "description": [ "With jQuery we are able to get data from APIs via Ajax.", - "This data normally comes in the form of JSON.", - "Let's get the Get Message button to set the text of a div.", + "This data normally comes in the form of JSON.", + "Let's get the Get Message button to set the text of a div element.", "We will later use this to display the result of out API request.", "$(\"#getMessage\").on(\"click\", function(){", "  $(\".message\").html(\"Here is the message\");", @@ -33,13 +32,11 @@ "
      ", "

      Cat Photo Finder

      ", "
      ", - "
      ", "
      ", "
      ", " The message will go here", "
      ", "
      ", - "
      ", "
      ", "
      ", "
      \"", "", " });", " ", - " //Don't modify above here", - " ", "     $(\".message\").html(html);", " ", "   });", @@ -248,19 +214,15 @@ " });", "fcces", "", - "", - "", "
      ", "
      ", "

      Cat Photo Finder

      ", "
      ", - "
      ", "
      ", "
      ", " The message will go here", "
      ", "
      ", - "
      ", "
      ", "
      ", "
      \"", "", " });", " ", - " //Don't modify above here", - " ", "     $(\".message\").html(html);", " ", "   });", @@ -337,19 +293,16 @@ " });", "fcces", "", - "", "", "
      ", "
      ", "

      Cat Photo Finder

      ", "
      ", - "
      ", "
      ", "
      ", " The message will go here", "
      ", "
      ", - "
      ", "
      ", "
      ", "