js: "fix" zooming
authorgregor herrmann <gregor@toastfreeware.priv.at>
Wed, 8 Aug 2018 15:42:58 +0000 (17:42 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Wed, 8 Aug 2018 15:42:58 +0000 (17:42 +0200)
we have sensors vs. weather now, and need mor variables

web/static/seepark_web.js

index 66cc2a951173a208b1488b8908da499c4978ea3b..9ac4f444a1e50235b3f26802c955bd26a61eb3b0 100644 (file)
@@ -88,7 +88,7 @@ function dayschart(element, title, days, xtickformat) {
                                // FIXME
                                var days = Math.round(duration / 86400 / 2);
                                if (days > 0) {
-                                       loaddays(days);
+                                       loaddays(this, element, days); // this = chart
                                }
                        }
                },
@@ -129,11 +129,19 @@ function dayschart(element, title, days, xtickformat) {
        });
 };
 
-function loaddays(days) {
-       chart.load({
-               url: api_base_url_sensors + beginend(days),
-               mimeType: 'json'
-       });
+function loaddays(chart, element, days) {
+       // TODO: maybe move to top or factor out somehow
+       if (element.substr(0, 7) == 'chart_w') {
+               chart.load({
+                       url: api_base_url_sensors + beginend(days),
+                       mimeType: 'json'
+               });
+       } else {
+               chart.load({
+                       url: api_base_url_weather + beginend(days),
+                       mimeType: 'json'
+               });
+       }
 }
 
 function beginend(days) {