<commit_before>angular.module('starter.controllers', ['monospaced.elastic', 'angularMoment'])

  .controller('DashCtrl', function ($scope) {
  })

  .controller('ChatsCtrl', function ($scope, Chats) {
    // With the new view caching in Ionic, Controllers are only called
    // when they are recreated or on app start, instead of every page change.
    // To listen for when this page is active (for example, to refresh data),
    // listen for the $ionicView.enter event:
    //
    //$scope.$on('$ionicView.enter', function(e) {
    //});

    $scope.chats = Chats.all();
    $scope.remove = function (chat) {
      Chats.remove(chat);
    };
  })

  .controller('ChatDetailCtrl', ['$scope', '$rootScope', '$state',
    '$stateParams', 'MockService', '$ionicActionSheet',
    '$ionicPopup', '$ionicScrollDelegate', '$timeout', '$interval', 'Chats',
    function ($scope, $rootScope, $state, $stateParams, MockService,
              $ionicActionSheet,
              $ionicPopup, $ionicScrollDelegate, $timeout, $interval, Chats) {

      $scope.chat = Chats.get($stateParams.chatId);

      // mock acquiring data via $stateParams
      $scope.toUser = {
        _id : '534b8e5aaa5e7afc1b23e69b',
        pic : 'http://ionicframework.com/img/docs/venkman.jpg',
        username : 'Venkman'
      };

      // this could be on $rootScope rather than in $stateParams
      $scope.user = {
        _id : '534b8fb2aa5e7afc1b23e69c',
        pic : 'http://ionicframework.com/img/docs/mcfly.jpg',
        username : 'Marty'
      };

      $scope.input = {
        message : localStorage['userMessage-' + $scope.toUser._id] || ''
      };

      var messageCheckTimer;

      var viewScroll = $ionicScrollDelegate.$getByHandle('userMessageScroll');
      var footerBar; // gets set in $ionicView.enter
      var scroller;
      var txtInput; // ^^^
      var tabNavi;
      var $tabNavi;
      var tabNaviHeight = 0;
      var keyboardHeight = 0;
      var isAndroid = ionic.Platform.isAndroid();

      // TODO 입력 버튼 제거, 키보드의 엔터로 메세지 입력되게 변경하여 키보드 show, hide 문제 해결하기
      function keyboardShowHandler(e) {
        console.log('keyboardShowHandler');
        keyboardHeight = e.keyboardHeight;

        if (!isAndroid) {
          tabNaviHeight = 0;
        }

        $rootScope.hideTabs = true;

        $timeout(function() {
          if (isAndroid) {
            scroller.style.bottom = footerBar.clientHeight + tabNaviHeight + 'px';
          } else {
            scroller.style.bottom = footerBar.clientHeight + keyboardHeight + 'px';
          }
          viewScroll.scrollBottom(false);
        }, 0);
      }

      function keyboardHideHandler(e) {
        console.log('Goodnight, sweet prince');
        keyboardHeight = 0;
        tabNaviHeight = tabNavi.offsetHeight;

        $timeout(function() {
          scroller.style.bottom = footerBar.clientHeight + tabNaviHeight + 'px';
          viewScroll.scrollBottom(false);
        }, 0);
      }

      function keydownHandler(e) {
        console.log('key down handler', e.keyCode);
        if (e.keyCode === 13) {
          e.preventDefault();
          e.stopPropagation();

          $scope.sendMessage();
        }
      }

      $scope.$on('$ionicView.enter', function () {
        console.log('UserMessages $ionicView.enter');

        window.addEventListener('native.keyboardshow', keyboardShowHandler);
        window.addEventListener('native.keyboardhide', keyboardHideHandler);

        if (keyboardPluginAvailable()) {
          cordova.plugins.Keyboard.disableScroll(true);
        }

        getMessages();

        $timeout(function () {
          footerBar = document.body.querySelector('#userMessagesView .bar-footer');
          scroller = document.body.querySelector('#userMessagesView .scroll-content');
          txtInput = angular.element(footerBar.querySelector('textarea'));
          tabNavi = document.body.querySelector('.tab-nav');<commit_msg>아무것도 입력하지 않거나 스페이스만 입력한 경우 엔터 키를 눌러도 메세지 전달을 하지 않도록 변경<commit_after>angular.module('starter.controllers', ['monospaced.elastic', 'angularMoment'])

  .controller('DashCtrl', function ($scope) {
  })

  .controller('ChatsCtrl', function ($scope, Chats) {
    // With the new view caching in Ionic, Controllers are only called
    // when they are recreated or on app start, instead of every page change.
    // To listen for when this page is active (for example, to refresh data),
    // listen for the $ionicView.enter event:
    //
    //$scope.$on('$ionicView.enter', function(e) {
    //});

    $scope.chats = Chats.all();
    $scope.remove = function (chat) {
      Chats.remove(chat);
    };
  })

  .controller('ChatDetailCtrl', ['$scope', '$rootScope', '$state',
    '$stateParams', 'MockService', '$ionicActionSheet',
    '$ionicPopup', '$ionicScrollDelegate', '$timeout', '$interval', 'Chats',
    function ($scope, $rootScope, $state, $stateParams, MockService,
              $ionicActionSheet,
              $ionicPopup, $ionicScrollDelegate, $timeout, $interval, Chats) {

      $scope.chat = Chats.get($stateParams.chatId);

      // mock acquiring data via $stateParams
      $scope.toUser = {
        _id : '534b8e5aaa5e7afc1b23e69b',
        pic : 'http://ionicframework.com/img/docs/venkman.jpg',
        username : 'Venkman'
      };

      // this could be on $rootScope rather than in $stateParams
      $scope.user = {
        _id : '534b8fb2aa5e7afc1b23e69c',
        pic : 'http://ionicframework.com/img/docs/mcfly.jpg',
        username : 'Marty'
      };

      $scope.input = {
        message : localStorage['userMessage-' + $scope.toUser._id] || ''
      };

      var messageCheckTimer;

      var viewScroll = $ionicScrollDelegate.$getByHandle('userMessageScroll');
      var footerBar; // gets set in $ionicView.enter
      var scroller;
      var txtInput; // ^^^
      var tabNavi;
      var $tabNavi;
      var tabNaviHeight = 0;
      var keyboardHeight = 0;
      var isAndroid = ionic.Platform.isAndroid();

      // TODO 입력 버튼 제거, 키보드의 엔터로 메세지 입력되게 변경하여 키보드 show, hide 문제 해결하기
      function keyboardShowHandler(e) {
        console.log('keyboardShowHandler');
        keyboardHeight = e.keyboardHeight;

        if (!isAndroid) {
          tabNaviHeight = 0;
        }

        $rootScope.hideTabs = true;

        $timeout(function() {
          if (isAndroid) {
            scroller.style.bottom = footerBar.clientHeight + tabNaviHeight + 'px';
          } else {
            scroller.style.bottom = footerBar.clientHeight + keyboardHeight + 'px';
          }
          viewScroll.scrollBottom(false);
        }, 0);
      }

      function keyboardHideHandler(e) {
        console.log('Goodnight, sweet prince');
        keyboardHeight = 0;
        tabNaviHeight = tabNavi.offsetHeight;

        $timeout(function() {
          scroller.style.bottom = footerBar.clientHeight + tabNaviHeight + 'px';
          viewScroll.scrollBottom(false);
        }, 0);
      }

      function keydownHandler(e) {
        console.log('key down handler', e.keyCode);
        if (e.keyCode === 13) {
          e.preventDefault();
          e.stopPropagation();

          if (txtInput.val().replace(/\s+/g, '') !== '') {
            $scope.sendMessage();
          } else {
            txtInput.val('');
          }
        }
      }

      $scope.$on('$ionicView.enter', function () {
        console.log('UserMessages $ionicView.enter');

        window.addEventListener('native.keyboardshow', keyboardShowHandler);
        window.addEventListener('native.keyboardhide', keyboardHideHandler);

        if (keyboardPluginAvailable()) {
          cordova.plugins.Keyboard.disableScroll(true);
        }

        getMessages();

        $timeout(function () {
          footerBar = document.body.querySelector('#userMessagesView .bar-footer');
          scroller = document.body.querySelector('#userMessagesView .scroll-content');
          txtInput = angular.element(footerBar.querySelector('textarea'));
          tabNavi = document.body.querySelector('.tab-nav');
{'fraction_non_alphanumeric': 0.13436370434999376, 'fraction_numerical': 0.007977065935435623, 'mean_word_length': 2.4571305471779405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4701106', 'n_tokens_mistral': 2511, 'n_tokens_neox': 2483, 'n_words': 488}