diff --git a/css/main.css b/css/main.css index 49bfe611..ae590fdd 100644 --- a/css/main.css +++ b/css/main.css @@ -95,7 +95,7 @@ body { header { text-transform: uppercase; font-size: 15px; - font-family: "Roboto Condensed"; + font-family: "Roboto Condensed", sans-serif; font-weight: 400; border-bottom: 1px solid #666; line-height: 15px; @@ -151,6 +151,7 @@ sup { .region.right { right: 0; + text-align: right; } .region.top { @@ -161,6 +162,10 @@ sup { margin-bottom: 25px; } +.region.bottom .container { + margin-top: 25px; +} + .region.top .container:empty { margin-bottom: 0; } @@ -185,10 +190,6 @@ sup { bottom: 0; } -.region.bottom .container { - margin-top: 25px; -} - .region.bottom .container:empty { margin-top: 0; } @@ -231,10 +232,6 @@ sup { text-align: left; } -.region.right { - text-align: right; -} - .region table { width: 100%; border-spacing: 0; diff --git a/modules/default/weather/providers/darksky.js b/modules/default/weather/providers/darksky.js index e5358a0f..74758d6e 100644 --- a/modules/default/weather/providers/darksky.js +++ b/modules/default/weather/providers/darksky.js @@ -17,30 +17,30 @@ WeatherProvider.register("darksky", { fetchCurrentWeather: function() { this.fetchData(this.getUrl()) .then(data => { - Log.log(data); if(!data || !data.currently || typeof data.currently.temperature === "undefined") { // No usable data? return; } + var currentWeather = this.generateWeatherDayFromCurrentWeather(data); this.setCurrentWeather(currentWeather); }).catch(function(request) { - Log.error("Could not load data!", request); + Log.error("Could not load data ... ", request); }); }, fetchWeatherForecast: function() { this.fetchData(this.getUrl()) .then(data => { - Log.log(data); if(!data || !data.daily || !data.daily.data.length) { // No usable data? return; } + var forecast = this.generateWeatherObjectsFromForecast(data.daily.data); this.setWeatherForecast(forecast); }).catch(function(request) { - Log.error("Could not load data!", request); + Log.error("Could not load data ... ", request); }); }, @@ -99,4 +99,4 @@ WeatherProvider.register("darksky", { }; return weatherTypes.hasOwnProperty(weatherType) ? weatherTypes[weatherType] : null; } -}); \ No newline at end of file +}); diff --git a/modules/default/weather/providers/openweathermap.js b/modules/default/weather/providers/openweathermap.js index ff58547c..8fd1e3be 100644 --- a/modules/default/weather/providers/openweathermap.js +++ b/modules/default/weather/providers/openweathermap.js @@ -26,13 +26,13 @@ WeatherProvider.register("openweathermap", { return; } - this.setFetchedLocation(data.name + ', ' + data.sys.country) + this.setFetchedLocation(`${data.name}, ${data.sys.country}`); - var currentWeather = this.generateWeatherObjectFromCurrentWeather(data) - this.setCurrentWeather(currentWeather) + var currentWeather = this.generateWeatherObjectFromCurrentWeather(data); + this.setCurrentWeather(currentWeather); }) .catch(function(request) { - Log.error("Could not load data ... ", request) + Log.error("Could not load data ... ", request); }) }, @@ -46,13 +46,13 @@ WeatherProvider.register("openweathermap", { return; } - this.setFetchedLocation(data.city.name + ', ' + data.city.country) + this.setFetchedLocation(`${data.city.name}, ${data.city.country}`); - var forecast = this.generateWeatherObjectsFromForecast(data.list) - this.setWeatherForecast(forecast) + var forecast = this.generateWeatherObjectsFromForecast(data.list); + this.setWeatherForecast(forecast); }) .catch(function(request) { - Log.error("Could not load data ... ", request) + Log.error("Could not load data ... ", request); }) }, @@ -63,45 +63,45 @@ WeatherProvider.register("openweathermap", { * Gets the complete url for the request */ getUrl: function() { - return this.config.apiBase + this.config.apiVersion + this.config.weatherEndpoint + this.getParams() + return this.config.apiBase + this.config.apiVersion + this.config.weatherEndpoint + this.getParams(); }, /* * Generate a WeatherObject based on currentWeatherInformation */ generateWeatherObjectFromCurrentWeather: function(currentWeatherData) { - var currentWeather = new WeatherObject() + var currentWeather = new WeatherObject(); - currentWeather.humidity = currentWeatherData.main.humidity - currentWeather.temperature = currentWeatherData.main.temp - currentWeather.windSpeed = currentWeatherData.wind.speed - currentWeather.windDirection = currentWeatherData.wind.deg - currentWeather.weatherType = this.convertWeatherType(currentWeatherData.weather[0].icon) - currentWeather.sunrise = moment(currentWeatherData.sys.sunrise, "X") - currentWeather.sunset = moment(currentWeatherData.sys.sunset, "X") + currentWeather.humidity = currentWeatherData.main.humidity; + currentWeather.temperature = currentWeatherData.main.temp; + currentWeather.windSpeed = currentWeatherData.wind.speed; + currentWeather.windDirection = currentWeatherData.wind.deg; + currentWeather.weatherType = this.convertWeatherType(currentWeatherData.weather[0].icon); + currentWeather.sunrise = moment(currentWeatherData.sys.sunrise, "X"); + currentWeather.sunset = moment(currentWeatherData.sys.sunset, "X"); - return currentWeather + return currentWeather; }, /* * Generate WeatherObjects based on forecast information */ generateWeatherObjectsFromForecast: function(forecasts) { - var days = [] + var days = []; for (var forecast of forecasts) { - var weather = new WeatherObject() + var weather = new WeatherObject(); - weather.date = moment(forecast.dt, "X") - weather.minTemperature = forecast.temp.min - weather.maxTemperature = forecast.temp.max - weather.weatherType = this.convertWeatherType(forecast.weather[0].icon) - weather.rain = forecast.rain + weather.date = moment(forecast.dt, "X"); + weather.minTemperature = forecast.temp.min; + weather.maxTemperature = forecast.temp.max; + weather.weatherType = this.convertWeatherType(forecast.weather[0].icon); + weather.rain = forecast.rain; - days.push(weather) + days.push(weather); } - return days + return days; }, /* @@ -127,9 +127,9 @@ WeatherProvider.register("openweathermap", { "11n": "night-thunderstorm", "13n": "night-snow", "50n": "night-alt-cloudy-windy" - } + }; - return weatherTypes.hasOwnProperty(weatherType) ? weatherTypes[weatherType] : null + return weatherTypes.hasOwnProperty(weatherType) ? weatherTypes[weatherType] : null; }, /* getParams(compliments) @@ -144,7 +144,7 @@ WeatherProvider.register("openweathermap", { } else if(this.config.location) { params += "q=" + this.config.location; } else if (this.firstEvent && this.firstEvent.geo) { - params += "lat=" + this.firstEvent.geo.lat + "&lon=" + this.firstEvent.geo.lon + params += "lat=" + this.firstEvent.geo.lat + "&lon=" + this.firstEvent.geo.lon; } else if (this.firstEvent && this.firstEvent.location) { params += "q=" + this.firstEvent.location; } else { @@ -157,5 +157,5 @@ WeatherProvider.register("openweathermap", { params += "&APPID=" + this.config.apiKey; return params; - }, -}); \ No newline at end of file + } +}); diff --git a/modules/default/weather/weather.css b/modules/default/weather/weather.css index febc777c..dfa2b12a 100644 --- a/modules/default/weather/weather.css +++ b/modules/default/weather/weather.css @@ -1,46 +1,45 @@ .weather .weathericon, .weather .fa-home { - font-size: 75%; - line-height: 65px; - display: inline-block; - -ms-transform: translate(0, -3px); /* IE 9 */ - -webkit-transform: translate(0, -3px); /* Safari */ - transform: translate(0, -3px); + font-size: 75%; + line-height: 65px; + display: inline-block; + -ms-transform: translate(0, -3px); /* IE 9 */ + -webkit-transform: translate(0, -3px); /* Safari */ + transform: translate(0, -3px); } .weather .humidityIcon { - padding-right: 4px; + padding-right: 4px; } .weather .humidity-padding { - padding-bottom: 6px; + padding-bottom: 6px; } - .weather .day { - padding-left: 0; - padding-right: 25px; + padding-left: 0; + padding-right: 25px; } .weather .weather-icon { - padding-right: 30px; - text-align: center; + padding-right: 30px; + text-align: center; } .weather .min-temp { - padding-left: 20px; - padding-right: 0; + padding-left: 20px; + padding-right: 0; } .weather .rain { - padding-left: 20px; - padding-right: 0; + padding-left: 20px; + padding-right: 0; } .weather tr.colored .min-temp { - color: #BCDDFF; + color: #bcddff; } .weather tr.colored .max-temp { - color: #FF8E99; + color: #ff8e99; } diff --git a/modules/default/weather/weather.js b/modules/default/weather/weather.js index d94f774e..03e15bda 100644 --- a/modules/default/weather/weather.js +++ b/modules/default/weather/weather.js @@ -59,16 +59,12 @@ Module.register("weather",{ // Return the scripts that are nessecery for the weather module. getScripts: function () { - var scripts = [ + return [ "moment.js", "weatherprovider.js", - "weatherobject.js" + "weatherobject.js", + this.file("providers/" + this.config.weatherProvider.toLowerCase() + ".js") ]; - - // Add the provider file to the required scripts. - scripts.push(this.file("providers/" + this.config.weatherProvider.toLowerCase() + ".js")); - - return scripts }, // Override getHeader method. @@ -93,7 +89,7 @@ Module.register("weather",{ this.addFilters(); // Schedule the first update. - this.scheduleUpdate(0); + this.scheduleUpdate(this.config.initialLoadDelay); }, // Override notification handler. @@ -112,12 +108,10 @@ Module.register("weather",{ } } } - } - if (notification === "INDOOR_TEMPERATURE") { + } else if (notification === "INDOOR_TEMPERATURE") { this.indoorTemperature = this.roundValue(payload); this.updateDom(300); - } - if (notification === "INDOOR_HUMIDITY") { + } else if (notification === "INDOOR_HUMIDITY") { this.indoorHumidity = this.roundValue(payload); this.updateDom(300); } @@ -125,7 +119,7 @@ Module.register("weather",{ // Select the template depending on the display type. getTemplate: function () { - return this.config.type.toLowerCase() + ".njk" + return `${this.config.type.toLowerCase()}.njk`; }, // Add all the data to the template. @@ -144,8 +138,8 @@ Module.register("weather",{ // What to do when the weather provider has new information available? updateAvailable: function() { Log.log("New weather information available."); - this.updateDom(300); - this.scheduleUpdate(60000); + this.updateDom(0); + this.scheduleUpdate(); }, scheduleUpdate: function(delay = null) { @@ -214,9 +208,9 @@ Module.register("weather",{ } if(this.config.units === "imperial") { - return (parseFloat(value) / 25.4).toFixed(2) + " in"; + return `${(parseFloat(value) / 25.4).toFixed(2)} in`; } else { - return parseFloat(value).toFixed(1) + " mm"; + return `${parseFloat(value).toFixed(1)} mm`; } }.bind(this)); } diff --git a/modules/default/weather/weatherobject.js b/modules/default/weather/weatherobject.js index ff0de841..b6ee9b95 100644 --- a/modules/default/weather/weatherobject.js +++ b/modules/default/weather/weatherobject.js @@ -14,16 +14,16 @@ class WeatherObject { constructor() { - this.date = null - this.windSpeed = null - this.windDirection = null - this.sunrise = null - this.sunset = null - this.temperature = null - this.minTemperature = null - this.maxTemperature = null - this.weatherType = null - this.humidity = null + this.date = null; + this.windSpeed = null; + this.windDirection = null; + this.sunrise = null; + this.sunset = null; + this.temperature = null; + this.minTemperature = null; + this.maxTemperature = null; + this.weatherType = null; + this.humidity = null; } cardinalWindDirection () { @@ -78,4 +78,4 @@ class WeatherObject { var now = new Date(); return (this.sunrise < now && this.sunset > now) ? "sunset" : "sunrise"; } -}; \ No newline at end of file +} diff --git a/modules/default/weather/weatherprovider.js b/modules/default/weather/weatherprovider.js index 0be45663..bb139991 100644 --- a/modules/default/weather/weatherprovider.js +++ b/modules/default/weather/weatherprovider.js @@ -36,71 +36,71 @@ var WeatherProvider = Class.extend({ // Called when a weather provider is initialized. init: function(config) { this.config = config; - Log.info("Weather provider: " + this.providerName + " initialized.") + Log.info(`Weather provider: ${this.providerName} initialized.`); }, // Called to set the config, this config is the same as the weather module's config. setConfig: function(config) { - this.config = config - Log.info("Weather provider: " + this.providerName + " config set.", this.config) + this.config = config; + Log.info(`Weather provider: ${this.providerName} config set.`, this.config); }, // Called when the weather provider is about to start. start: function(config) { - Log.info("Weather provider: " + this.providerName + " started.") + Log.info(`Weather provider: ${this.providerName} started.`); }, // This method should start the API request to fetch the current weather. // This method should definetly be overwritten in the provider. fetchCurrentWeather: function() { - Log.warn("Weather provider: " + this.providerName + " does not subclass the fetchCurrentWeather method.") + Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchCurrentWeather method.`); }, // This method should start the API request to fetch the weather forecast. // This method should definetly be overwritten in the provider. fetchWeatherForecast: function() { - Log.warn("Weather provider: " + this.providerName + " does not subclass the fetchWeatherForecast method.") + Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchWeatherForecast method.`); }, // This returns a WeatherDay object for the current weather. currentWeather: function() { - return this.currentWeatherObject + return this.currentWeatherObject; }, // This returns an array of WeatherDay objects for the weather forecast. weatherForecast: function() { - return this.weatherForecastArray + return this.weatherForecastArray; }, // This returns the name of the fetched location or an empty string fetchedLocation: function() { - return this.fetchedLocationName || '' + return this.fetchedLocationName || ""; }, // Set the currentWeather and notify the delegate that new information is available. setCurrentWeather: function(currentWeatherObject) { // We should check here if we are passing a WeatherDay - this.currentWeatherObject = currentWeatherObject + this.currentWeatherObject = currentWeatherObject; - this.updateAvailable() + this.updateAvailable(); }, // Set the weatherForecastArray and notify the delegate that new information is available. setWeatherForecast: function(weatherForecastArray) { // We should check here if we are passing a WeatherDay - this.weatherForecastArray = weatherForecastArray + this.weatherForecastArray = weatherForecastArray; - this.updateAvailable() + this.updateAvailable(); }, // Set the fetched location name setFetchedLocation: function(name) { - this.fetchedLocationName = name + this.fetchedLocationName = name; }, // Notify the delegate that new weather is available. updateAvailable: function() { - this.delegate.updateAvailable(this) + this.delegate.updateAvailable(this); }, // A convinience function to make requests. It returns a promise. @@ -125,30 +125,30 @@ var WeatherProvider = Class.extend({ /** * Collection of registered weather providers. */ -WeatherProvider.providers = [] +WeatherProvider.providers = []; /** * Static method to register a new weather provider. */ WeatherProvider.register = function(providerIdentifier, providerDetails) { - WeatherProvider.providers[providerIdentifier.toLowerCase()] = WeatherProvider.extend(providerDetails) -} + WeatherProvider.providers[providerIdentifier.toLowerCase()] = WeatherProvider.extend(providerDetails); +}; /** * Static method to initialize a new weather provider. */ WeatherProvider.initialize = function(providerIdentifier, delegate) { - providerIdentifier = providerIdentifier.toLowerCase() + providerIdentifier = providerIdentifier.toLowerCase(); - var provider = new WeatherProvider.providers[providerIdentifier]() + var provider = new WeatherProvider.providers[providerIdentifier](); - provider.delegate = delegate - provider.setConfig(delegate.config) + provider.delegate = delegate; + provider.setConfig(delegate.config); provider.providerIdentifier = providerIdentifier; if (!provider.providerName) { - provider.providerName = providerIdentifier + provider.providerName = providerIdentifier; } return provider; -} \ No newline at end of file +};