<commit_before>'use strict';

/* Controllers */

angular.module('myApp.controllers', []).
  controller('AppCtrl', function ($scope, socket) {

  }).
  controller('MyCtrl1', function ($scope, $timeout, $http, socket, $location) {
    //global variable
    var PAGELIMIT = 9;
    $scope.flatUiColors = {
      "c1" : "#1abc9c",
      "c2" : "#2ecc71",
      "c3" : "#2980b9",
      "c4" : "#8e44ad",
      "c5" : "#34495e",
      "c6" : "#d35400",
      "c7" : "#c0392b",
      "c8" : "#7f8c8d",
      "c9" : "#f39c12",
      "c0" : "#3498db"
    }

    $scope.testNotes = [
      {"sentence":"1"},
      {"sentence":"2"},      
      {"sentence":"3"}
    ]

    $scope.limit = PAGELIMIT;
    $scope.notes = [];
    $scope.endOfLine = false;
    $scope.notesLength = 0;
    $scope.busy = false;
    $scope.bottomShadow = {    
      "box-shadow": "0 0px 0px 0px #000000",
      "-moz-box-shadow": "0 0px 0px 0px #000000",
      "-webkit-box-shadow": "0 0px 0px 0px #000000"
    }

    $(document).on("scroll",function(){
      if($(document).scrollTop()>10){
          $scope.bottomShadow = {    
            "-webkit-box-shadow": "0px 2px 4px #B8B8B8",
               "-moz-box-shadow": "0px 2px 4px #B8B8B8",
                    "box-shadow": "0px 2px 4px #B8B8B8"
          };
      } else{
          $scope.bottomShadow = {    
            "box-shadow": "0 0px 0px 0px #000000",
            "-moz-box-shadow": "0 0px 0px 0px #000000",
            "-webkit-box-shadow": "0 0px 0px 0px #000000"
          };
      }
    });

    $scope.getNotesLength = function() {
      $scope.busy = true;
      $http.get('/api/notes/count').success(function(data) {
        $scope.notesLength = data;
        $scope.busy = false;
      });
    }

    socket.on('note: added', function (data) {
      $scope.loadMore($scope.notes.length + 1);
    });

    socket.on('note: updated', function (data) {
      $scope.loadMore($scope.notes.length);
    });

    socket.on('note: removed', function (data) {
      $scope.loadMore($scope.notes.length - 1);
    });

    $scope.loadMore = function(limit) {
      if ($scope.notes.length != 0) {
        if (($scope.notes.length) >= $scope.notesLength) {
          $scope.endOfLine = true;
          return;
        }
      }

      $http.get('/api/notes?limit=' + limit).success(function(data) {
        $scope.notes = data;
        $scope.limit += PAGELIMIT;
      });
    };

    $scope.clickFunction = function() {
      $location.path("/view2");
    }

    $scope.fadeInClass = function() {
      return {
        "opacity" : "1"
      };
    }

    $scope.showIcon = function(index) {
      $scope.notes[index].show = true;
    }

    $scope.hideIcon = function(index) {
      $scope.notes[index].show = false;
    }

    $scope.deleteNote = function(index) {
      $http.delete('/api/notes/' + $scope.notes[index]['_id']).success(function(data) {

      })
    }

    $scope.barColor = function(index) {
      var colorNum = parseInt(index - 1)
      return {
        "background-color" : $scope.flatUiColors['c' + colorNum]
      };
    }

  }).
  controller('navbarController', function ($scope, $location) {
    $scope.paths = {
      '/index': false,
      '/about': false,
      '/contact': false,
      '/add':false
    }

    $scope.collapseFunc = function() {
      if ($('.navbar-toggle').is(":visible"))
        $('#slideMenu').collapse('toggle');
    }

    $scope.$watch(function(){
      return $location.path();
    }, function(newValue, oldValue) { 
      $scope.paths[newValue] = true;
       $scope.paths[oldValue] = false;
    });
  }).
  controller('addNoteController', function ($scope, $http, $location, $window) {
    $scope.note = {};

    $scope.addNote = function() {
      $http.post('/api/notes',{sentence: $scope.note.sentence, translation: $scope.note.translation}).
          success(function(data, status, headers, config) {
            $window.location.href = '/'
          }).
          error(function(data, status, headers, config) {
              
          });
     };         
  });






<commit_msg>Fixed auto polling<commit_after>'use strict';

/* Controllers */

