7 .when('/', { |
7 .when('/', { |
8 templateUrl: 'slideshow/slideshow.html', |
8 templateUrl: 'slideshow/slideshow.html', |
9 controller: 'slideshowCtrl' |
9 controller: 'slideshowCtrl' |
10 }); |
10 }); |
11 }) |
11 }) |
12 /*.service('slideshowApi', function($resource, context) { |
|
13 console.log('slideshow 5',this); |
|
14 this.slideshow = $resource(context.urls.slideshowUrl); |
|
15 })*/ |
|
16 .service('slideshowModel', function(searchApi) { |
12 .service('slideshowModel', function(searchApi) { |
17 console.log('slideshow 6',this); |
13 console.log('slideshow 6',this); |
18 /*this.slideshow = function(myVarForData){ |
|
19 searchApi.searchResource({q:'stop_email=toto@gmail.com', of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}, myVarForData); |
|
20 };*/ |
|
21 this.slideshow = searchApi.searchResource({q:'stop_email=toto@gmail.com', of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).getJsonp(); |
14 this.slideshow = searchApi.searchResource({q:'stop_email=toto@gmail.com', of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).getJsonp(); |
22 console.log('slideshow 6-2',this); |
|
23 }) |
15 }) |
24 .controller('slideshowCtrl', function($scope, $filter, $location, $routeParams, $timeout, searchApi, slideshowModel){ |
16 .controller('slideshowCtrl', function($scope, $filter, $location, $routeParams, $timeout, searchApi, slideshowModel){ |
25 //console.log('slideshow 7', $location, $routeParams, searchApi); |
17 //console.log('slideshow 7', $location, $routeParams, searchApi); |
26 console.log('slideshow 7'); |
18 console.log('slideshow 7'); |
27 $scope.slideshow = slideshowModel.slideshow; |
19 $scope.slideshow = slideshowModel.slideshow; |
30 //console.log('$routeParams',$routeParams); |
22 //console.log('$routeParams',$routeParams); |
31 if(typeof $routeParams.searched !== 'undefined'){ |
23 if(typeof $routeParams.searched !== 'undefined'){ |
32 var a = $routeParams.searched.split(','); |
24 var a = $routeParams.searched.split(','); |
33 var q = a[0], i = parseInt(a[1]); |
25 var q = a[0], i = parseInt(a[1]); |
34 if(a.length===2 && !isNaN(i)){ |
26 if(a.length===2 && !isNaN(i)){ |
35 searchApi.searchResource({q:q, of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).$promise.then( |
27 searchApi.searchResource({q:q, of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).getJsonp().$promise.then( |
36 //success |
28 //success |
37 function( data ){ |
29 function( data ){ |
38 var hit = data.hits[i]; |
30 $scope.slideshow.hits.push(data.hits[i]); |
39 $scope.slideshow.images.push({url: $filter('meta')(hit.metas, 'url'), |
|
40 title: $filter('meta')(hit.metas, 'name'), |
|
41 description: $filter('meta')(hit.metas, 'description'), tags: [], user_title:'', user_description:''}); |
|
42 // timeout because |
31 // timeout because |
43 $timeout(function(){$scope.slideshow.images[$scope.slideshow.images.length-1].active = true;}, 200); |
32 $timeout(function(){$scope.slideshow.hits[$scope.slideshow.hits.length-1].active = true;}, 500); |
44 }, |
33 }, |
45 //error |
34 //error |
46 function( error ){ |
35 function( error ){ |
47 alert('Erreur avec la requête (dans slideshow)', error); |
36 alert('Erreur avec la requête (dans slideshow)', error); |
48 } |
37 } |