<commit_before>var bmiApp = angular.module('diabeteSavior', ['ngRoute', 'ngCookies']);
bmiApp.controller('bmiCalculatorsController', ['$scope','$cookies', '$cookieStore', bmiCalculatorsController]);


function bmiCalculatorsController($scope, $cookies, $cookieStore) {
  $scope.race = ""
  $scope.bmi = "";
  $scope.weightClassification = "";
  $scope.obesityClass = "";

  $scope.unitType = null;
  $scope.unitFormat = null;

  setPlaceholders = function() {
    $('#txtWeight').attr('placeholder', $scope.unitFormat.weightFormat);
    $('#txtHeight').attr('placeholder', $scope.unitFormat.heightFormat);
  }

  init = function() {
    // Retrieving a cookie
    if($cookies.unitType == '') {
      $cookies.unitType = 'imperial';
    }
    $scope.unitType = $cookies.unitType;
    $scope.unitFormat = unit[$scope.unitType];    
    setPlaceholders();
  }
  init();

  $scope.enterInput = function(ev) {
    tgt = ev.target;
    setTimeout(function() { 
      tgt.setSelectionRange(0, tgt.value.length);
    },10);    
  }

  $scope.heightKeyDown = function(ev) {
    // Only allow numbers, ., ', " in this field.
    // Keydown trigger before change, thus the value still old.
    value = ev.target.value;

    if($scope.unitType == 'imperial') {
      // . ' "
      if(value.indexOf('"') >  -1) {
        if(ev.keyCode == 8 || ev.keyCode == 46 || ev.keyCode == 9) {
          // Only allow to delete string.
          return true;
        }
        ev.preventDefault();
        return false;
      }
      if(value.indexOf("'") > -1 && (ev.keyCode == 222 && !ev.shiftKey)) {
        // Not allow "'" key
        ev.preventDefault();
        return false;
      }
      allowedKeys = [190, 222, 16];
    } else {
      allowedKeys = [190];
    }

    if(value.indexOf('.') >  -1 && ev.keyCode == 190) {
      // Not allow '.' key
      ev.preventDefault();
      return false;
    } 
    // arrow keys: 37 - 40, ctrl 17, cmd 91, backspace 8, del 46, c 67, v 86, x 88, tab 9
    actionKeys = [67, 86, 88, 82, 65];
    modKeys = [37, 38, 39, 40, 17, 91, 8, 46, 9];
    ctrlDown = ev.ctrlKey || ev.metaKey // Mac support
    allowedKeys = allowedKeys.concat(modKeys);
    //console.log('keycode: ' + ev.keyCode);
    
    if(ev.keyCode >= 48 && ev.keyCode <= 57) {
      // is a digit.
      return true;
    } else if($.inArray(ev.keyCode, allowedKeys) > -1){
      // is allowd keys: . ' "
      return true;
    } else if(ctrlDown && $.inArray(ev.keyCode, actionKeys) > -1) {
      return true;
    } else {
      ev.preventDefault();
      return false;
    }
  }

  $scope.unitTypeClass = function(type) {
    return type === $scope.unitType ? 'btn-primary' : '';
  }

  $scope.setUnitType = function(type) {
    if($scope.unitType === type) {
      return false;
    }
    $scope.unitType = type;
    $cookies.unitType = type;
    $scope.unitFormat = $scope.unit[type];    
    setPlaceholders();
    if(type == 'imperial') {
      newW = kgToLb($('#txtWeight').val());
      newH = mToFt($('#txtHeight').val());
    } else {
      newW = lbToKg($('#txtWeight').val());
      newH = ftToM($('#txtHeight').val());
    }
    $('#txtWeight').val(newW);
    $('#txtHeight').val(newH);
    return false;
  }
<commit_msg>fixed placeholders errors of unit-type<commit_after>var bmiApp = angular.module('diabeteSavior', ['ngRoute', 'ngCookies']);
bmiApp.controller('bmiCalculatorsController', ['$scope','$cookies', '$cookieStore', bmiCalculatorsController]);


function bmiCalculatorsController($scope, $cookies, $cookieStore) {
  $scope.race = ""
  $scope.bmi = "";
  $scope.weightClassification = "";
  $scope.obesityClass = "";

  $scope.unitType = null;
  $scope.unitFormat = null;

  setPlaceholders = function() {
    $('#txtWeight').attr('placeholder', $scope.unitFormat.weightFormat);
    $('#txtHeight').attr('placeholder', $scope.unitFormat.heightFormat);
  }

  init = function() {
    // Retrieving a cookie
    if($cookies.unitType == '') {
      $cookies.unitType = 'imperial';
    }
    $scope.unitType = $cookies.unitType;
    $scope.unitFormat = unit[$scope.unitType];    
    setPlaceholders();
  }
  init();

  $scope.enterInput = function(ev) {
    tgt = ev.target;
    setTimeout(function() { 
      tgt.setSelectionRange(0, tgt.value.length);
    },10);    
  }

  $scope.heightKeyDown = function(ev) {
    // Only allow numbers, ., ', " in this field.
    // Keydown trigger before change, thus the value still old.
    value = ev.target.value;

    if($scope.unitType == 'imperial') {
      // . ' "
      if(value.indexOf('"') >  -1) {
        if(ev.keyCode == 8 || ev.keyCode == 46 || ev.keyCode == 9) {
          // Only allow to delete string.
          return true;
        }
        ev.preventDefault();
        return false;
      }
      if(value.indexOf("'") > -1 && (ev.keyCode == 222 && !ev.shiftKey)) {
        // Not allow "'" key
        ev.preventDefault();
        return false;
      }
      allowedKeys = [190, 222, 16];
    } else {
      allowedKeys = [190];
    }

    if(value.indexOf('.') >  -1 && ev.keyCode == 190) {
      // Not allow '.' key
      ev.preventDefault();
      return false;
    } 
    // arrow keys: 37 - 40, ctrl 17, cmd 91, backspace 8, del 46, c 67, v 86, x 88, tab 9
    actionKeys = [67, 86, 88, 82, 65];
    modKeys = [37, 38, 39, 40, 17, 91, 8, 46, 9];
    ctrlDown = ev.ctrlKey || ev.metaKey // Mac support
    allowedKeys = allowedKeys.concat(modKeys);
    //console.log('keycode: ' + ev.keyCode);
    
    if(ev.keyCode >= 48 && ev.keyCode <= 57) {
      // is a digit.
      return true;
    } else if($.inArray(ev.keyCode, allowedKeys) > -1){
      // is allowd keys: . ' "
      return true;
    } else if(ctrlDown && $.inArray(ev.keyCode, actionKeys) > -1) {
      return true;
    } else {
      ev.preventDefault();
      return false;
    }
  }

  $scope.unitTypeClass = function(type) {
    return type === $scope.unitType ? 'btn-primary' : '';
  }

  $scope.setUnitType = function(type) {
    if($scope.unitType === type) {
      return false;
    }
    $scope.unitType = type;
    $cookies.unitType = type;
    $scope.unitFormat = unit[type];
    setPlaceholders();
    
    if(type == 'imperial') {
      newW = kgToLb($('#txtWeight').val());
      newH = mToFt($('#txtHeight').val());
    } else {
      newW = lbToKg($('#txtWeight').val());
      newH = ftToM($('#txtHeight').val());
    }
   
    //Update the value only if the textbox is not empty 
    if($('#txtWeight').val().length > 0)
      $('#txtWeight').val(newW);
    if($('#txtHeight').val().length > 0)
      $('#txtHeight').val(newH);
    
    return false;
  }

{'fraction_non_alphanumeric': 0.18040223801602903, 'fraction_numerical': 0.023589898684409496, 'mean_word_length': 2.4810526315789474, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6847691', 'n_tokens_mistral': 2371, 'n_tokens_neox': 2223, 'n_words': 466}