Ponomarenko.Oleg 6 лет назад
Родитель
Сommit
233daf5e85
2 измененных файлов с 0 добавлено и 110 удалено
  1. 0 25
      hw9/index.html
  2. 0 85
      hw9/main.js

+ 0 - 25
hw9/index.html

@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-	<meta charset="UTF-8">
-	<meta name="viewport" content="width=device-width, initial-scale=1">
-	<link rel="stylesheet" href="style.css">
-	<title>Countries Cities Weather</title>
-</head>
-<body>
-        
-
-        <select name="" id="country"></select>
-        <select name="" id="city"></select>
-       
-        <div id="weather" style="padding-top:30px; padding-left: 20px; margin-top:40px;  width:250px;"></div>
-
-
-	
-	<script src="main.js"></script>
-	
-	</script>
-</body>
-</html>
-
-

+ 0 - 85
hw9/main.js

@@ -1,85 +0,0 @@
-
-var request = new XMLHttpRequest() 
-
-request.open('GET', 'https://raw.githubusercontent.com/David-Haim/CountriesToCitiesJSON/master/countriesToCities.json', true) 
-
-
-request.onreadystatechange = function(){  
-    if (request.readyState != 4){
-        return;
-    }
-
-    var mass = JSON.parse(request.responseText);
-        console.log(mass)
-
-    var country=document.getElementById('country')
-    var city=document.getElementById('city')
-    var weather=document.getElementById('weather')
-    var weather=document.getElementById('temperature')
-
-    if (request.status == 200){
-        alert('all ok')
-    
-       
-        for(key in mass){
-            var option = document.createElement('option')
-            option.innerText = key;
-            country.appendChild(option);
-            
-        }
-        
-
-        country.onchange = function(){
-            city.innerText ='';
-
-            for(i=0; i<mass[country.value].length; i++){
-            var option2 = document.createElement('option');
-            option2.innerText = mass[country.value][i];
-            city.appendChild(option2);
-            console.log(country.value); 
-
-        city.onchange = function(){
-            var reqW = "select * from weather.forecast where woeid in (select woeid from geo.places(1) where text='" + city.value +"') and u='c'"
-            var requestW = new XMLHttpRequest();
-            requestW.open('GET', "https://query.yahooapis.com/v1/public/yql?" + "q=" + encodeURIComponent(reqW) + "&format=json", true);
-            requestW.onreadystatechange = function(){
-                if(requestW.readyState !=4){
-                    return;
-                }
-                if(requestW.status == 200){
-                    alert('all ok2')
-                    var weatherCity = JSON.parse(requestW.responseText);
-                    console.log(weatherCity);
-
-                var weatherParam=document.getElementById('weather');
-                dayWeather = weatherCity.query.results.channel.item.forecast;
-                var day = " ";
-                console.log(weatherCity.query.results.channel.item.condition.text)
-                for(i = 0; i < dayWeather.length; i++){
-                    day += "<b>"+ dayWeather[i].day +" "+ dayWeather[i].date +"</b></br>" 
-                        + "Temperature from " + dayWeather[i].low + " to " + dayWeather[i].high + "</br></br>";                
-                } 
-                weatherParam.style.border="2px solid red"
-                weatherParam.style.backgroundColor="yellow"
-                weatherParam.innerHTML ="восход " +  weatherCity.query.results.channel.astronomy.sunrise
-                                    + "; закат " + weatherCity.query.results.channel.astronomy.sunset+ "</br></br>"
-                                    + day;
-
-                }   
-                else {
-                    alert('shit happens: ' +  requestW.status + ', ' + requestW.statusText );
-                }
-            }
-            requestW.send();
-        }
-    }
-          
-            
-        }
-    }
-  else {
-        alert('shit happens: ' +  request.status + ', ' + request.statusText );
-    }
-}
-
-request.send()