bitcore-node-zcash/public/js/controllers/transactions.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

'use strict';
2014-01-17 11:49:08 -08:00
angular.module('insight.transactions').controller('transactionsController',
2014-01-20 13:09:18 -08:00
function ($scope, $rootScope, $routeParams, $location, Global, Transaction, TransactionsByBlock, TransactionsByAddress, get_socket) {
$scope.global = Global;
2014-01-17 11:49:08 -08:00
$scope.findThis = function() {
$scope.findTx($routeParams.txId);
};
$scope.findTx = function(txid) {
Transaction.get({
2014-01-17 11:49:08 -08:00
txId: txid
}, function(tx) {
$scope.tx = tx;
$scope.txs.unshift(tx);
2014-01-20 11:11:35 -08:00
}, function(e) {
if (e.status === 400) {
$rootScope.flashMessage = 'Invalid Transaction ID: ' + $routeParams.txId;
}
else if (e.status === 503) {
$rootScope.flashMessage = 'Backend Error. ' + e.data;
}
else {
$rootScope.flashMessage = 'Transaction Not Found';
}
$location.path('/');
});
};
$scope.byBlock = function(bId) {
TransactionsByBlock.query({
2014-01-15 05:22:07 -08:00
block: bId
}, function(txs) {
$scope.txs = txs;
});
};
$scope.byAddress = function(aId) {
TransactionsByAddress.query({
2014-01-15 05:22:07 -08:00
address: aId
}, function(txs) {
$scope.txs = txs;
});
};
2014-01-20 09:30:25 -08:00
var socket = get_socket($scope);
socket.on('atx', function(tx) {
console.log('atx '+tx.txid);
var beep = new Audio('/sound/transaction.mp3');
beep.play();
2014-01-17 11:49:08 -08:00
$scope.findTx(tx.txid);
2014-01-20 09:30:25 -08:00
});
2014-01-17 11:49:08 -08:00
$scope.txs = [];
2014-01-20 13:09:18 -08:00
});