Skip to content

Commit

Permalink
Fixed missing blocklines, I forgot getJSON is ajax and finishes whenever
Browse files Browse the repository at this point in the history
  • Loading branch information
roy7 committed Apr 7, 2014
1 parent d0d6eb0 commit b3d6819
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,30 @@ <h4>Recent blocks</h4>
graph_doa_hashrate.push(el);
});
graph_doa_hashrate.sort();
if (recent_blocks) $.each(recent_blocks, function(key, block) {
el= []; el.push(parseInt(block["ts"]) * 1000);
graph_blocks.push(el);
});
draw(graph_hashrate, graph_doa_hashrate, graph_blocks, 'chart', interval);
if (typeof recent_blocks == 'undefined') {
// init fetchBlocks() has not finished. Need to fetch it myself.

$.getJSON(api_url + '/recent_blocks'
,function(data) {
$.each(data, function(key, block) {
el= []; el.push(parseInt(block["ts"]) * 1000);
graph_blocks.push(el);
});
draw(graph_hashrate, graph_doa_hashrate, graph_blocks, 'chart', interval);
});
} else if (recent_blocks) {
// init fetchBlocks() has finished.

$.each(recent_blocks, function(key, block) {
el= []; el.push(parseInt(block["ts"]) * 1000);
graph_blocks.push(el);
});
draw(graph_hashrate, graph_doa_hashrate, graph_blocks, 'chart', interval);
} else {
// init fetchBlocks() has finished, but there are no recent blocks.

draw(graph_hashrate, graph_doa_hashrate, graph_blocks, 'chart', interval);
}
});
});
};
Expand Down

0 comments on commit b3d6819

Please sign in to comment.