cleanup
[psensor.git] / www / details.html
index 43c38cc..45bb367 100644 (file)
@@ -3,86 +3,38 @@
     <meta charset="utf-8">
     <title>Sensor </title>
 
-    <link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,bold&subset=Latin">
+    <link type="text/css"
+         rel="stylesheet"
+href="http://fonts.googleapis.com/css?family=Ubuntu:regular,bold&subset=Latin">
 
-    <link type="text/css" href="style.css" rel="stylesheet" /> 
+    <link href="jqplot.css" rel="stylesheet" type="text/css"/> 
+    <link href="style.css" rel="stylesheet" type="text/css"/>  
 
-    <script type="text/javascript" src="jquery.js"></script>
-    <script type="text/javascript" src="jqplot.js"></script>
-    <link   type="text/css"        href="jqplot.css" rel="stylesheet" />       
-    <script type="text/javascript" src="jqplot.dateAxisRenderer.js"></script>
+    <script src="jquery.js" type="text/javascript"></script>
+    <script src="jqplot.js" type="text/javascript"></script>
+    <script src="jqplot.dateAxisRenderer.js" type="text/javascript"></script>
 
-    <script type="text/javascript" src="psensor.js"></script>
+    <script src="psensor.js" type="text/javascript"></script>
 
     <script>
       $(document).ready(function() {
-         var max_date = null;
-         var min_date = null;
-          var min, max, value;
-          var params = get_url_params();
-          var url_id = params["id"];
+          var url_id;
 
-          min = max = null;
+         url_id = get_url_params()["id"];
 
           $.getJSON(url_id, function(data) {
-              var measures = data["measures"];
-              var data_chart = [];
-
-              $("#title").append(data["name"]);
-              $("title").append(data["name"]);
-
-              $.each(measures, function(i, item) {
-                  value = item["value"];
-                  var d = new Date(item["time"]*1000);
-                  var entry = [d, item["value"]];
-
-                  data_chart.push(entry);
-      
-                 if (max_date == null || max_date < d)
-                    max_date = d;
-                  
-                 if (min_date == null || min_date > d)
-                   min_date = d;
-            
-                  if (min == null || value < min)
-                    min = value;
-                 if (max == null || value > max)
-                    max = value;
-
-              });
-
-              var plot1 = $.jqplot ('chart1', [data_chart], 
-                  {
-                      title: type_to_str(data["type"]),
-                      axes:{
-                          xaxis:{
-                              renderer:$.jqplot.DateAxisRenderer,
-                              tickOptions:{formatString:'%H:%M:%S'},
-                             min: min_date,
-                             max: max_date
-                          },
-                         yaxis: {
-                             min: min-1,
-                              max: max+1
-                         }
-                      },
-                      series: [{lineWidth:1,showMarker:false}]
-                  });
-          });
+               update_chart("chart", type_to_str(data["type"]), data);
+         });
       });
     </script>
   </head>
   <body>
-    <div class='page'>
-      <div class='page-header'>
-        <h1 id='title'></h1>
-      </div>
+    <h1></h1>
 
-      <div class="chart">
-       <div id='chart1'></div>
-      </div>
-    </div>
+    <div class="chart" id="chart"></div>
 
-    <div id="footer">Generated by <a href='http://wpitchoune.net/psensor'>psensor-server</a></div>
+    <div id="footer">
+      Generated by <a href='http://wpitchoune.net/psensor'>psensor-server</a>
+    </div>
   </body>
 </html>