@@ -83,7 +83,7 @@ document.addEventListener("DOMContentLoaded", function (event) {
83
83
showLoading ( "#main-content" ) ;
84
84
$ajaxUtils . sendGetRequest (
85
85
allCategoriesUrl ,
86
- [ ... ] , // ***** <---- TODO: STEP 1: Substitute [...] ******
86
+ buildAndShowHomeHTML ( ) , // ***** <---- TODO: STEP 1: Substitute [...] ******
87
87
true ) ; // Explicitly setting the flag to get JSON from server processed into an object literal
88
88
} ) ;
89
89
// *** finish **
@@ -101,7 +101,7 @@ function buildAndShowHomeHTML (categories) {
101
101
// TODO: STEP 2: Here, call chooseRandomCategory, passing it retrieved 'categories'
102
102
// Pay attention to what type of data that function returns vs what the chosenCategoryShortName
103
103
// variable's name implies it expects.
104
- // var chosenCategoryShortName = ....
104
+ var chosenCategoryShortName = chooseRandomCategory ( categories ) . short_name ;
105
105
106
106
107
107
// TODO: STEP 3: Substitute {{randomCategoryShortName}} in the home html snippet with the
@@ -114,14 +114,14 @@ function buildAndShowHomeHTML (categories) {
114
114
// $dc.loadMenuItems('L')
115
115
// Hint: you need to surround the chosen category short name with something before inserting
116
116
// it into the home html snippet.
117
- //
118
- // var homeHtmlToInsertIntoMainPage = ....
117
+ chosenCategoryShortName = "'" + chosenCategoryShortName + "'" ;
118
+ var homeHtmlToInsertIntoMainPage = insertProperty ( homeHtml , "randomCategoryShortName" , chosenCategoryShortName ) ;
119
119
120
120
121
121
// TODO: STEP 4: Insert the the produced HTML in STEP 3 into the main page
122
122
// Use the existing insertHtml function for that purpose. Look through this code for an example
123
123
// of how to do that.
124
- // ....
124
+ insertHtml ( '#main-content' , homeHtmlToInsertIntoMainPage ) ;
125
125
126
126
} ,
127
127
false ) ; // False here because we are getting just regular HTML from the server, so no need to process JSON.
0 commit comments