client/app/search/search_controller.js
changeset 8 824c87a9084c
parent 7 e70f1c4785f3
child 47 dd750778535c
--- a/client/app/search/search_controller.js	Mon Oct 06 17:36:47 2014 +0200
+++ b/client/app/search/search_controller.js	Mon Oct 06 22:52:30 2014 +0200
@@ -12,43 +12,7 @@
     .controller('searchCtrl', function($scope, $location, $routeParams, searchApi){
       console.log('search 6',$scope, $location, $routeParams);
       $scope.q = $routeParams.q || '';
-      searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).$promise.then(
-          //success
-          function( data ){
-              // Transform meta list into meta dict
-              var nb = data.hits.length;
-              for(var i=0;i<nb;i++){
-                  var nb_metas = data.hits[i].metas.length;
-                  data.hits[i].metas_dict = {};
-                  for(var j=0;j<nb_metas;j++){
-                      if(typeof data.hits[i].metas[j].images==='undefined'){
-                          data.hits[i].metas_dict[data.hits[i].metas[j].name] = data.hits[i].metas[j].value;
-                      }
-                      else{
-                          data.hits[i].metas_dict.images = data.hits[i].metas[j].images[0].value;
-                      }
-                  }
-              }
-              $scope.results = data;
-          },
-          //error
-          function( error ){
-              alert('Erreur avec la requĂȘte', error);
-          }
-      );
-    })
-    .filter('meta', function() {
-        return function(input, metaName) {
-            var nb = input.length, i = 0, found = false;
-            while(found===false && i<nb){
-                if(input[i].name===metaName){
-                    found = true;
-                    return input[i].value;
-                }
-                i++;
-            }
-            return '';
-        };
+      $scope.results = searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).getJsonp();
     });
 
 })();