]> ToastFreeware Gitweb - chrisu/seepark.git/blobdiff - web/static/seepark_web.js
reload openweathermap widget by removing and re-adding script and widget
[chrisu/seepark.git] / web / static / seepark_web.js
index 7e727a1f0927b31351122c6f2a8c00f9ac289e77..5aaf55a5c46233871cc647fab52d5688dbd39451 100644 (file)
@@ -217,7 +217,7 @@ dayschart('chart_air_7',     'Die Luft (Woche)',   7, '%a %d');
 dayschart('chart_air_31',    'Die Luft (Monat)',  31, '%Y-%m-%d');
 dayschart('chart_air_365',   'Die Luft (Jahr)',  365, '%b %Y');
 
-// reload current values
+// reload current values + owm script
 setInterval(
        function() {
                var airvalue   = document.getElementById('currentairvalue');
@@ -242,6 +242,14 @@ setInterval(
                        .catch(function(error) {
                                console.log(error);
                        });
+
+               var owmwidget = document.getElementById('openweathermap-widget-15');
+               owmwidget.removeChild(owmwidget.childNodes[0]);
+               var owmscript = document.head.lastElementChild;
+               document.head.removeChild(owmscript);
+               var newowmscript = document.createElement('script');
+               newowmscript.src = '//openweathermap.org/themes/openweathermap/assets/vendor/owm/js/weather-widget-generator.js';
+               document.head.appendChild(newowmscript);
        },
        refresh_interval
 );