Selaa lähdekoodia

Filtered for Golden Gate Bridge Movies

Nick Satinover 7 vuotta sitten
vanhempi
commit
5650b87ebc
7 muutettua tiedostoa jossa 86 lisäystä ja 0 poistoa
  1. 9
    0
      .idea/JSON-Lab-2.iml
  2. 6
    0
      .idea/misc.xml
  3. 8
    0
      .idea/modules.xml
  4. 6
    0
      .idea/vcs.xml
  5. 28
    0
      GoldenGateBridge.js
  6. 28
    0
      Practice.js
  7. 1
    0
      index.html

+ 9
- 0
.idea/JSON-Lab-2.iml Näytä tiedosto

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module type="JAVA_MODULE" version="4">
3
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+    <exclude-output />
5
+    <content url="file://$MODULE_DIR$" />
6
+    <orderEntry type="inheritedJdk" />
7
+    <orderEntry type="sourceFolder" forTests="false" />
8
+  </component>
9
+</module>

+ 6
- 0
.idea/misc.xml Näytä tiedosto

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="JavaScriptSettings">
4
+    <option name="languageLevel" value="ES6" />
5
+  </component>
6
+</project>

+ 8
- 0
.idea/modules.xml Näytä tiedosto

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/.idea/JSON-Lab-2.iml" filepath="$PROJECT_DIR$/.idea/JSON-Lab-2.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 6
- 0
.idea/vcs.xml Näytä tiedosto

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="" vcs="Git" />
5
+  </component>
6
+</project>

+ 28
- 0
GoldenGateBridge.js Näytä tiedosto

@@ -0,0 +1,28 @@
1
+var url = "https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD";
2
+var xmlhttp = new XMLHttpRequest();
3
+var data;
4
+var listGateMovies = "";
5
+
6
+xmlhttp.open("GET", url, true);
7
+
8
+xmlhttp.onreadystatechange = function() {
9
+    if (this.readyState == 4 && this.status == 200) {
10
+        console.log(xmlhttp.response);
11
+        data = JSON.parse(this.responseText);
12
+        var movieArr = data.data;
13
+        movieFunction(movieArr);
14
+    }
15
+};
16
+
17
+xmlhttp.send();
18
+
19
+
20
+function movieFunction(movieArr) {
21
+    var match = "Golden Gate Bridge";
22
+    for(var i = 0; i < movieArr.length; i++) {
23
+        if (movieArr[i][10] === match)
24
+            listGateMovies += movieArr[i][8] + ' ' + movieArr[i][9] + ' ' + movieArr[i][12] + '<br>';
25
+    }
26
+    document.getElementById("result").innerHTML = listGateMovies;
27
+
28
+}

+ 28
- 0
Practice.js Näytä tiedosto

@@ -0,0 +1,28 @@
1
+var url = "https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD";
2
+var xmlhttp = new XMLHttpRequest();
3
+var data;
4
+var listGateMovies = "";
5
+
6
+xmlhttp.open("GET", url, true);
7
+
8
+xmlhttp.onreadystatechange = function() {
9
+    if (this.readyState == 4 && this.status == 200) {
10
+        console.log(xmlhttp.response);
11
+        data = JSON.parse(this.responseText);
12
+        var movieArr = data.data;
13
+        movieFunction(movieArr);
14
+    }
15
+};
16
+
17
+xmlhttp.send();
18
+
19
+
20
+function movieFunction(movieArr) {
21
+    var match = "Golden Gate Bridge";
22
+    for(var i = 0; i < movieArr.length; i++) {
23
+        if (movieArr[i][10] === match)
24
+        listGateMovies += movieArr[i][8] + ' ' + movieArr[i][9] + ' ' + movieArr[i][12] + '<br>';
25
+    }
26
+    document.getElementById("result").innerHTML = listGateMovies;
27
+
28
+}

+ 1
- 0
index.html Näytä tiedosto

@@ -38,5 +38,6 @@
38 38
     	<h1>Movie Information</h1>
39 39
     	<div id="result"></div>
40 40
     </section>
41
+    <script type="text/javascript" src="GoldenGateBridge.js"></script>
41 42
 </body>
42 43
 </html>