<commit_before><html>
<head>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function() {

  var daysInMonth = function(month) {
    if (month == 2) return 29;
    if (month == 4 || month == 6 || month == 9 || month == 11) return 30;
    return 31;
  }

  var validChar = function(text, position, code) {
    code = (96 <= code && code <= 105)? code - 48 : code; // Fix numpad
    var character = String.fromCharCode(code);
    console.log("checking " + code + ", -" + character);
    switch (position) {
      case 0:
        return character.match(/[0-9]/) != null
      case 1:
        if (text[0] == 0) {
          return character.match(/[1-9]/) != null
        } else {
          return character.match(/[0-2]/) != null // Don't allow higher than 12
        }
      case 5:
        return character.match(/[0-9]/) != null;
      case 6:
        if (text[5] == 0) {
          return character.match(/[1-9]/) != null;
        }
        var ct = parseInt(text[5]) * 10;
        if (ct + parseInt(character) > daysInMonth(parseInt(text.substring(0,2)))) {
          return false;
        }
      case 10:
        return character.match(/[0-9]/) != null
      case 11:
        return character.match(/[0-9]/) != null
    }
    return false;
  }

  var backspace = function(input) {
    var cursorPos = input.prop("selectionStart");

    // Handle backspace over slash between MM and DD
    if ((cursorPos == 3) || (cursorPos == 4)) {
      input.val(input.val().substring(0, 1));
    } 

    // Handle backspace over slash between DD and YY
    if ((cursorPos == 9) || (cursorPos == 8)) {
      input.val(input.val().substring(0, 6));
    }

    // Handle backspace of '0N' DD
    if ((input.val().match("^0")) && (cursorPos == 2)) {
      input.val("");
    }
  }
  
  $("#date").bind('input', function() {
    self = $(this);
    text = self.val();
    if (text.length == 1) {
      if (!text.match("^0") && !text.match("^1")) {
        self.val("0" + text);
      } 
    } else if (text.length == 6) {
      var maxFirstChar = daysInMonth(parseInt(text.substring(0, 2))).toString()[0];
      char = text[5];
      if (parseInt(char) > parseInt(maxFirstChar)) {
        self.val(text.substring(0, 5) + "0" + char);
      }
    }
  });

  $("#date").bind('keydown', function(e) {
    self = $(this);

    // Prevent unwanted inputs
    var code = e.keyCode;
    if (code == 8) return true; // Backspace
    if (code >= 35 && code <= 40) return true; // Arrow keys, home, end
    //if (code >= 48 && code <= 57) return true; // Numbers
    //if (code >= 96 && code <= 105) return true; // Numpad numbers

    // Check valid code at position
    var position = self.prop("selectionStart");
    return validChar(self.val(), position, code);
  });

  $("#date").bind('keyup', function(e) {
    self = $(this);
    if (e.keyCode == 8) {   // Backspace
      backspace(self);
    }

    var cursorPos = self.prop("selectionStart");
    if (cursorPos == 2 || cursorPos == 7) {<commit_msg>Handle slash<commit_after><html>
<head>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function() {

  var daysInMonth = function(month) {
    if (month == 2) return 29;
    if (month == 4 || month == 6 || month == 9 || month == 11) return 30;
    return 31;
  }

  var validChar = function(text, position, code) {
    code = (96 <= code && code <= 105)? code - 48 : code; // Fix numpad
    var character = String.fromCharCode(code);
    console.log("checking " + code + ", -" + character);

    switch (position) {
      case 0:
        return character.match(/[0-9]/) != null
      case 1:
        if (text[0] == 0) {
          return character.match(/[1-9]/) != null
        } else {
          return character.match(/[0-2]/) != null // Don't allow higher than 12
        }
      case 5:
        return character.match(/[0-9]/) != null;
      case 6:
        if (text[5] == 0) {
          return character.match(/[1-9]/) != null;
        }
        var ct = parseInt(text[5]) * 10;
        if (ct + parseInt(character) > daysInMonth(parseInt(text.substring(0,2)))) {
          return false;
        }
      case 10:
        return character.match(/[0-9]/) != null
      case 11:
        return character.match(/[0-9]/) != null
    }
    return false;
  }

  var backspace = function(input) {
    var cursorPos = input.prop("selectionStart");

    // Handle backspace over slash between MM and DD
    if ((cursorPos == 3) || (cursorPos == 4)) {
      input.val(input.val().substring(0, 1));
    } 

    // Handle backspace over slash between DD and YY
    if ((cursorPos == 9) || (cursorPos == 8)) {
      input.val(input.val().substring(0, 6));
    }
  }

  var slash = function(input) {
    var position = input.prop("selectionStart");
    if (position == 1 && input.val()[0] != "0") {
      input.val("0" + input.val());
    } else if (position == 6 && input.val()[5] != "0") {
      var character = input.val()[5];
      input.val(input.val().substring(0, 5) + "0" + character);
    }
    return false;
  }
  
  $("#date").bind('input', function() {
    self = $(this);
    text = self.val();
    if (text.length == 1) {
      if (!text.match("^0") && !text.match("^1")) {
        self.val("0" + text);
      } 
    } else if (text.length == 6) {
      var maxFirstChar = daysInMonth(parseInt(text.substring(0, 2))).toString()[0];
      char = text[5];
      if (parseInt(char) > parseInt(maxFirstChar)) {
        self.val(text.substring(0, 5) + "0" + char);
      }
    }
  });

  $("#date").bind('keydown', function(e) {
    self = $(this);

    // Prevent unwanted inputs
    var code = e.keyCode;
    if (code == 8) return true; // Backspace
    if (code >= 35 && code <= 40) return true; // Arrow keys, home, end

    if (code == 111 || code == 191) {
      return slash(self);
    }

    // Check valid code at position
    var position = self.prop("selectionStart");
    return validChar(self.val(), position, code);
  });

  $("#date").bind('keyup', function(e) {
    self = $(this);
    if (e.keyCode == 8) {   // Backspace
      backspace(self);
    }

    var cursorPos = self.prop("selectionStart");
    if (cursorPos == 2 || cursorPos == 7) {
{'fraction_non_alphanumeric': 0.18787591009813231, 'fraction_numerical': 0.029914529914529916, 'mean_word_length': 2.3083769633507853, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '4494995', 'n_tokens_mistral': 2212, 'n_tokens_neox': 2052, 'n_words': 529}