<commit_before>var calcApp = angular.module('NodeCalc', []);
calcApp.controller('CalcController', ['$scope', function ($scope) {
  var m = null;

  function sleep(time) {
    time = time*1000;
    return new Promise((resolve) => setTimeout(resolve, time));
  }
  function setScreen(v) {
    document.getElementById('res').value = v;
  }

  $scope.memory = {
    recall: function() {
      $scope.screen.add(m);
    },
    clear: function() {
      m = null;
      curr_v = document.getElementById('res').value;
      setScreen('Memory clear');
      sleep(1).then(() => {
        setScreen(curr_v);
      });
    },
    add: function() {
      m = document.getElementById('res').value;
      setScreen(m + ' saved');
      sleep(1).then(() => {
        setScreen(m);
      });
    }
  };

  $scope.calculate = function() {
    var places = 8;
    try { setScreen(parseFloat(eval(document.getElementById('res').value).toFixed(places))) } catch(e) { setScreen('Error'); }
  }
  
  $scope.screen = {
    add: function(v) {
      var operators = ['/', '*', '+', '-'];
      if (document.getElementById('res').value === '0' && operators.indexOf(v) < 0) {
        document.getElementById('res').value = v
      }
      else {
        document.getElementById('res').value += v
      }
    },
    clear: function() {
      document.getElementById('res').value = '0';
    }
  };

  $scope.buttons = {
    memory: [ 
      {text: 'mrc', action: $scope.memory.recall},
      {text: 'm-', action: $scope.memory.clear},
      {text: 'm+', action: $scope.memory.add},
    ],
    symbols: {
      divide: {text: '/', action: $scope.screen.add},
      multiply: {text: '*', action: $scope.screen.add},
      add: {text: '+', action: $scope.screen.add},
      subtract: {text: '-', action: $scope.screen.add},
      decimal: {text: '.', action: $scope.screen.add}
    },
    verbs: {
      clear: {text: 'C', action: $scope.screen.clear},
      calculate: {text: '=', action: $scope.calculate}
    },
    numbers: {
      row7to9: [
        {text: '7', action: $scope.screen.add},
        {text: '8', action: $scope.screen.add},
        {text: '9', action: $scope.screen.add},
      ],
      row4to6: [
        {text: '4', action: $scope.screen.add},
        {text: '5', action: $scope.screen.add},
        {text: '6', action: $scope.screen.add},
      ],
      row1to3: [
        {text: '1', action: $scope.screen.add},
        {text: '2', action: $scope.screen.add},
        {text: '3', action: $scope.screen.add},
      ],
      zero: {text: '0', action: $scope.screen.add},
    }
  };
}]);

/*
$(document).keypress(function(event) {
  if (event.key === 'Enter') {
    e();
  }
  else {
    a(String.fromCharCode(event.which));
  }
});
*/<commit_msg>added comments to old keypress jquery code for reference when issue is tackled<commit_after>var calcApp = angular.module('NodeCalc', []);
calcApp.controller('CalcController', ['$scope', function ($scope) {
  var m = null;

  function sleep(time) {
    time = time*1000;
    return new Promise((resolve) => setTimeout(resolve, time));
  }
  function setScreen(v) {
    document.getElementById('res').value = v;
  }

  $scope.memory = {
    recall: function() {
      $scope.screen.add(m);
    },
    clear: function() {
      m = null;
      curr_v = document.getElementById('res').value;
      setScreen('Memory clear');
      sleep(1).then(() => {
        setScreen(curr_v);
      });
    },
    add: function() {
      m = document.getElementById('res').value;
      setScreen(m + ' saved');
      sleep(1).then(() => {
        setScreen(m);
      });
    }
  };

  $scope.calculate = function() {
    var places = 8;
    try { setScreen(parseFloat(eval(document.getElementById('res').value).toFixed(places))) } catch(e) { setScreen('Error'); }
  }
  
  $scope.screen = {
    add: function(v) {
      var operators = ['/', '*', '+', '-'];
      if (document.getElementById('res').value === '0' && operators.indexOf(v) < 0) {
        document.getElementById('res').value = v
      }
      else {
        document.getElementById('res').value += v
      }
    },
    clear: function() {
      document.getElementById('res').value = '0';
    }
  };

  $scope.buttons = {
    memory: [ 
      {text: 'mrc', action: $scope.memory.recall},
      {text: 'm-', action: $scope.memory.clear},
      {text: 'm+', action: $scope.memory.add},
    ],
    symbols: {
      divide: {text: '/', action: $scope.screen.add},
      multiply: {text: '*', action: $scope.screen.add},
      add: {text: '+', action: $scope.screen.add},
      subtract: {text: '-', action: $scope.screen.add},
      decimal: {text: '.', action: $scope.screen.add}
    },
    verbs: {
      clear: {text: 'C', action: $scope.screen.clear},
      calculate: {text: '=', action: $scope.calculate}
    },
    numbers: {
      row7to9: [
        {text: '7', action: $scope.screen.add},
        {text: '8', action: $scope.screen.add},
        {text: '9', action: $scope.screen.add},
      ],
      row4to6: [
        {text: '4', action: $scope.screen.add},
        {text: '5', action: $scope.screen.add},
        {text: '6', action: $scope.screen.add},
      ],
      row1to3: [
        {text: '1', action: $scope.screen.add},
        {text: '2', action: $scope.screen.add},
        {text: '3', action: $scope.screen.add},
      ],
      zero: {text: '0', action: $scope.screen.add},
    }
  };
}]);

/*
$(document).keypress(function(event) {
  if (event.key === 'Enter') {
    // if key pressed is Enter, eval
    e();
  }
  else {
    // record the keypress (TODO: make sure only numbers are recorded)
    a(String.fromCharCode(event.which));
  }
});
*/
{'fraction_non_alphanumeric': 0.20407440212577502, 'fraction_numerical': 0.00921169176262179, 'mean_word_length': 2.49165120593692, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6135447', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1900, 'n_words': 368}