Skip to content

Commit ccdd28e

Browse files
authored
Merge pull request #41 from VinayApposite/Apposite_20480C_Mod09_LM
Apposite 20480 c mod09 lm
2 parents 91a1cd4 + 5e155b7 commit ccdd28e

File tree

1 file changed

+75
-72
lines changed

1 file changed

+75
-72
lines changed

Instructions/20480C_MOD09_LAB_MANUAL.md

Lines changed: 75 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
#### Scenario
66

7-
The conference organizers are concerned that the venue has poor Wi-Fi coverage in some locations, meaning that attendees might not always be able to access the conference website on their tablets and laptops. The Schedule page is especially important because attendees need to know when sessions are running.
7+
The conference organizers are concerned that the venue has poor Wi-Fi coverage in some locations, so the attendees might not always be able to access the conference website on their tablets and laptops. The **Schedule** page is especially important because attendees need to know when sessions are running.
88

99
You have decided to make parts of the web application available offline by using the offline web application features of HTML5. After an attendee has visited the online website once, their browser will have downloaded and cached the important pages. If a Wi-Fi connection is unavailable, the attendee will still be able to view the website by using the cached information.
1010

1111
#### Objectives
1212

1313
After completing this lab, you will be able to:
1414

15-
- Use the Application Cache API to make web pages available offline.
15+
- Use the Application Cache API to make webpages available offline.
1616
- Use the Local Storage API to persist user data locally between browser sessions.
1717

1818
#### Lab Setup
@@ -25,142 +25,145 @@ Estimated Time: **60 minutes**
2525

2626
In this exercise, you will make the **Home**, **About**, **Schedule**, and **Location** pages available offline.
2727

28-
First, you will complete the creation of an application manifest file, which lists all of the files that should be cached for offline access. Next, you will reference the manifest file from the **Home**, **About**, **Schedule**, and **Location** pages. Then, you will write JavaScript code that adapts the page navigation, hiding links to pages that are not available offline. Finally, you will run the application and view the **Schedule** page. You will stop the web server and then reload the **Schedule** page to verify that it works offline.
28+
First, you will complete the creation of an application manifest file, which lists all the files that should be cached for offline access. Next, you will reference the manifest file from the **Home**, **About**, **Schedule**, and **Location** pages. Then, you will write a JavaScript code that adapts the page navigation, hiding links to pages that are not available offline. Finally, you will run the application and view the **Schedule** page. You will stop the web server, and then reload the **Schedule** page to verify that it works offline.
2929

30-
#### Task 1: Configure the application cache manifest.
30+
#### Task 1: Configure the application cache manifest
3131

32-
1. Configure Microsoft Edge to enable support for application caching:
32+
1. To enable support for application caching, configure Microsoft Edge:
3333
- Start Microsoft Edge.
34-
- In the Microsoft Edge, press F10 to display the menu bar.
34+
- To display the menu bar, in Microsoft Edge, press F10.
3535
- On the **Tools** menu, click **Internet options**.
3636
- In the **Internet Options** dialog box, click **Settings**.
3737
- In the **Website Data Settings** dialog box, click the **Caches and databases** tab.
3838
- Select the **Allow website caches and databases** check box, and then click **OK**.
3939
- In the **Internet Options** dialog box, click **OK**.
4040
- Close Microsoft Edge.
41-
2. Start Visual Studio and open the **ContosoConf.sln** solution from the **Allfiles\Mod09\Labfiles\Starter\Exercise 1** folder.
42-
3. Open the **appcache.manifest** file. This file contains a partial application manifest that lists the resources a web browser must cache for offline access.
43-
4. After the comment near the start of the file, insert the following URLs to cache the **Home**, **About**, **Schedule**, and **Location** pages:
44-
```javascript
41+
2. Start Microsoft Visual Studio.
42+
3. Browse to **Allfiles\Mod09\Labfiles\Starter\Exercise 1**, and then open the **ContosoConf.sln** solution.
43+
4. Open the **appcache.manifest** file. This file contains a partial application manifest that lists the resources that a web browser must cache for offline access.
44+
5. After the comment near the start of the file, insert the following URLs to cache the **Home**, **About**, **Schedule**, and **Location** pages:
45+
```javascript
4546
/index.htm
4647
/about.htm
4748
/location.htm
4849
/schedule.htm
49-
```
50-
5. Add the **manifest="/appcache.manifest"** attribute to the **<html>** element of the **Home**, **About**, **Schedule**, and **Location** pages. These are the pages that will operate offline by using the application cache.
50+
```
51+
6. Add the **manifest="/appcache.manifest"** attribute to the **<html>** element of the **Home**, **About**, **Schedule**, and **Location** pages. These are the pages that will operate offline by using the application cache.
5152

