From d96f60f18b1d275d66d3037489fe6ff5db5d5a65 Mon Sep 17 00:00:00 2001 From: Mario Colque Date: Wed, 12 Feb 2014 13:04:26 -0300 Subject: [PATCH] added helper to reset serch --- public/src/js/controllers/search.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/public/src/js/controllers/search.js b/public/src/js/controllers/search.js index c41bbb88..deab77a4 100644 --- a/public/src/js/controllers/search.js +++ b/public/src/js/controllers/search.js @@ -13,6 +13,11 @@ angular.module('insight.search').controller('SearchController', }, 2000); }; + var _resetSearch = function() { + $scope.q = ''; + $scope.loading = false; + }; + $scope.search = function() { var q = $scope.q; $scope.badQuery = false; @@ -21,30 +26,26 @@ angular.module('insight.search').controller('SearchController', Block.get({ blockHash: q }, function() { - $scope.q = ''; - $scope.loading = false; + _resetSearch(); $location.path('block/' + q); - }, function () { //block not found, search on TX + }, function() { //block not found, search on TX Transaction.get({ txId: q }, function() { - $scope.q = ''; - $scope.loading = false; + _resetSearch(); $location.path('tx/' + q); - }, function () { //tx not found, search on Address + }, function() { //tx not found, search on Address Address.get({ addrStr: q }, function() { - $scope.q = ''; - $scope.loading = false; + _resetSearch(); $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. BlockByHeight.get({ blockHeight: q }, function(hash) { - $scope.q = ''; - $scope.loading = false; + _resetSearch(); $location.path('/block/' + hash.blockHash); }, function() { //not found, fail :( _badQuery();