2014-01-06 12:34:25 -08:00
|
|
|
'use strict';
|
|
|
|
|
2014-01-14 14:42:38 -08:00
|
|
|
var TRANSACTION_DISPLAYED = 5;
|
|
|
|
var BLOCKS_DISPLAYED = 5;
|
2014-01-14 10:20:59 -08:00
|
|
|
angular.module('mystery.system').controller('IndexController', ['$scope', 'Global', 'socket', function($scope, Global, socket) {
|
2014-01-06 13:01:23 -08:00
|
|
|
$scope.global = Global;
|
2014-01-13 13:13:41 -08:00
|
|
|
socket.on('tx', function(data) {
|
2014-01-13 14:07:12 -08:00
|
|
|
var tx = data;
|
2014-01-14 14:42:38 -08:00
|
|
|
console.log('Transaction received! ' + tx);
|
|
|
|
if ($scope.txs.length === TRANSACTION_DISPLAYED) {
|
|
|
|
$scope.txs.pop();
|
|
|
|
}
|
|
|
|
$scope.txs.unshift(tx);
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.on('block', function(data) {
|
|
|
|
var block = data;
|
|
|
|
console.log('Block received! ' + block);
|
|
|
|
if ($scope.blocks.length === BLOCKS_DISPLAYED) {
|
|
|
|
$scope.blocks.pop();
|
|
|
|
}
|
|
|
|
$scope.blocks.unshift(block);
|
2014-01-13 13:13:41 -08:00
|
|
|
});
|
|
|
|
|
2014-01-14 10:20:59 -08:00
|
|
|
$scope.txs = [];
|
2014-01-14 14:42:38 -08:00
|
|
|
$scope.blocks = [];
|
2014-01-14 10:20:59 -08:00
|
|
|
|
|
|
|
}]);
|
2014-01-13 13:13:41 -08:00
|
|
|
|