52-
#### Task 2: Detect offline mode by using JavaScript code.
53+
#### Task 2: Detect offline mode by using JavaScript code
5354

54-
1. Open **offline.js** file in the **scripts** folder. This script contains methods that hide or show links depending on whether a page is currently running in online or offline mode. The pages that support offline mode reference this script.
55-
2. After the comment // TODO: if currently offline, hide navigation links that require online, add JavaScript code to detect if the web browser is currently offline, and call the **hideLinksThatRequireOnline()** function.
56-
- Examine the **navigator.onLine** property to determine whether the browser is online of offline.
57-
3. After the comment that starts with // TODO: add onoffline and ononline events to document.body, handle the **ononline** and **onoffline** events for the document body; call the **hideLinksThatRequireOnline** and **showLinks** functions as appropriate.
58-
4. After the comment // TODO: also handle the applicationCache error event to hide links, add an event listener to the **applicationCache error** event, which calls the **hideLinksThatRequireOnline** function.
55+
1. In the **scripts** folder, open the **offline.js** file. This script contains methods that hide or show links depending on whether a page is currently running in the online or offline mode. The pages that support the offline mode reference this script.
56+
2. After the __// TODO:__ comment, if currently in the offline mode, hide navigation links that require the online mode, add JavaScript code to detect if the web browser is currently offline, and then call the **hideLinksThatRequireOnline()** function.
57+
- Examine the **navigator.onLine** property to determine whether the browser is online or offline.
58+
3. After the comment that starts with __// TODO:__, add the **onoffline** and **ononline** events to **document.body**, handle the **ononline** and **onoffline** events for the document body, and then call the **hideLinksThatRequireOnline** and **showLinks** functions as appropriate.
59+
4. After the __// TODO:__ comment, handle the **applicationCache** error event to hide links, and then add an event listener to the **applicationCache error** event, which calls the **hideLinksThatRequireOnline** function.
5960

60-
#### Task 3: Test the application.
61+
#### Task 3: Test the application
6162

62-
1. Run the application and view the **index.htm** page.
63-
2. Expand the Windows notification area, right click **IIS Express**, and then click **Exit**. Allow IIS Express to exit when prompted.
63+
1. Run the application, and then open the **index.htm** page.
64+
2. Expand the Windows notification area, right-click **IIS Express**, and then select **Exit**. Allow **IIS Express** to exit when prompted.
6465

65-
>**Note:** When IIS Express first starts running, the IIS Express icon may appear in the Windows task bar rather than the notification area. If this occurs, right-click the **IIS Express** icon and then click **Exit**.
66+
>**Note**: When **IIS Express** first starts running, the **IIS Express** icon may appear in the taskbar rather than the notification area. If this occurs, right-click the **IIS Express** icon, and then select **Exit**.
6667
6768
![alt text](./Images/20480B_9_IIS-Express.png "The IIS Express icon in the Windows notification area")
6869

69-
3. In Microsoft Edge, view the **Schedule** page. Verify that the page loads and displays the schedule information. Also verify that, after a brief delay, the **Register** link in the navigation bar is removed. This occurs because the Register page is not cached (it is not included in the **appcache.manifest** file), and registration requires an active connection to the web site.
70-
4. View the **About** page and verify that this page displays correctly, and that the **Register** link disappears from the navigation bar.
70+
3. In Microsoft Edge, open the **Schedule** page. Verify that the page loads and displays the schedule information. Also verify that after a brief delay, the **Register** link in the navigation bar is removed. This occurs because the **Register** page is not cached (it is not included in the **appcache.manifest** file), and registration requires an active connection to the website.
71+
4. View the **About** page, verify that this page displays correctly, and then verify that the **Register** link disappears from the navigation bar.
7172
5. Close Microsoft Edge.
7273

73-
>**Results:** After completing this exercise, you will have modified the web application and made the **Home**, **About**, **Schedule**, and **Location** pages available offline.
74+
>**Results**: After completing this exercise, you will have modified the web application and made the **Home**, **About**, **Schedule**, and **Location** pages available offline.
7475
75-
### Exercise 2: Persisting User Data by Using the Local Storage API.
76+
### Exercise 2: Persisting User Data by Using the Local Storage API
7677

7778
#### Scenario
7879

