Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
// TODO: insert your API key and location code (example location code: pws:KNYNEWYO118)
var weatherURL = "http://api.wunderground.com/api/YOUR_API_KEY_HERE/conditions/q/YOUR_LOCATION_CODE_HERE.json";
var forecastURL = "http://api.wunderground.com/api/YOUR_API_KEY_HERE/forecast/q/YOUR_LOCATION_CODE_HERE.json";
var weatherUnit = "c" // c for celcius / f for farenheit
// Logging level (0 = off, 1 = ajax errors only, 2 = some logging, 3 = full logging)
// This logs to the developer console: in Google Chrome, press F12 and make sure the "Console" tab is selected
var loggingLevel = 3;
Expand Down
28 changes: 22 additions & 6 deletions js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,13 @@ function GetWeatherConditions()
// The weather service sends back a lot of data, but we'll only use some
$("#observation_icon").attr("src", "weather/" + data.current_observation.icon + ".png");
$("#observation_weather").html(ParseWeatherConditions(data.current_observation.weather));
$("#observation_temperature").html(data.current_observation.temperature_string);
$("#observation_feelslike").html("feels like: " + data.current_observation.feelslike_string);
if (weatherUnit == "c"){
$("#observation_temperature").html(data.current_observation.temp_c+" °C");
$("#observation_feelslike").html("feels like: " + data.current_observation.feelslike_c+" °C");
} else {
$("#observation_temperature").html(data.current_observation.temp_f+" °F");
$("#observation_feelslike").html("feels like: " + data.current_observation.feelslike_f+" °F");
}
$("#observation_time").html(data.current_observation.observation_time);
}).fail( function(jqXHR, data) {
Log("Error getting weather: " + data, 1);
Expand All @@ -259,14 +264,25 @@ function GetWeatherForecast()
$("#forecast_title", "#weather_today").html(data.forecast.simpleforecast.forecastday[0].date.weekday);
$("#forecast_icon", "#weather_today").attr("src", "weather/" + data.forecast.simpleforecast.forecastday[0].icon + ".png");
$("#forecast_conditions", "#weather_today").html(ParseWeatherConditions(data.forecast.simpleforecast.forecastday[0].conditions));
$("#forecast_high", "#weather_today").html(data.forecast.simpleforecast.forecastday[0].high.fahrenheit + "F (" + data.forecast.simpleforecast.forecastday[0].high.celsius + "C)");
$("#forecast_low", "#weather_today").html(data.forecast.simpleforecast.forecastday[0].low.fahrenheit + "F (" + data.forecast.simpleforecast.forecastday[0].low.celsius + "C)");
if (weatherUnit == "c"){
$("#forecast_high", "#weather_today").html(data.forecast.simpleforecast.forecastday[0].high.celsius + " °C");
$("#forecast_low", "#weather_today").html(data.forecast.simpleforecast.forecastday[0].low.celsius + "°C");
} else {
$("#forecast_high", "#weather_today").html(data.forecast.simpleforecast.forecastday[0].high.fahrenheit + " °F");
$("#forecast_low", "#weather_today").html(data.forecast.simpleforecast.forecastday[0].low.fahrenheit + " °F");
}

$("#forecast_title", "#weather_tomorrow").html(data.forecast.simpleforecast.forecastday[1].date.weekday);
$("#forecast_icon", "#weather_tomorrow").attr("src", "weather/" + data.forecast.simpleforecast.forecastday[1].icon + ".png");
$("#forecast_conditions", "#weather_tomorrow").html(ParseWeatherConditions(data.forecast.simpleforecast.forecastday[1].conditions));
$("#forecast_high", "#weather_tomorrow").html(data.forecast.simpleforecast.forecastday[1].high.fahrenheit + "F (" + data.forecast.simpleforecast.forecastday[1].high.celsius + "C)");
$("#forecast_low", "#weather_tomorrow").html(data.forecast.simpleforecast.forecastday[1].low.fahrenheit + "F (" + data.forecast.simpleforecast.forecastday[1].low.celsius + "C)");

if (weatherUnit == "c"){
$("#forecast_high", "#weather_tomorrow").html(data.forecast.simpleforecast.forecastday[1].high.celsius + " °C");
$("#forecast_low", "#weather_tomorrow").html(data.forecast.simpleforecast.forecastday[1].low.celsius + " °C");
} else {
$("#forecast_high", "#weather_tomorrow").html(data.forecast.simpleforecast.forecastday[1].high.fahrenheit + " °F");
$("#forecast_low", "#weather_tomorrow").html(data.forecast.simpleforecast.forecastday[1].low.fahrenheit + " °F");
}

$("#forecast_time").html("Forecast Time: " + data.forecast.txt_forecast.date);

Expand Down