added helper to reset serch
This commit is contained in:
parent
42968ba12e
commit
d96f60f18b
|
@ -13,6 +13,11 @@ angular.module('insight.search').controller('SearchController',
|
||||||
}, 2000);
|
}, 2000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var _resetSearch = function() {
|
||||||
|
$scope.q = '';
|
||||||
|
$scope.loading = false;
|
||||||
|
};
|
||||||
|
|
||||||
$scope.search = function() {
|
$scope.search = function() {
|
||||||
var q = $scope.q;
|
var q = $scope.q;
|
||||||
$scope.badQuery = false;
|
$scope.badQuery = false;
|
||||||
|
@ -21,30 +26,26 @@ angular.module('insight.search').controller('SearchController',
|
||||||
Block.get({
|
Block.get({
|
||||||
blockHash: q
|
blockHash: q
|
||||||
}, function() {
|
}, function() {
|
||||||
$scope.q = '';
|
_resetSearch();
|
||||||
$scope.loading = false;
|
|
||||||
$location.path('block/' + q);
|
$location.path('block/' + q);
|
||||||
}, function () { //block not found, search on TX
|
}, function() { //block not found, search on TX
|
||||||
Transaction.get({
|
Transaction.get({
|
||||||
txId: q
|
txId: q
|
||||||
}, function() {
|
}, function() {
|
||||||
$scope.q = '';
|
_resetSearch();
|
||||||
$scope.loading = false;
|
|
||||||
$location.path('tx/' + q);
|
$location.path('tx/' + q);
|
||||||
}, function () { //tx not found, search on Address
|
}, function() { //tx not found, search on Address
|
||||||
Address.get({
|
Address.get({
|
||||||
addrStr: q
|
addrStr: q
|
||||||
}, function() {
|
}, function() {
|
||||||
$scope.q = '';
|
_resetSearch();
|
||||||
$scope.loading = false;
|
|
||||||
$location.path('address/' + q);
|
$location.path('address/' + q);
|
||||||
}, function () { // block by height not found
|
}, function() { // block by height not found
|
||||||
if (isFinite(q)) { // ensure that q is a finite number. A logical height value.
|
if (isFinite(q)) { // ensure that q is a finite number. A logical height value.
|
||||||
BlockByHeight.get({
|
BlockByHeight.get({
|
||||||
blockHeight: q
|
blockHeight: q
|
||||||
}, function(hash) {
|
}, function(hash) {
|
||||||
$scope.q = '';
|
_resetSearch();
|
||||||
$scope.loading = false;
|
|
||||||
$location.path('/block/' + hash.blockHash);
|
$location.path('/block/' + hash.blockHash);
|
||||||
}, function() { //not found, fail :(
|
}, function() { //not found, fail :(
|
||||||
_badQuery();
|
_badQuery();
|
||||||
|
|
Loading…
Reference in New Issue