79-
Currently, the **Schedule** page is able to display sessions when offline, but this information does not include whether the attendee selected the session by using the star icon. This information is stored on a remote server that is inaccessible when the application is running offline. However, attendees also need to see the sessions they have selected. This information should be saved locally on an attendee’s computer, so it is available offline.
80+
Currently, the **Schedule** page is able to display sessions when offline, but this information does not include whether the attendee selected the session by using the star icon. This information is stored on a remote server that is inaccessible when the application is running offline. However, attendees also need to see the sessions they have selected. This information should be saved locally on an attendee’s computer, so that it is available offline.
8081

81-
In this exercise, you will update the JavaScript code for the Schedule page to record an attendee's selected sessions. You will create an object that wraps the Local Storage API. Then you will use this wrapper to save information locally about starred sessions. Finally, you will run the application, view the Schedule page, and verify that the starred sessions are persisted even when the web server is not available.
82+
In this exercise, you will update the JavaScript code for the **Schedule** page to record an attendee's selected sessions. You will create an object that wraps the Local Storage API. Then, you will use this wrapper to save information locally about starred sessions. Finally, you will run the application, view the **Schedule** page, and then verify that the starred sessions are persisted even when the web server is not available.
8283

83-
>**Note:** The Local Storage API is very simple. It can only save and load string key-value pairs. Persisting more complex data requires serialization. In this exercise, you will use a wrapper around the Local Storage API.
84+
>**Note**: The Local Storage API is very simple. It can only save and load string key-value pairs. Persisting more complex data requires serialization. In this exercise, you will use a wrapper around the Local Storage API.
8485
85-
#### Task 1: Observe the current behavior of the Schedule page.
86+
#### Task 1: Observe the current behavior of the Schedule page
8687

87-
1. In Visual Studio, open the **ContosoConf.sln** solution in the **Allfiles\Mod09\Labfiles\Starter\Exercise 2** folder.
88-
2. Run the application and view the **schedule.htm** page.
89-
3. Close IIS Express by using the icon in the Windows notification area.
90-
4. On the Schedule page, click some of the stars, and then refresh the page.
91-
5. Notice that information about which sessions are starred is not saved when the application is running offline (the yellow stars turn white again).
92-
6. Close Microsoft Edge.
88+
1. In Visual Studio, browse to **Allfiles\Mod09\Labfiles\Starter\Exercise 2**, and then open the **ContosoConf.sln** solution.
89+
2. Run the application, and then open the **schedule.htm** page.
90+
3. Close **IIS Express** by using the icon in the Windows notification area.
91+
4. On the **Schedule** page, click some of the stars, and then refresh the page.
92+
Notice that the application does not save the information about which sessions are starred when the application is running offline (the yellow stars turn white again).
93+
5. Close Microsoft Edge.
9394

94-
#### Task 2: Save information about starred session to local storage.
95+
#### Task 2: Save information about starred sessions to local storage
9596

96-
1. In the **scripts** folder, open the **LocalStarStorage.js** file. The code in this file wraps the Local Storage API to provide a higher-level interface used by the application code.
97+
1. In the **scripts** folder, open the **LocalStarStorage.js** file. To provide a higher-level interface used by the application code, the code in this file wraps the Local Storage API.
9798

98-
>**Note:** The Schedule page will use the **addStar**, **removeStar**, **isStarred**, and **initialize** functions defined in this file. These functions in turn call the **save** and **load** methods that you will implement in this task.
99+
>**Note**: The **Schedule** page will use the **addStar**, **removeStar**, **isStarred**, and **initialize** functions defined in this file. These functions call the **save** and **load** methods that you will implement in this task.
99100
100101
2. Implement the **LocalStarStorage save** method.
101-
- The IDs of the starred sessions to be saved are held in the array **this.sessions**.
102-
- Convert the array to a string by using the **JSON.stringify** function, and save this string to local storage with the key **stars**.
102+
- The IDs of the starred sessions to be saved are held in the **this.sessions** array.
103+
- Convert the array to a string by using the **JSON.stringify** function.
104+
- Save this string to local storage with the **stars** key.
103105

104-
#### Task 3: Load information about starred session from local storage.
106+
#### Task 3: Load information about starred sessions from local storage
105107

106-
1. In the **LocalStarStorage.js** file, implement the **LocalStarStorage load** method.
107-
- Get the **stars** item from local storage.
108-
- Parse the JSON string into an array and assign it to **this.sessions**.
109-
- Handle the cases when the local storage returns no data or invalid JSON. In these situations, set **this.sessions** to be an empty array.
108+
In the **LocalStarStorage.js** file, implement the **LocalStarStorage load** method.
109+
- Get the **stars** item from local storage.
110+
- Parse the JSON string into an array, and then assign it to **this.sessions**.
111+
- Handle the cases when the local storage returns no data or a JavaScript Object Notation (JSON) that is not valid. In these situations, set **this.sessions** to be an empty array.
110112

