Skip to content

Commit 0994f31

Browse files
committed
assignment-5
1 parent 443e690 commit 0994f31

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mod5/js/script.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ document.addEventListener("DOMContentLoaded", function (event) {
8383
showLoading("#main-content");
8484
$ajaxUtils.sendGetRequest(
8585
allCategoriesUrl,
86-
[...], // ***** <---- TODO: STEP 1: Substitute [...] ******
86+
buildAndShowHomeHTML(), // ***** <---- TODO: STEP 1: Substitute [...] ******
8787
true); // Explicitly setting the flag to get JSON from server processed into an object literal
8888
});
8989
// *** finish **
@@ -101,7 +101,7 @@ function buildAndShowHomeHTML (categories) {
101101
// TODO: STEP 2: Here, call chooseRandomCategory, passing it retrieved 'categories'
102102
// Pay attention to what type of data that function returns vs what the chosenCategoryShortName
103103
// variable's name implies it expects.
104-
// var chosenCategoryShortName = ....
104+
var chosenCategoryShortName = chooseRandomCategory(categories).short_name;
105105

106106

107107
// TODO: STEP 3: Substitute {{randomCategoryShortName}} in the home html snippet with the
@@ -114,14 +114,14 @@ function buildAndShowHomeHTML (categories) {
114114
// $dc.loadMenuItems('L')
115115
// Hint: you need to surround the chosen category short name with something before inserting
116116
// it into the home html snippet.
117-
//
118-
// var homeHtmlToInsertIntoMainPage = ....
117+
chosenCategoryShortName = "'" + chosenCategoryShortName + "'";
118+
var homeHtmlToInsertIntoMainPage = insertProperty(homeHtml, "randomCategoryShortName", chosenCategoryShortName);
119119

120120

121121
// TODO: STEP 4: Insert the the produced HTML in STEP 3 into the main page
122122
// Use the existing insertHtml function for that purpose. Look through this code for an example
123123
// of how to do that.
124-
// ....
124+
insertHtml('#main-content' , homeHtmlToInsertIntoMainPage);
125125

126126
},
127127
false); // False here because we are getting just regular HTML from the server, so no need to process JSON.

0 commit comments

Comments
 (0)