flosight-ui
Version:
An open-source frontend for the Flosight API. The Flosight API provides you with a convenient, powerful and simple way to query and broadcast data on the florincoin network and build your own services with it.
61 lines (51 loc) • 1.33 kB
JavaScript
'use strict';
angular.module('flosight.system').controller('HeaderController',
function($scope, $rootScope, $modal, getSocket, Global, Block, Status) {
$scope.global = Global;
$rootScope.currency = {
factor: 1,
bitstamp: 0,
symbol: 'FLO'
};
$scope.menu = [{
'title': 'Blocks',
'link': 'blocks'
}, {
'title': 'Status',
'link': 'status'
}];
$scope.openScannerModal = function() {
var modalInstance = $modal.open({
templateUrl: 'scannerModal.html',
controller: 'ScannerController'
});
};
$scope.getStatus = function(q) {
Status.get({
q: 'get' + q
},
function(d) {
$scope.loaded = 1;
angular.extend($scope, d);
},
function(e) {
$scope.error = 'API ERROR: ' + e.data;
});
};
var _getBlock = function(hash) {
Block.get({
blockHash: hash
}, function(res) {
$scope.totalBlocks = res.height;
});
};
var socket = getSocket($scope);
socket.on('connect', function() {
socket.emit('subscribe', 'inv');
socket.on('block', function(block) {
var blockHash = block.toString();
_getBlock(blockHash);
});
});
$rootScope.isCollapsed = true;
});