111-
#### Task 4: Use the local storage wrapper to save and load data in the Schedule page.
113+
#### Task 4: Use the local storage wrapper to save and load data in the Schedule page
112114

113115
1. In the **scripts** folder, open the **ScheduleItem.js** page.
114116
2. In the **initialize** method, find the following comment:
115-
```javascript
117+
```javascript
116118
// TODO: Check if item is starred
117-
```
118-
3. Add JavaScript code after this comment to:
119-
- Detect whether the session identified by **this.id** is starred (use the **isStarred** method of the **localStarStorage** object).
120-
- If the session is starred, tag the element with the **starred** CSS class so that it is rendered correctly (use the statement this.element.classList.add(this.starredClass);).
119+
```
120+
3. Add a JavaScript code after this comment:
121+
- To detect whether the session identified by **this.id** is starred, use the **isStarred** method of the **localStarStorage** object.
122+
- If the session is starred, to tag the element with the **starred** CSS class so that it is rendered correctly, use the **this.element.classList.add(this.starredClass);)** statement.
121123
4. In the **unsetStar** method, find the following comment:
122-
```javascript
124+
```javascript
123125
// TODO: remove the star from the item
124-
```
125-
5. After this comment, add JavaScript code to remove the star from the session identified by **this.id**. Use the **removeStar** method of the **localStarStorage** object.
126+
```
127+
5. After this comment, to remove the star from the session identified by **this.id**, add a JavaScript code. Use the **removeStar** method of the **localStarStorage** object.
126128
6. In the **setStar** method, find the following comment:
127-
```javascript
129+
```javascript
128130
// TODO: add a star to the item
129-
```
130-
7. After this comment, add JavaScript code to add a star to the session identified by **this.id**. Use the **addStar** method of the **localStarStorage** object.
131+
```
132+
7. After this comment, to add a star to the session identified by **this.id**, add a JavaScript code. Use the **addStar** method of the **localStarStorage** object.
131133

132-
#### Task 5: Test the application.
134+
#### Task 5: Test the application
133135

134-
1. Open the appcache.manifest file and insert a version comment near the top of the file. As follows:
135-
```javascript
136+
1. Open the **appcache.manifest** file, and then insert a version comment near the top of the file. As follows:
137+
```javascript
136138
CACHE MANIFEST
137139
# version 2
138140

139141
...
140-
```
142+
```
141143

142-
>**Note:** The JavaScript files are listed in **appcache.manifest**, and they will have been cached by the web browser. Making a change to the **appcache.manifest** file forces the browser to download the updated scripts.
144+
>**Note**: The JavaScript files are listed in **appcache.manifest**, and they will have been cached by the web browser. Making a change to the **appcache.manifest** file forces the browser to download the updated scripts.
143145
144-
2. Run the application and view the **schedule.htm** page.
145-
3. In Microsoft Edge, refresh the page to ensure the updated scripts are used.
146-
4. Close IIS Express by using the icon in the Windows notification area.
147-
5. On the **Schedule** page, click some of the stars, and then refresh the page.
148-
6. Verify that the same sessions are still starred.
149-
7. Close Microsoft Edge.
146+
2. Run the application.
147+
3. Open the **schedule.htm** page.
148+
4. In Microsoft Edge, refresh the page to ensure the updated scripts are used.
149+
5. Close **IIS Express** by using the icon in the Windows notification area.
150+
6. On the **Schedule** page, click some of the stars, and then refresh the page.
151+
7. Verify that the same sessions are still starred.
152+
8. Close Microsoft Edge.
150153

151-
#### Task 6: Reset Microsoft Edge caching.
154+
#### Task 6: Reset Microsoft Edge caching
152155

153156
1. Configure Microsoft Edge to disable support for application caching:
154157
- Start Microsoft Edge.
155-
- In the Microsoft Edge, press F10 to display the menu bar.
158+
- In Microsoft Edge, to display the menu bar, press F10.
156159
- On the **Tools** menu, click **Internet options**.
157160
- In the **Internet Options** dialog box, click **Settings**.
158161
- In the **Website Data Settings** dialog box, click the **Caches and databases** tab.
159162
- Clear the **Allow website caches and databases** check box, and then click **OK**.
160163
- In the **Internet Options** dialog box, click **OK**.
161164
- Close Microsoft Edge.
162165

163-
>**Result:** After completing this exercise, you will have updated the Schedule page to locally record starred sessions.
166+
>**Result**: After completing this exercise, you will have updated the **Schedule** page to locally record starred sessions.
164167
165168
©2018 Microsoft Corporation. All rights reserved.
166169

0 commit comments

Comments
 (0)