'use strict';
// WORK CONTROLLER
// Description: Define the following functionalities:
// All the functionalities on the "Work" section to display items and filter them
//var app = angular.module("myApp",[]);  
    app.controller('work', function($scope,$http, $filter) {
        
 
        
        $http({
            
            method:"GET",
            url:"/api/work"
        
            }).then(function mySuccess(response){
            
            
             $scope.works=response.data.works;
            
            
        }, function myError(response){
        
        console.log("error");
    });
    

        
        $scope.deleteItem = function(item) {
        
          
            $scope.removeIndex = -1;
            $scope.removeIndex=$scope.works.indexOf(item);
        
        
        };
        
        $scope.deleteConfirm = function() {
  
            $scope.works.splice($scope.removeIndex, 1);
         
        };
        
        
        $scope.addItems=function(){
     
            var newItem={
                
                title: $scope.addtitle,
                author:$scope.addAuthor,
                like:$scope.addLike,
                comment:$scope.addComment,
                image: ''
                
                  
            }
           // alert($scope.addTitle);
            $scope.works.push(newItem);
            $scope.addtitle="";
            $scope.addAuthor="";
            $scope.addLike="";
            $scope.addComment="";
            
            
        }
        
         $scope.editItems=function(item){
             $scope.editIndex = -1;
            $scope.editIndex=$scope.works.indexOf(item);
             $scope.edittitle=item.title;
            $scope.editAuthor=item.author;
            $scope.editLike=item.like;
            $scope.editComment=item.comment;
             
         }
         
         $scope.editConfirm = function() {
             var i=$scope.editIndex;
            $scope.works[i].author=$scope.editAuthor;
            $scope.works[i].title=$scope.edittitle;
             $scope.works[i].like=$scope.editLike;
             $scope.works[i].comment=$scope.editComment;
            
        };
    
        
        $scope.order = function(expression, reverse) {
            $scope.works = $filter('orderBy')($scope.works, expression, reverse);
        }

          $scope.greaterThan1 = function(work) {
      
          var partNum=work.like.substring(0,work.like.length-6).split(',');
          var num=parseInt(partNum[0]+partNum[1]);
          
              if(!$scope.searchLike){
                  
                  return true;
                  
              }
            if (num>parseInt($scope.searchLike)) {                
                return true;
            } else {                
                return false;
            }
    
   
        };
        
        
         $scope.greaterThan2 = function(work) {
 
          var partNum=work.comment.substring(0,work.comment.length-9).split(',');
          var num=parseInt(partNum[0]+partNum[1]);
        
              if(!$scope.searchComment){
                  
                  return true;
                  
              }
            if (num>parseInt($scope.searchComment)) {                
                return true;
            } else {                
                return false;
            }
    
      
        };
        
    });


@@ -208,3233 +208,4 @@
 ;  %0A
-    app.controller('work', function($scope,$http, $filter) %7B%0A        %0A %0A        %0A        $http(%7B%0A            %0A            method:%22GET%22,%0A            url:%22/api/work%22%0A        %0A            %7D).then(function mySuccess(response)%7B%0A            %0A            %0A             $scope.works=response.data.works;%0A            %0A            %0A        %7D, function myError(response)%7B%0A        %0A        console.log(%22error%22);%0A    %7D);%0A    %0A%0A        %0A        $scope.deleteItem = function(item) %7B%0A        %0A          %0A            $scope.removeIndex = -1;%0A            $scope.removeIndex=$scope.works.indexOf(item);%0A        %0A        %0A        %7D;%0A        %0A        $scope.deleteConfirm = function() %7B%0A  %0A            $scope.works.splice($scope.removeIndex, 1);%0A         %0A        %7D;%0A        %0A        %0A        $scope.addItems=function()%7B%0A     %0A            var newItem=%7B%0A                %0A                title: $scope.addtitle,%0A                author:$scope.addAuthor,%0A                like:$scope.addLike,%0A                comment:$scope.addComment,%0A                image: ''%0A                %0A                  %0A            %7D%0A           // alert($scope.addTitle);%0A            $scope.works.push(newItem);%0A            $scope.addtitle=%22%22;%0A            $scope.addAuthor=%22%22;%0A            $scope.addLike=%22%22;%0A            $scope.addComment=%22%22;%0A            %0A            %0A        %7D%0A        %0A         $scope.editItems=function(item)%7B%0A             $scope.editIndex = -1;%0A            $scope.editIndex=$scope.works.indexOf(item);%0A             $scope.edittitle=item.title;%0A            $scope.editAuthor=item.author;%0A            $scope.editLike=item.like;%0A            $scope.editComment=item.comment;%0A             %0A         %7D%0A         %0A         $scope.editConfirm = function() %7B%0A             var i=$scope.editIndex;%0A            $scope.works%5Bi%5D.author=$scope.editAuthor;%0A            $scope.works%5Bi%5D.title=$scope.edittitle;%0A             $scope.works%5Bi%5D.like=$scope.editLike;%0A             $scope.works%5Bi%5D.comment=$scope.editComment;%0A            %0A        %7D;%0A    %0A        %0A        $scope.order = function(expression, reverse) %7B%0A            $scope.works = $filter('orderBy')($scope.works, expression, reverse);%0A        %7D%0A%0A          $scope.greaterThan1 = function(work) %7B%0A      %0A          var partNum=work.like.substring(0,work.like.length-6).split(',');%0A          var num=parseInt(partNum%5B0%5D+partNum%5B1%5D);%0A          %0A              if(!$scope.searchLike)%7B%0A                  %0A                  return true;%0A                  %0A              %7D%0A            if (num%3EparseInt($scope.searchLike)) %7B                %0A                return true;%0A            %7D else %7B                %0A                return false;%0A            %7D%0A    %0A   %0A        %7D;%0A        %0A        %0A         $scope.greaterThan2 = function(work) %7B%0A %0A          var partNum=work.comment.substring(0,work.comment.length-9).split(',');%0A          var num=parseInt(partNum%5B0%5D+partNum%5B1%5D);%0A        %0A              if(!$scope.searchComment)%7B%0A                  %0A                  return true;%0A                  %0A              %7D%0A            if (num%3EparseInt($scope.searchComment)) %7B                %0A                return true;%0A            %7D else %7B                %0A                return false;%0A            %7D%0A    %0A      %0A        %7D;%0A        %0A    %7D);%0A%0A

Update work.js