Add variable update time for Ajax display. Update status.shtml with <pre> tag now used by cgi.

This commit is contained in:
David Kopf 2012-03-10 10:43:23 -05:00
parent cf3827829d
commit ca273e28e9
7 changed files with 123 additions and 36 deletions

View file

@ -3,6 +3,7 @@
function e(el){return document.getElementById(el);}
function ls(){try{r=new XMLHttpRequest();}catch(e){alert("Browswer does not support Ajax");return false;}r.open("GET","/ajaxdata.shtml",true);
x=0;r.onreadystatechange=function(){e('date').innerHTML=(new Date()).toTimeString();if(r.readyState>0){j=r.responseText.substr(x);x+=j.length;eval(j);}};r.send(null);}
function tb(x){var t=e('ss');if(x||t.value=="RUN"){t.value="STOP";ls();}else{t.value="RUN";r.abort();}}
function s(el,n,max,text){e(el).innerHTML='<table width=504 border=0 cellpadding=1 cellspacing=0>'+'<tr><td width=200>'+text+'</td>'+'<td width='+(10+300*n/max)+' bgcolor="gray">&nbsp;</td>'+'<td width='+(310-300*n/max)+' bgcolor="lightgray">&nbsp;</td>'+'</table>';}
function wt(m){document.title=m;e('v').innerHTML=m;}
function dc(n,d){return n.toFixed(d);}
@ -12,7 +13,7 @@ function ax(m){s('ax',m+2000,4000,'Acceleration (X-axis) '+m+'mg');}
function ay(m){s('ay',m+2000,4000,'Acceleration (Y-axis) '+m+'mg');}
function az(m){s('az',m+2000,4000,'Acceleration (Z-axis) '+m+'mg');}
function rs(m){s('rs',n,100,'RSSI '+n);}
function p(c,l,t,r){cp=0.136*c;lt=0.478*t;lr=0.412*r;n=cp+lt+lr;//128rfa1@3v3
function p(c,l,t,r){cp=0.00109*c;lt=0.00848*t;lr=0.00617*r;n=cp+lt+lr;//mc1322x
s('p',n,200,'Power consumption '+dc(n,2)+' mW');
s('pc',cp,100,'CPU power '+dc(cp,2)+' mW');
s('pr',lr,200,'Radio RX power '+dc(lr,2)+' mW');

View file

@ -1,6 +1,8 @@
%! header
%!: /ajax.js
<input type="button" value="RUN" onclick="ls()"><input type="button" value="STOP" onclick="r.abort()"><br><span id="date"></span>
<input id="ss" type="button" value="STOP" onclick="tb(0)">
Interval <input id="tc" type="text" style="width:60;text-align:right;" maxlength="5" value="10" onchange="tb(1)"> seconds<br>
<span id="date"></span>
<div id="v"></div>
<pre><span id="rims"></span><div id="ener"></div></pre>
<h2>Sensors</h2>

View file

@ -1,10 +1,14 @@
%! header
<h4>Addresses</h4>
<pre><big><b>Addresses</b></big>
%! addresses
<h4>Neighbors</h4>
<big><b>Neighbors</b></big>
%! neighbors
<h4>Routes</h4>
<big><b>Routes</b></big>
%! routes
<h4>Sensors</h4>
<big><b>Sensors</b></big>
%! sensors
%! file-stats .
</pre>
%! file-stats .

View file

@ -1,10 +1,14 @@
%! header
<p>Addresses<br>
<pre><big><b>Addresses</b></big>
%! addresses
<p>Neighbors<br>
<big><b>Neighbors</b></big>
%! neighbors
<p>Routes<br>
<big><b>Routes</b></big>
%! routes
<p>Sensors<br>
<big><b>Sensors</b></big>
%! sensors
%! file-stats .
</pre>
%! file-stats .