angular.module('myApp.controllers', []).
  controller('AppCtrl', function ($scope, socket) {

  }).
  controller('MyCtrl1', function ($scope, $timeout, $http, socket, $location) {
    //global variable
    var PAGELIMIT = 9;
    $scope.flatUiColors = {
      "c1" : "#1abc9c",
      "c2" : "#2ecc71",
      "c3" : "#2980b9",
      "c4" : "#8e44ad",
      "c5" : "#34495e",
      "c6" : "#d35400",
      "c7" : "#c0392b",
      "c8" : "#7f8c8d",
      "c9" : "#f39c12",
      "c0" : "#3498db"
    }

    $scope.testNotes = [
      {"sentence":"1"},
      {"sentence":"2"},      
      {"sentence":"3"}
    ]

    $scope.limit = PAGELIMIT;
    $scope.notes = [];
    $scope.endOfLine = false;
    $scope.notesLength = 1;
    $scope.busy = false;
    $scope.bottomShadow = {    
      "box-shadow": "0 0px 0px 0px #000000",
      "-moz-box-shadow": "0 0px 0px 0px #000000",
      "-webkit-box-shadow": "0 0px 0px 0px #000000"
    }

    $(document).on("scroll",function(){
      if($(document).scrollTop()>10){
          $scope.bottomShadow = {    
            "-webkit-box-shadow": "0px 2px 4px #B8B8B8",
               "-moz-box-shadow": "0px 2px 4px #B8B8B8",
                    "box-shadow": "0px 2px 4px #B8B8B8"
          };
      } else{
          $scope.bottomShadow = {    
            "box-shadow": "0 0px 0px 0px #000000",
            "-moz-box-shadow": "0 0px 0px 0px #000000",
            "-webkit-box-shadow": "0 0px 0px 0px #000000"
          };
      }
    });

    $scope.getNotesLength = function() {
      $http.get('/api/notes/count').success(function(data) {
        $scope.notesLength = data;
        $http.get('/api/notes?limit=9').success(function(data) {
          $scope.notes = data;
          $scope.limit += PAGELIMIT;
          $scope.busy = false;
        });
      });
    }

    socket.on('note: added', function (data) {
      $http.get('/api/notes').success(function(data) {
        $scope.notes.unshift(data[0]);
      });
    });

    socket.on('note: updated', function (data) {
      $scope.loadMore($scope.notes.length);
    });

    socket.on('note: removed', function (data) {
      $scope.loadMore($scope.notes.length - 1);
    });

    $scope.loadMore = function(limit) {
      $scope.busy = true;
      if (($scope.notes.length) >= $scope.notesLength) {
        $scope.busy = false;
        $scope.endOfLine = true;
        return;
      }
      $http.get('/api/notes?limit=' + limit).success(function(data) {
        $scope.notes = data;
        $scope.limit += PAGELIMIT;
        $scope.busy = false;
      });
    };

    $scope.clickFunction = function() {
      $location.path("/view2");
    }

    $scope.fadeInClass = function() {
      return {
        "opacity" : "1"
      };
    }

    $scope.showIcon = function(index) {
      $scope.notes[index].show = true;
    }

    $scope.hideIcon = function(index) {
      $scope.notes[index].show = false;
    }

    $scope.deleteNote = function(index) {
      $http.delete('/api/notes/' + $scope.notes[index]['_id']).success(function(data) {

      })
    }

    $scope.barColor = function(index) {
      var colorNum = parseInt(index - 1)
      return {
        "background-color" : $scope.flatUiColors['c' + colorNum]
      };
    }

    $scope.getNotesLength();

  }).
  controller('navbarController', function ($scope, $location) {
    $scope.paths = {
      '/index': false,
      '/about': false,
      '/contact': false,
      '/add':false
    }

    $scope.collapseFunc = function() {
      if ($('.navbar-toggle').is(":visible"))
        $('#slideMenu').collapse('toggle');
    }

    $scope.$watch(function(){
      return $location.path();
    }, function(newValue, oldValue) { 
      $scope.paths[newValue] = true;
       $scope.paths[oldValue] = false;
    });
  }).
  controller('addNoteController', function ($scope, $http, $location, $window) {
    $scope.note = {};

    $scope.addNote = function() {
      $http.post('/api/notes',{sentence: $scope.note.sentence, translation: $scope.note.translation}).
          success(function(data, status, headers, config) {
            $window.location.href = '/'
          }).
          error(function(data, status, headers, config) {
              
          });
     };         
  });
{'fraction_non_alphanumeric': 0.1873508353221957, 'fraction_numerical': 0.03341288782816229, 'mean_word_length': 2.086924493554328, 'pattern_counts': {'":': 26, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5866992', 'n_tokens_mistral': 3030, 'n_tokens_neox': 2816, 'n_words': 473}