diff --git a/platypush/backend/http/static/css/widgets/date-time-weather.css b/platypush/backend/http/static/css/widgets/date-time-weather.css index 3b0112007..49fcf029e 100644 --- a/platypush/backend/http/static/css/widgets/date-time-weather.css +++ b/platypush/backend/http/static/css/widgets/date-time-weather.css @@ -16,3 +16,8 @@ h1.temperature { font-size: 22px; } + .widget.date-time-weather * > .sensor-temperature, + .widget.date-time-weather * > .sensor-humidity { + display: none; + } + diff --git a/platypush/backend/http/static/js/widgets/date-time-weather.js b/platypush/backend/http/static/js/widgets/date-time-weather.js index 9b0ead879..92b8dd516 100644 --- a/platypush/backend/http/static/js/widgets/date-time-weather.js +++ b/platypush/backend/http/static/js/widgets/date-time-weather.js @@ -2,12 +2,22 @@ $(document).ready(function() { var $widget = $('.widget.date-time-weather'), $dateElement = $widget.find('[data-bind=date]'), $timeElement = $widget.find('[data-bind=time]'), + $sensorTempElement = $widget.find('[data-bind=sensor-temperature]'), + $sensorHumidityElement = $widget.find('[data-bind=sensor-humidity]'), $forecastElement = $widget.find('[data-bind=forecast]'), $tempElement = $widget.find('[data-bind=temperature]'); var onEvent = function(event) { if (event.args.type == 'platypush.message.event.weather.NewWeatherConditionEvent') { updateTemperature(event.args.temperature); + } else if (event.args.type == 'platypush.message.event.sensor.SensorDataChangeEvent') { + if ('temperature' in event.args) { + updateSensorTemperature(event.args.temperature); + } + + if ('humidity' in event.args) { + updateSensorHumidity(event.args.humidity); + } } }; @@ -15,6 +25,16 @@ $(document).ready(function() { $tempElement.text(Math.round(temperature)); }; + var updateSensorTemperature = function(temperature) { + $sensorTempElement.text(Math.round(temperature*10)/10); + $sensorTempElement.parent().show(); + }; + + var updateSensorHumidity = function(humidity) { + $sensorHumidityElement.text(Math.round(humidity)); + $sensorHumidityElement.parent().show(); + }; + var initEvents = function() { window.registerEventListener(onEvent); }; diff --git a/platypush/backend/http/templates/widgets/date-time-weather.html b/platypush/backend/http/templates/widgets/date-time-weather.html index 58aa45aaf..bfe1483da 100644 --- a/platypush/backend/http/templates/widgets/date-time-weather.html +++ b/platypush/backend/http/templates/widgets/date-time-weather.html @@ -11,8 +11,12 @@
- - - +