Subversion Repositories SmartDukaan

Rev

Rev 13560 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13560 Rev 13563
Line 5... Line 5...
5
// the 2nd parameter is an array of 'requires'
5
// the 2nd parameter is an array of 'requires'
6
// 'starter.services' is found in services.js
6
// 'starter.services' is found in services.js
7
// 'starter.controllers' is found in controllers.js
7
// 'starter.controllers' is found in controllers.js
8
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'starter.filters', 'LocalStorageModule','ngResource'])
8
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'starter.filters', 'LocalStorageModule','ngResource'])
9
 
9
 
10
.run(function($ionicPlatform,$rootScope,Clicks,localStorageService) {
10
.run(function($ionicPlatform,$rootScope,Clicks,localStorageService,RemAction,UserAction) {
11
  $rootScope.likeProduct = function(id){
11
  $rootScope.likeProduct = function(id,obj){
12
    // alert('like '+id);
12
    if($rootScope.liked[id]){
-
 
13
      console.log('already liked, so remove ilike');
-
 
14
      RemAction.rem({user_id:localStorageService.get('me'),store_product_id:id,action:'like'});
-
 
15
      $rootScope.liked[id] = null;
-
 
16
    }else{
13
    // $scope.click = Clicks.get({'me':localStorageService.get('me'),'id':id});    
17
      UserAction.like({user_id:localStorageService.get('me'),store_product_id:id,action:'like'});
-
 
18
      $rootScope.liked[id] = 1;
-
 
19
      $rootScope.disliked[id] = null;
-
 
20
    }    
14
  },
21
  },
15
  $rootScope.unlikeProduct = function(id){
22
  $rootScope.unlikeProduct = function(id,obj){
16
    alert('unlike '+id);
23
    if($rootScope.disliked[id]){
-
 
24
      console.log('already disliked, so remove dislike');
-
 
25
      RemAction.rem({user_id:localStorageService.get('me'), store_product_id:id,action:'dislike'});
-
 
26
      $rootScope.disliked[id] = null;
-
 
27
    }else{
-
 
28
      UserAction.like({user_id:localStorageService.get('me'), store_product_id:id,action:'dislike'});
-
 
29
      $rootScope.disliked[id] = 1;
17
    console.log(id);
30
      $rootScope.liked[id] = null;
-
 
31
    }
18
  }
32
  }
19
  $rootScope.viewproduct = function(id){
33
  $rootScope.viewproduct = function(id){
20
    Clicks.get({'me':localStorageService.get('me'), 'id':id},  
34
    Clicks.get({'me':localStorageService.get('me'), 'id':id},  
21
      function( result ) {          
35
      function( result ) {          
22
        console.log(result);
36
        console.log(result);