Nina 6 år sedan
förälder
incheckning
e620efce13

+ 1 - 0
City/nbproject/private/private.properties

@@ -0,0 +1 @@
+browser=Chrome.INTEGRATED

+ 9 - 0
City/nbproject/private/private.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
+    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
+        <group>
+            <file>file:/C:/Users/Ганц%20Гигагерц/Documents/NetBeansProjects/City/public_html/index.html</file>
+        </group>
+    </open-files>
+</project-private>

+ 5 - 0
City/nbproject/project.properties

@@ -0,0 +1,5 @@
+file.reference.City-public_html=public_html
+file.reference.City-test=test
+files.encoding=UTF-8
+site.root.folder=${file.reference.City-public_html}
+test.folder=${file.reference.City-test}

+ 9 - 0
City/nbproject/project.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.web.clientproject</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/clientside-project/1">
+            <name>City</name>
+        </data>
+    </configuration>
+</project>

+ 58 - 0
City/public_html/index.html

@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>TODO supply a title</title>
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    </head>
+    <body>
+   <select name="s1" id="s1"></select>
+   <select name="c1" id="c1"></select>
+    <p id='ww'></p>
+        <script>
+var xhr = new XMLHttpRequest();
+xhr.open('GET', 'https://raw.githubusercontent.com/David-Haim/CountriesToCitiesJSON/master/countriesToCities.json', false);
+xhr.send();
+
+if (xhr.status !== 200) {alert( xhr.status+xhr.statusText);} else {var sP = JSON.parse(xhr.responseText);};
+
+var v1 = document.getElementById('s1');
+for (let key in sP) {
+	let optC = document.createElement('option');
+	v1.appendChild(optC);
+	optC.innerHTML = key;
+	optC.value = key;
+};
+
+var v2 = document.getElementById('c1');
+
+v1.onchange = function () {
+	var tv1 = v1.value;
+	while (v2.firstChild) {
+		v2.removeChild(v2.firstChild);
+	}
+	for (let i = 0; i <sP[tv1].length; i++) {
+		let optS = document.createElement('option');
+		v2.appendChild(optS);
+		optS.innerHTML = sP[tv1][i];
+		optS.value = sP[tv1][i];}};
+        
+v2.onchange = function () {
+	var headV = v2.value;
+	var xhr = new XMLHttpRequest();
+	var request = "select * from weather.forecast where woeid in (select woeid from geo.places(1) where text=\"" + headV + "\") and u='c'";
+	request = encodeURIComponent(request);
+	xhr.open('GET', 'https://query.yahooapis.com/v1/public/yql?q=' + request + '&format=json', false);
+	xhr.send();
+	if (xhr.status !== 200) {
+	  alert( xhr.status + ': ' + xhr.statusText);
+	} else {
+	  let ww1 = JSON.parse(xhr.responseText); 
+	  let ww2= document.getElementById('ww');
+	  let ww3 = ww1.query.results.channel.item.description;
+	  ww2.innerHTML = ww3;
+	}
+};
+    </script>
+    </body>
+</html>