Created
August 31, 2016 08:50
-
-
Save jimmy89Li/a1b9eacbb7994ba31047f37af245bd38 to your computer and use it in GitHub Desktop.
Set weather icon based on the forecast, using "meteocons" font type (http://www.alessioatzeni.com/meteocons/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.getJSON('http://api.wunderground.com/api/API_KEY/conditions/q/CITY_NAME.json', function(Weather) { | |
| var weatherInfo = Weather.current_observation; | |
| var weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon="1">'; | |
| if(weatherInfo.weather === 'Partly Cloudy') { | |
| weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon="3">'; | |
| } | |
| else if (weatherInfo.weather === 'Mostly Cloudy') { | |
| weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon="5">'; | |
| } | |
| else if (weatherInfo.weather === 'Rain') { | |
| weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon="8">'; | |
| } | |
| else if (weatherInfo.weather === 'Snow') { | |
| weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon="#">'; | |
| } | |
| else if (weatherInfo.weather === 'Thunderstorm') { | |
| weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon="6">'; | |
| } | |
| else { | |
| weatherIcon = '<span id="weatherIcon" class="meteoIcon" data-icon=")">'; | |
| } | |
| document.getElementById('weatherIcon').innerHTML = weatherIcon; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment