improve markup and titles of challenges
This commit is contained in:
@ -5,11 +5,10 @@
|
|||||||
{
|
{
|
||||||
"id": "bb000000000000000000001",
|
"id": "bb000000000000000000001",
|
||||||
"title": "Trigger on click Events with jQuery",
|
"title": "Trigger on click Events with jQuery",
|
||||||
"difficulty": 3.19,
|
|
||||||
"description": [
|
"description": [
|
||||||
"With jQuery we are able to get data from APIs via Ajax.",
|
"With jQuery we are able to get data from APIs via Ajax.",
|
||||||
"This data normally comes in the form of JSON.",
|
"This data normally comes in the form of <code>JSON</code>.",
|
||||||
"Let's get the <code>Get Message</code> button to set the text of a div.",
|
"Let's get the <code>Get Message</code> button to set the text of a <code>div</code> element.",
|
||||||
"We will later use this to display the result of out API request.",
|
"We will later use this to display the result of out API request.",
|
||||||
"<code>$(\"#getMessage\").on(\"click\", function(){</code>",
|
"<code>$(\"#getMessage\").on(\"click\", function(){</code>",
|
||||||
"<code>  $(\".message\").html(\"Here is the message\");</code>",
|
"<code>  $(\".message\").html(\"Here is the message\");</code>",
|
||||||
@ -33,13 +32,11 @@
|
|||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <h2>Cat Photo Finder</h2>",
|
" <h2>Cat Photo Finder</h2>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12 well Message\">",
|
" <div class = \"col-xs-12 well Message\">",
|
||||||
" The message will go here",
|
" The message will go here",
|
||||||
" </div>",
|
" </div>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12\">",
|
" <div class = \"col-xs-12\">",
|
||||||
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
||||||
@ -54,19 +51,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "bb000000000000000000002",
|
"id": "bb000000000000000000002",
|
||||||
"title": "Creating HTML from Data from an AJAX request Using jQuery",
|
"title": "Create HTML from an AJAX Request",
|
||||||
"difficulty": 3.20,
|
|
||||||
"description": [
|
"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.",
|
"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.",
|
||||||
"<code>$(\"#getMessage\").on(\"click\", function() {",
|
"<code>$(\"#getMessage\").on(\"click\", function() {",
|
||||||
"  $.getJSON(\"/json/cats.json?callback=\", function( json ) {",
|
"<code>  $.getJSON(\"/json/cats.json?callback=\", function( json ) {</code>",
|
||||||
"    //Code to run when request is complete",
|
"<code>    //Code to run when request is complete</code>",
|
||||||
"    $(\".message\").html(JSON.stringify(json))",
|
"<code>    $(\".message\").html(JSON.stringify(json))</code>",
|
||||||
"  });",
|
"<code>  });</code>",
|
||||||
"});</code>",
|
"<code>});</code>",
|
||||||
"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": [
|
"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*?(\\\"|\\')\\#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.')",
|
||||||
@ -86,19 +81,15 @@
|
|||||||
" });",
|
" });",
|
||||||
"fcces",
|
"fcces",
|
||||||
"",
|
"",
|
||||||
"<!-- You shouldn't need to modify code below this line -->",
|
|
||||||
"",
|
|
||||||
"<div class=\"container-fluid\">",
|
"<div class=\"container-fluid\">",
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <h2>Cat Photo Finder</h2>",
|
" <h2>Cat Photo Finder</h2>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12 well Message\">",
|
" <div class = \"col-xs-12 well Message\">",
|
||||||
" The message will go here",
|
" The message will go here",
|
||||||
" </div>",
|
" </div>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12\">",
|
" <div class = \"col-xs-12\">",
|
||||||
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
||||||
@ -113,26 +104,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "bb000000000000000000003",
|
"id": "bb000000000000000000003",
|
||||||
"title": "Convert JSON data to HTML",
|
"title": "Convert JSON Data to HTML",
|
||||||
"difficulty": 3.21,
|
|
||||||
"description": [
|
"description": [
|
||||||
"",
|
|
||||||
"Now that we have the data let's re-arrange it so that it can be displayed in a user friendly way.",
|
"Now that we have the data let's re-arrange it so that it can be displayed in a user friendly way.",
|
||||||
"",
|
"<code>json.map(function(val) {</code>",
|
||||||
"<code>",
|
"<code>  html = html + \"<div class = 'cat'>\"</code>",
|
||||||
"  json.map(function(val){",
|
"<code>  for(var key in val) {</code>",
|
||||||
"    ",
|
"<code>    html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';</code>",
|
||||||
"    html = html + \"<div class = 'cat'>\"",
|
"<code>  }</code>",
|
||||||
"    ",
|
"<code>  html = html + \"</div><br/>\"</code>",
|
||||||
"    for(var key in val){",
|
"<code>});</code>"
|
||||||
"      html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';",
|
|
||||||
"  }",
|
|
||||||
"    ",
|
|
||||||
"    html = html + \"</div><br/>\"",
|
|
||||||
"    ",
|
|
||||||
"  });",
|
|
||||||
"</code>",
|
|
||||||
""
|
|
||||||
],
|
],
|
||||||
"tests": [
|
"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.')"
|
||||||
@ -146,13 +127,12 @@
|
|||||||
" ",
|
" ",
|
||||||
" var html = \"\";",
|
" var html = \"\";",
|
||||||
" ",
|
" ",
|
||||||
" //Add you code to modify the data here. It should add it to the html sting for use in the view",
|
" // You shouldn't need to modify code above this line.",
|
||||||
" ",
|
|
||||||
" //Don't modify above here",
|
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" //Don't modify below here",
|
" ",
|
||||||
|
" // You shouldn't need to modify code below this line.",
|
||||||
" ",
|
" ",
|
||||||
" $(\".message\").html(html);",
|
" $(\".message\").html(html);",
|
||||||
" ",
|
" ",
|
||||||
@ -162,18 +142,14 @@
|
|||||||
" });",
|
" });",
|
||||||
"fcces",
|
"fcces",
|
||||||
"",
|
"",
|
||||||
"<!-- You shouldn't need to modify code below this line -->",
|
|
||||||
"",
|
|
||||||
"<div class=\"container-fluid\">",
|
"<div class=\"container-fluid\">",
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <h2>Cat Photo Finder</h2>",
|
" <h2>Cat Photo Finder</h2>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12 well Message\">",
|
" <div class = \"col-xs-12 well Message\">",
|
||||||
" The message will go here"," </div>",
|
" The message will go here"," </div>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12\">",
|
" <div class = \"col-xs-12\">",
|
||||||
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
||||||
@ -188,21 +164,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "bb000000000000000000004",
|
"id": "bb000000000000000000004",
|
||||||
"title": "render those images!",
|
"title": "ender those images!",
|
||||||
"difficulty": 3.22,
|
|
||||||
"description": [
|
"description": [
|
||||||
"",
|
"Instead of just placing everything in a div we should check if the value is an image.",
|
||||||
"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.",
|
||||||
"<code>",
|
"<code>if(key === \"imageLink\") {</code>",
|
||||||
"if(key === \"imageLink\"){",
|
"<code>  html = html + '<img class = \"' + key + '\"src = \"' + val[key] + '\">';</code>",
|
||||||
"html = html + '<img class = \"' + key + '\"src = \"' + val[key] + '\">';",
|
"<code>} else {</code>",
|
||||||
"}",
|
"<code>  html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';</code>",
|
||||||
"else{",
|
"<code>}</code>"
|
||||||
" html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';",
|
|
||||||
"}",
|
|
||||||
"</code>",
|
|
||||||
""
|
|
||||||
],
|
],
|
||||||
"tests": [
|
"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.')"
|
||||||
@ -222,24 +192,20 @@
|
|||||||
"",
|
"",
|
||||||
" html = html + \"<div class = 'cat'>\"",
|
" html = html + \"<div class = 'cat'>\"",
|
||||||
"",
|
"",
|
||||||
"",
|
|
||||||
"",
|
|
||||||
" for(var key in val){",
|
" for(var key in val){",
|
||||||
"",
|
"",
|
||||||
" //Don't modify above here",
|
" // You shouldn't need to modify code below this line",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" //Don't modify below here",
|
" // You shouldn't need to modify code above this line",
|
||||||
"",
|
"",
|
||||||
" }",
|
" }",
|
||||||
" ",
|
" ",
|
||||||
" html = html + \"</div><br/>\"",
|
" html = html + \"</div>\"",
|
||||||
"",
|
"",
|
||||||
" });",
|
" });",
|
||||||
" ",
|
" ",
|
||||||
" //Don't modify above here",
|
|
||||||
" ",
|
|
||||||
" $(\".message\").html(html);",
|
" $(\".message\").html(html);",
|
||||||
" ",
|
" ",
|
||||||
" });",
|
" });",
|
||||||
@ -248,19 +214,15 @@
|
|||||||
" });",
|
" });",
|
||||||
"fcces",
|
"fcces",
|
||||||
"",
|
"",
|
||||||
"<!-- You shouldn't need to modify code below this line -->",
|
|
||||||
"",
|
|
||||||
"<div class=\"container-fluid\">",
|
"<div class=\"container-fluid\">",
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <h2>Cat Photo Finder</h2>",
|
" <h2>Cat Photo Finder</h2>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12 well Message\">",
|
" <div class = \"col-xs-12 well Message\">",
|
||||||
" The message will go here",
|
" The message will go here",
|
||||||
" </div>",
|
" </div>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12\">",
|
" <div class = \"col-xs-12\">",
|
||||||
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
||||||
@ -276,19 +238,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "bb000000000000000000005",
|
"id": "bb000000000000000000005",
|
||||||
"title": "Pre-filtering the JSON",
|
"title": "Prefilter your JSON",
|
||||||
"difficulty": 3.22,
|
|
||||||
"description": [
|
"description": [
|
||||||
"",
|
"",
|
||||||
"This means we should never hit API limits and it will make the process more efficient.",
|
"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.",
|
"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.",
|
"We can use the pre-made filter method like this to remove the cat with the id of 1.",
|
||||||
"<code>",
|
"<code>json = json.filter(function(val) {</code>",
|
||||||
"json = json.filter(function(val){",
|
"<code>  return(val.id !== 1);</code>",
|
||||||
" return(val.id !== 1);",
|
"<code>});</code>"
|
||||||
"});",
|
|
||||||
"</code>",
|
|
||||||
""
|
|
||||||
],
|
],
|
||||||
"tests": [
|
"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.')"
|
||||||
@ -306,15 +264,15 @@
|
|||||||
" ",
|
" ",
|
||||||
" json.map(function(val){",
|
" json.map(function(val){",
|
||||||
"",
|
"",
|
||||||
" val = \"<img src = '\" + val.imageLink + \"'/>\" ",
|
" val = \"<img src = '\" + val.imageLink + \"'/>\" ",
|
||||||
"",
|
"",
|
||||||
" html = html + \"<div class = 'cat'>\"",
|
" html = html + \"<div class = 'cat'>\"",
|
||||||
"",
|
"",
|
||||||
" //Don't modify above here",
|
" // You shouldn't need to modify code above this line",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" //Don't modify below here",
|
" // You shouldn't need to modify code below this line",
|
||||||
"",
|
"",
|
||||||
" for(var key in val){",
|
" for(var key in val){",
|
||||||
"",
|
"",
|
||||||
@ -323,12 +281,10 @@
|
|||||||
" }",
|
" }",
|
||||||
"",
|
"",
|
||||||
" ",
|
" ",
|
||||||
" html = html + \"</div><br/>\"",
|
" html = html + \"</div>\"",
|
||||||
"",
|
"",
|
||||||
" });",
|
" });",
|
||||||
" ",
|
" ",
|
||||||
" //Don't modify above here",
|
|
||||||
" ",
|
|
||||||
" $(\".message\").html(html);",
|
" $(\".message\").html(html);",
|
||||||
" ",
|
" ",
|
||||||
" });",
|
" });",
|
||||||
@ -337,19 +293,16 @@
|
|||||||
" });",
|
" });",
|
||||||
"fcces",
|
"fcces",
|
||||||
"",
|
"",
|
||||||
"<!-- You shouldn't need to modify code below this line -->",
|
|
||||||
"",
|
"",
|
||||||
"<div class=\"container-fluid\">",
|
"<div class=\"container-fluid\">",
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <h2>Cat Photo Finder</h2>",
|
" <h2>Cat Photo Finder</h2>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12 well Message\">",
|
" <div class = \"col-xs-12 well Message\">",
|
||||||
" The message will go here",
|
" The message will go here",
|
||||||
" </div>",
|
" </div>",
|
||||||
" </div>",
|
" </div>",
|
||||||
" <br/>",
|
|
||||||
" <div class = \"row text-center\">",
|
" <div class = \"row text-center\">",
|
||||||
" <div class = \"col-xs-12\">",
|
" <div class = \"col-xs-12\">",
|
||||||
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
" <button id = \"getMessage\" class = \"btn btn-primary\">",
|
||||||
@ -365,25 +318,19 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "bb000000000000000000006",
|
"id": "bb000000000000000000006",
|
||||||
"title": "Getting Geo-location data for use in APIs",
|
"title": "Get Geo-location Data",
|
||||||
"difficulty": 3.19,
|
|
||||||
"description": [
|
"description": [
|
||||||
"",
|
|
||||||
"We can access the users current location by using the built in navigator in the browser.",
|
"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.",
|
"The navigator will get the users current longitude and latitude with a decent level of accuracy.",
|
||||||
"<code>",
|
"<code>if (navigator.geolocation) {</code>",
|
||||||
"if (navigator.geolocation) {",
|
"<code>  navigator.geolocation.getCurrentPosition(function(position) {</code>",
|
||||||
"  navigator.geolocation.getCurrentPosition(function(position){",
|
"<code>    // Do something in here with the coordinates</code>",
|
||||||
"    // Do something in here with the coordinates!",
|
"<code>    $(\"#data\").html(\"latitiude\" + position.coords.latitude + \"longitude\" + position.coords.longitude);</code>",
|
||||||
"    ",
|
"<code>  });</code>",
|
||||||
"    $(\"#data\").html(\"latitiude\" + position.coords.latitude + \"longitude\" + position.coords.longitude);",
|
"<code>}</code>"
|
||||||
"    ",
|
|
||||||
"  });",
|
|
||||||
"}",
|
|
||||||
"</code>"
|
|
||||||
],
|
],
|
||||||
"tests": [
|
"tests": [
|
||||||
"assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'you should make use of the <code>navigator.geolocation</code> to access the users current location.')"
|
"assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'You should make use of the <code>navigator.geolocation</code> to access the users current location.')"
|
||||||
],
|
],
|
||||||
"challengeSeed": [
|
"challengeSeed": [
|
||||||
"fccss",
|
"fccss",
|
||||||
|
Reference in New Issue
Block a user