|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+<!DOCTYPE html>
|
|
|
2
|
+<html lang="en">
|
|
|
3
|
+<head>
|
|
|
4
|
+ <meta charset="UTF-8">
|
|
|
5
|
+ <link href="./css/style.css" type="text/css" rel="stylesheet">
|
|
|
6
|
+ <title>Import Local JSON Data | Zipcode Wilmington</title>
|
|
|
7
|
+</head>
|
|
|
8
|
+<body>
|
|
|
9
|
+<header class="main-header group">
|
|
|
10
|
+ <div class="title"><h1>Zipcode Wilmington<br>Javascript Lab - Fall 2015</h1></div>
|
|
|
11
|
+ <div class="lesson-link"><img src="./images/logos/js_logo.png" alt="Javascript"/></div>
|
|
|
12
|
+ <div class="zip-link"><img src="./images/logos/zip_logo.jpg" alt="Zipcode Wilmington"/></div>
|
|
|
13
|
+</header>
|
|
|
14
|
+
|
|
|
15
|
+<article>
|
|
|
16
|
+ <h1>Instructions</h1>
|
|
|
17
|
+ <p>Us the <code>XMLHttpRequest()</code> to receive the remote json feed from the following website<br>
|
|
|
18
|
+ https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD
|
|
|
19
|
+ </p>
|
|
|
20
|
+
|
|
|
21
|
+ <p>The json feed list movies made in San Francisco</p>
|
|
|
22
|
+
|
|
|
23
|
+ <p>Write the following info for each movie to the webpage:
|
|
|
24
|
+ <ul>
|
|
|
25
|
+ <li>movie title</li>
|
|
|
26
|
+ <li>release year</li>
|
|
|
27
|
+ <li>production company</li>
|
|
|
28
|
+ </ul>
|
|
|
29
|
+ </p>
|
|
|
30
|
+
|
|
|
31
|
+ <p>Only list movies that were made at the Golden Gate Bridge</p>
|
|
|
32
|
+
|
|
|
33
|
+ <p>Use <code>document.getElementById('result').innerHTML += <i>your_output</i>;</code> to write the movie's info to the page.</p>
|
|
|
34
|
+ <p>Append <code>"<br>"</code> to output code to create a new line</p>
|
|
|
35
|
+</article>
|
|
|
36
|
+
|
|
|
37
|
+<section>
|
|
|
38
|
+ <h1>Movie Information</h1>
|
|
|
39
|
+ <div id="result"></div>
|
|
|
40
|
+</section>
|
|
|
41
|
+<script>
|
|
|
42
|
+ var xmlhttp = new XMLHttpRequest();
|
|
|
43
|
+ var url = "https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD";
|
|
|
44
|
+ var data;
|
|
|
45
|
+ var listGateMovies = "";
|
|
|
46
|
+
|
|
|
47
|
+ xmlhttp.open("GET", url, true);
|
|
|
48
|
+
|
|
|
49
|
+ xmlhttp.onreadystatechange = function () {
|
|
|
50
|
+ if (xmlhttp.readyState == 4 && xmlhttp.status === 200){
|
|
|
51
|
+ data = JSON.parse(this.responseText);
|
|
|
52
|
+ var movieArr = data.data;
|
|
|
53
|
+ movieFunction(movieArr);
|
|
|
54
|
+ }
|
|
|
55
|
+ }
|
|
|
56
|
+
|
|
|
57
|
+ xmlhttp.send();
|
|
|
58
|
+
|
|
|
59
|
+ function movieFunction(movieArr) {
|
|
|
60
|
+ for(var i = 0; i < movieArr.length; i++) {
|
|
|
61
|
+ if (movieArr[i][10] === "Golden Gate Bridge") {
|
|
|
62
|
+ listGateMovies +=
|
|
|
63
|
+ movieArr[i][8] + ' ' +
|
|
|
64
|
+ movieArr[i][9] + ' ' +
|
|
|
65
|
+ movieArr[i][12] + '<br>';
|
|
|
66
|
+
|
|
|
67
|
+ }
|
|
|
68
|
+ }
|
|
|
69
|
+ document.getElementById("result").innerText = listGateMovies;
|
|
|
70
|
+ }
|
|
|
71
|
+
|
|
|
72
|
+</script>
|
|
|
73
|
+</body>
|
|
|
74
|
+</html>
|