Author: zecas
Date: Sat Nov 28 16:57:23 2015
New Revision: 126

URL: http://svn.gna.org/viewcvs/zzzt?rev=126&view=rev
Log:
html5 progress bar

Modified:
    trunk/stats/index.php
    trunk/stats/update.js
    trunk/stats/updateP.php
    trunk/stats/updateR.php

Modified: trunk/stats/index.php
URL: 
http://svn.gna.org/viewcvs/zzzt/trunk/stats/index.php?rev=126&r1=125&r2=126&view=diff
==============================================================================
--- trunk/stats/index.php       (original)
+++ trunk/stats/index.php       Sat Nov 28 16:57:23 2015
@@ -59,7 +59,7 @@
     table { width: 100%;}
     #holderP { width: 100%; height: 400px; }
     #holderR { width: 100%; height: 300px; }
-    #last {
+    #etat {
       position: absolute;
       top: 4em;
       right: 1em;
@@ -203,12 +203,14 @@
     </TD></tr>
   </table>
   
-  <div id='last' title='<?php echo LAST_MEASURES;?>'></div>
+  <div id='etat' title='<?php echo LAST_MEASURES;?>'>
+    <div id='last'></div>
+    <progress id='temps' max='6' value='0'></progress>
+  </div>
   
   </body>
   
 <script type="text/javascript" charset="utf-8">
-
  var tabP = [
   <?php
     for($i=0;$i<sizeof($values['pac']);$i++) {

Modified: trunk/stats/update.js
URL: 
http://svn.gna.org/viewcvs/zzzt/trunk/stats/update.js?rev=126&r1=125&r2=126&view=diff
==============================================================================
--- trunk/stats/update.js       (original)
+++ trunk/stats/update.js       Sat Nov 28 16:57:23 2015
@@ -15,55 +15,51 @@
     along with Zzzt! .  If not, see <http://www.gnu.org/licenses/>.
 */
 
-function majP() {
+function majP(maintenant) {
   var xhttp = new XMLHttpRequest();
   xhttp.onreadystatechange = function() {
     if (xhttp.readyState == 4 && xhttp.status == 200) {
       var reponse = JSON.parse(xhttp.responseText);
       tabP.push.apply(tabP, reponse);
       chartP.setData(tabP);
-      document.getElementById("last").innerHTML = 
-        tabP[tabP.length-1]['h'].substr(-5,5)+' ' +
-        tabP[tabP.length-1]['a']+'W ' +
-        tabP[tabP.length-1]['k']/100+'kWh';
+    document.getElementById("last").innerHTML = 
+      tabP[tabP.length-1]['h'].substr(-5,5)+' ' +
+      tabP[tabP.length-1]['a']+'W ' +
+      tabP[tabP.length-1]['k']/100+'kWh';
     }
   }
-  if (typeof tabP !== 'undefined') {
-    var maintenant=encodeURIComponent(tabP[tabP.length-1]['h']);
-  }
-
   xhttp.open("GET", "updateP.php?datetime="+maintenant, true);
   xhttp.send();
 }
 
-function majR() {
+function majR(maintenant) {
   var xhttp = new XMLHttpRequest();
   xhttp.onreadystatechange = function() {
     if (xhttp.readyState == 4 && xhttp.status == 200) {
       var reponseR = JSON.parse(xhttp.responseText);
-
-//       console.log("tabR:"+tabR.length);
-//       console.log("reponseR:"+reponseR.length);
-
       tabR.push.apply(tabR, reponseR);
-//       console.log("tabR:"+tabR.length);
-
       chartR.setData(tabR);
     }
   }
-  var maintenant=encodeURIComponent(tabR[tabR.length-1]['h']);
-//   console.log("Now:"+maintenant);
-
   xhttp.open("GET", "updateR.php?datetime="+maintenant, true);
   xhttp.send();
 }
 
 function maj() {
-  majP();
-  majR();
+  if (typeof tabP[tabP.length-1] == 'undefined') {
+    var maintenant = (new Date()).toJSON().substr(0, 10);
+  } else {
+    var maintenant=encodeURIComponent(tabP[tabP.length-1]['h']);
+  }
+  majP(maintenant);
+  majR(maintenant);
 }
 
 setInterval(function(){
-    maj()
-}, 60000);
+  document.getElementById("temps").value++;
+  if ( document.getElementById("temps").value == 6 ) {
+    maj();
+    document.getElementById("temps").value=0;
+  }
+}, 10000);
 

Modified: trunk/stats/updateP.php
URL: 
http://svn.gna.org/viewcvs/zzzt/trunk/stats/updateP.php?rev=126&r1=125&r2=126&view=diff
==============================================================================
--- trunk/stats/updateP.php     (original)
+++ trunk/stats/updateP.php     Sat Nov 28 16:57:23 2015
@@ -22,9 +22,7 @@
   $heure=array();
   $values=array();
   $champs=array('pac','pdc','kdy','tkk');
-  if(!isset($_GET['day'])) $_GET['day']=date('Y-m-d');
-  if(!isset($_GET['width'])) $_GET['width']=1000;
-  if(!isset($_GET['height'])) $_GET['height']=550;
+  $day=date('Y-m-d');
   $sql="SELECT 
              ROUND(DATE_FORMAT(monitor_date,'%H%i'),0) AS md,
               ROUND(AVG(pac),0) AS pac,
@@ -34,7 +32,7 @@
   $db->query($sql);
   while ($row = $db->fetch()) {
       $prev=$row['pdc'];
-      $heure[]=$_GET['day'].' 
'.implode(':',str_split(str_pad((int)$row['md'],4,"0",STR_PAD_LEFT),2));
+      $heure[]=$day.' 
'.implode(':',str_split(str_pad((int)$row['md'],4,"0",STR_PAD_LEFT),2));
       
$values['rendement'][]=sprintf('%.2F',$row['pac']/($row['pdc']+0.0001)*100);
       foreach($champs as $c) $values[$c][]=$row[$c];
   }

Modified: trunk/stats/updateR.php
URL: 
http://svn.gna.org/viewcvs/zzzt/trunk/stats/updateR.php?rev=126&r1=125&r2=126&view=diff
==============================================================================
--- trunk/stats/updateR.php     (original)
+++ trunk/stats/updateR.php     Sat Nov 28 16:57:23 2015
@@ -22,9 +22,7 @@
   $heure=array();
   $values=array();
   $champs=array('pac','pdc','kdy','tkk');
-  if(!isset($_GET['day'])) $_GET['day']=date('Y-m-d');
-  if(!isset($_GET['width'])) $_GET['width']=1000;
-  if(!isset($_GET['height'])) $_GET['height']=550;
+  $day=date('Y-m-d');
   $sql="SELECT 
              ROUND(DATE_FORMAT(monitor_date,'%H%i'),0) AS md,
               ROUND(AVG(pac),0) AS pac,
@@ -34,7 +32,7 @@
   $db->query($sql);
   while ($row = $db->fetch()) {
       $prev=$row['pdc'];
-      $heure[]=$_GET['day'].' 
'.implode(':',str_split(str_pad((int)$row['md'],4,"0",STR_PAD_LEFT),2));
+      $heure[]=$day.' 
'.implode(':',str_split(str_pad((int)$row['md'],4,"0",STR_PAD_LEFT),2));
       
$values['rendement'][]=sprintf('%.2F',$row['pac']/($row['pdc']+0.0001)*100);
       foreach($champs as $c) $values[$c][]=$row[$c];
   }


_______________________________________________
Zzzt-commits mailing list
Zzzt-commits@gna.org
https://mail.gna.org/listinfo/zzzt-commits

Reply via email to