diff --git a/configuration.txt b/configuration.txt index d92888fa..8bdf9bfa 100644 --- a/configuration.txt +++ b/configuration.txt @@ -107,6 +107,7 @@ web: #- type: digitalclock - type: timeofdayclock showdigitalclock: true + #showweather: true #- type: regions # name: WorldGuard # useworldpath: true diff --git a/web/css/dynmap_style.css b/web/css/dynmap_style.css index 91edc507..8788a1b4 100644 --- a/web/css/dynmap_style.css +++ b/web/css/dynmap_style.css @@ -294,6 +294,39 @@ bottom: 16px; } +/******************* + * Clock weather style + */ + +.weather { + position: absolute; + top: 17px; + right: 5px; + width: 25px; + height: 23px; + display: block; + background-repeat: no-repeat; +} + +.weather.sunny { + background-image: url(../images/weather_sunny.png); +} + +.weather.stormy { + background-image: url(../images/weather_stormy.png); +} +.weather .thunder { + position: absolute; + top: 0; + left: 0; + right: 0; + width: 25px; + height: 25px; + display: none; + background-repeat: no-repeat; + background-image: url(../images/weather_thunder.png); +} + /******************* * map list-specific styling */ diff --git a/web/images/weather_stormy.png b/web/images/weather_stormy.png new file mode 100644 index 00000000..45808fb1 Binary files /dev/null and b/web/images/weather_stormy.png differ diff --git a/web/images/weather_sunny.png b/web/images/weather_sunny.png new file mode 100644 index 00000000..8ef8cbda Binary files /dev/null and b/web/images/weather_sunny.png differ diff --git a/web/images/weather_thunder.png b/web/images/weather_thunder.png new file mode 100644 index 00000000..07bbfc0a Binary files /dev/null and b/web/images/weather_thunder.png differ diff --git a/web/js/timeofdayclock.js b/web/js/timeofdayclock.js index 8467b1d4..82c0cb1a 100644 --- a/web/js/timeofdayclock.js +++ b/web/js/timeofdayclock.js @@ -62,6 +62,27 @@ componentconstructors['timeofdayclock'] = function(dynmap, configuration) { setTime(update.servertime); }); } + if(configuration.showweather) { + var weather = $('
') + .addClass('weather') + .appendTo(element); + + var thunder = $('
') + .addClass('thunder') + .css('display','none') + .appendTo(weather); + + var setWeather = function(hasStorm, isThundering) { + weather + .addClass(hasStorm ? 'stormy' : 'sunny') + .removeClass(hasStorm ? 'sunny' : 'stormy'); + thunder.css('display',isThundering ? 'block' : 'none'); + }; + + $(dynmap).bind('worldupdated', function(event, update) { + setWeather(update.hasStorm, update.isThundering); + }); + } $(dynmap).bind('worldupdated', function(event, update) { var sunangle; var time = update.servertime;