search by height of block
This commit is contained in:
parent
56dc130b4f
commit
ef109e3251
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('insight.search').controller('SearchController',
|
angular.module('insight.search').controller('SearchController',
|
||||||
function ($scope, $routeParams, $location, $timeout, Global, Block, Transaction, Address) {
|
function ($scope, $routeParams, $location, $timeout, Global, Block, Transaction, Address, BlockByHeight) {
|
||||||
$scope.global = Global;
|
$scope.global = Global;
|
||||||
|
|
||||||
$scope.search = function() {
|
$scope.search = function() {
|
||||||
|
@ -10,28 +10,34 @@ angular.module('insight.search').controller('SearchController',
|
||||||
$scope.badQuery = false;
|
$scope.badQuery = false;
|
||||||
$scope.q = '';
|
$scope.q = '';
|
||||||
|
|
||||||
Block.get({
|
BlockByHeight.get({
|
||||||
blockHash: q
|
blockHeight: q
|
||||||
}, function() {
|
}, function(hash) {
|
||||||
$location.path('block/' + q);
|
$location.path('/block/' + hash.blockHash);
|
||||||
}, function () { //block not found, search on TX
|
}, function() { // block by height not found
|
||||||
Transaction.get({
|
Block.get({
|
||||||
txId: q
|
blockHash: q
|
||||||
}, function() {
|
}, function() {
|
||||||
$location.path('tx/' + q);
|
$location.path('block/' + q);
|
||||||
}, function () { //tx not found, search on Address
|
}, function () { //block not found, search on TX
|
||||||
Address.get({
|
Transaction.get({
|
||||||
addrStr: q
|
txId: q
|
||||||
}, function() {
|
}, function() {
|
||||||
$location.path('address/' + q);
|
$location.path('tx/' + q);
|
||||||
}, function () { //address not found, fail :(
|
}, function () { //tx not found, search on Address
|
||||||
$scope.badQuery = true;
|
Address.get({
|
||||||
$timeout(function() {
|
addrStr: q
|
||||||
$scope.badQuery = false;
|
}, function() {
|
||||||
}, 2000);
|
$location.path('address/' + q);
|
||||||
$scope.q = q;
|
}, function () { //address not found, fail :(
|
||||||
});
|
$scope.badQuery = true;
|
||||||
});
|
$timeout(function() {
|
||||||
|
$scope.badQuery = false;
|
||||||
|
}, 2000);
|
||||||
|
$scope.q = q;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue