Permalink
Browse files

solved conflicts

  • Loading branch information...
2 parents ab1b54e + 9d1e407 commit fc79ff28fe4ecc93f302025d1c6f0bbfca591bce Rico Chen committed Mar 6, 2012
Showing with 14 additions and 13 deletions.
  1. +5 −4 app.js
  2. +9 −9 public/javascripts/main.js
View
9 app.js
@@ -39,15 +39,16 @@ app.get('/flot', routes.flot);
var io=require('socket.io').listen(app);
app.listen(3000);
-var limit=config.limit, interval=config.interval, all_d=[];
-
+var limit=config.limit, interval=config.interval, all_d=[]; // use all_d to hold config.limit number of data sets for initial connections
(function schedule() {
setTimeout( function () {
- var uptime_arr=os.loadavg(), ts=new Date().getTime();
+ var uptime_arr=os.loadavg();
+ var ts=(new Date()).getTime();
for(var i=0, l=uptime_arr.length;i<l;i++) {
- uptime_arr[i]=Math.round(uptime_arr[i]*100)/100;
+ uptime_arr[i]=Math.round(uptime_arr[i]*100)/100;
}
uptime_arr.unshift(ts);
+ all_d.push(uptime_arr)
if(all_d.length>limit) {
all_d=all_d.slice(0-limit);
}
View
@@ -1,10 +1,10 @@
-var socket=io.connect(), d1=[], d5=[], d15=[], zone_delta=(new Date()).getTimezoneOffset()*60000; // time diff in ms;
-var interval,limit=1440; // show 2 hours data (7200/5)
+var socket=io.connect(), d1=[], d5=[], d15=[], zone_delta=(new Date()).getTimezoneOffset()*60000; // time diff in ms
+var interval,limit=1440; // show 2 hours data (7200/5) at interval=5sec
socket.on('newdata', function(v) {
var ts=v[0]-zone_delta;
- d1.push([ts, v[1]]);
- d5.push([ts, v[2]]);
- d15.push([ts, v[3]]);
+ d1.push([ts, v[1]]);
+ d5.push([ts, v[2]]);
+ d15.push([ts, v[3]]);
re_flot();
var i=1;
$('#legend').find('tr').each(function() {
@@ -13,10 +13,10 @@ socket.on('newdata', function(v) {
});
socket.on('history', function(a) {
for(var i=0, l=a.length;i<l;i++) {
- var v=a[i], ts=v[0]-zone_delta;
- d1.push([ts, v[1]]);
- d5.push([ts, v[2]]);
- d15.push([ts, v[3]]);
+ var v=a[i], ts=v[0]-zone_delta;
+ d1.push([ts, v[1]]);
+ d5.push([ts, v[2]]);
+ d15.push([ts, v[3]]);
}
re_flot();
});

0 comments on commit fc79ff2

Please sign in to comment.