added nodata div
authorAndrew Tridgell <tridge@samba.org>
Sun, 10 Oct 2010 08:24:15 +0000 (19:24 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sun, 10 Oct 2010 08:24:15 +0000 (19:24 +1100)
live/graphs.js
live/index.html

index 0a5a37170d45efc147d17441239dbb7540d3027e..548bff1683025efe04119b60a4db2f04c655eac7 100644 (file)
@@ -34,6 +34,20 @@ function graph_div(divname) {
   }
 }
 
+/*
+  hide/show a div
+ */
+function hide_div(divname, hidden) {
+  var div = document.getElementById(divname);
+  if (hidden) {
+    writeDebug("hiding " + divname);
+    div.style.display = "none";
+  } else {
+    writeDebug("unhiding " + divname);
+    div.style.display = "block";
+  }
+}
+
 /* unhide the loading div when busy */
 loading_counter = 0;
 
@@ -41,15 +55,14 @@ function loading(busy) {
   if (busy) {
     loading_counter++;
     if (loading_counter == 1) {
-      document.getElementById("loading").style.display = "block";
+      hide_div("loading", false);
     }
   } else {
     loading_counter--;
     if (loading_counter == 0) {
-      document.getElementById("loading").style.display = "none";
+      hide_div("loading", true);
     }
   }
-  
 }
 
 
@@ -399,6 +412,7 @@ function graph_csv_files_func(divname, filenames, columns, func1, func2, attrs)
 
     if (d[0] == undefined) {
       writeDebug("unable to load file");
+      /* hide_div("nodata", false); */
       loading(false);
       return;
     }
@@ -527,6 +541,8 @@ in_redraw = false;
  */
 function show_graphs() {
 
+  hide_div("nodata", true);
+
   heading(3, "Total AC Power (W)");
 
   graph_sum_csv_files("Total AC Power", 
index b71689c2d617f08e11d1e1480e6b114d3a87cf21..b331a1697a6c21d4942cfe2b735c56eaeb52adea 100755 (executable)
@@ -43,6 +43,7 @@ graphing package. Please be patient, or install Firefox</p>
 </form>
 
 <div id="loading"><font color="red">Loading ....</font></div>
+<div id="nodata"><font color="red">No data available for chosen date</font></div>
 
 <script type="text/javascript">
 enableDebug(false);