<commit_before><!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>SDF P2016 Validateur de places</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <style>
      html, body {
        background-color: #95a5a6;
        font-family: sans-serif;
        text-align: center;
      }

      h1 {
        font-weight: 100;
        font-size: 42px;
      }

      #place {
        font-size: 24px;
        padding: 10px;
      }

      #result {
        font-size: 28px;
        margin: 20px auto;
        text-align: left;
        width: 600px;
      }

      #okay {
        height: 40px;
        font-size: 36px;
        font-weight: bold;
        margin-top: 20px;
      }

      #username, #studentNumber {
        float: right;
      }
    </style>
  </head>
  <body>
    <h1>Validateur de places SDF 2016</h1>
    <h3>NE PAS OUBLIER DE REPRENDRE LA CARTE ÉVÈNEMENT</h3>
    <input type="text" id="place" autofocus>
    <div id="okay">En attente</div>
    <div id="result">
      Nom: <span id="username">?</span><br>
      Numéro utilisateur: <span id="studentNumber">?</span>
    </div>

    <script>
    var places = [
        { "last_name":"Doe", "first_name": "John", "student_id":null, "card_id":53 },
        { "last_name":"Bate", "first_name": "Ala", "student_id":35397, "card_id":null }
    ];
    </script>

    <script>
      var place = document.getElementById("place");
      var username = document.getElementById("username");
      var studentNumber = document.getElementById("studentNumber");
      var okay = document.getElementById("okay");

      place.focus();
      place.onkeypress = function (e) {
        if (e.keyCode === 13 || e.charCode === 13 || e.which === 13) {
          if (place.value.length <= 4) check(place.value);
          else {
            if (place.value.length >= 6) {
              place.value = place.value.substr(8, 5);
            }
            checkEtu(place.value);
          }
          place.select();
        }
      };

      function check (value) {
        var found = false;
        for (var i = places.length - 1; i >= 0; i--) {
          // Replace trailing zero on the left by nothing, since the
          // card id can start by one. ie: 053 and 53.
          if (places[i].card_id) {
            if (places[i].card_id.toString() === value.replace(/^0+/g, '')) {
              found = places[i];
            }
          }
        }

        if (found === false) {
          hasNotFound(value);
        } else {
          hasFound(found);
        }
      }

      function checkEtu (value)  {
        var found = false;
        for (var i = places.length - 1; i >= 0; i--) {
          // Replace trailing zero on the left by nothing, since the
          // card id can start by one. ie: 053 and 53.
          if (places[i].student_id) {
            if (places[i].student_id.toString() === value) {
              found = places[i];
            }
          }
        }

        if (found === false) {
          hasNotFound(value);
        } else {
          hasFound(found);
        }
      }

      function hasNotFound (value) {
        okay.style.color = "#c0392b";
        okay.innerHTML = value + " non trouvé !"
        username.innerHTML = "?";
        studentNumber.innerHTML = "?";
      }

      function hasFound (place) {
        okay.style.color = "green";
        okay.innerHTML = "Trouvé !"
        username.innerHTML = place.first_name + " " + place.last_name;
        studentNumber.innerHTML = place.student_id;
      }
    </script>
  </body>
</html><commit_msg>Bind last name, manage multiple identical names<commit_after><!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>SDF P2016 Validateur de places</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <style>
      html, body {
        background-color: #95a5a6;
        font-family: sans-serif;
        text-align: center;
      }

      h1 {
        font-weight: 100;
        font-size: 42px;
      }

      #place {
        font-size: 24px;
        padding: 10px;
      }

      #result {
        font-size: 28px;
        margin: 20px auto;
        text-align: left;
        width: 600px;
      }

      #okay {
        height: 40px;
        font-size: 36px;
        font-weight: bold;
        margin-top: 20px;
      }

      #username, #studentNumber {
        float: right;
      }
    </style>
  </head>
  <body>
    <h1>Validateur de places SDF 2016</h1>
    <h3>NE PAS OUBLIER DE REPRENDRE LA CARTE ÉVÈNEMENT</h3>
    <input type="text" id="place" autofocus>
    <div id="okay">En attente</div>
    <div id="result">
      <div id="multiple"><br /></div>
      Nom: <span id="username">?</span><br>
      Numéro utilisateur: <span id="studentNumber">?</span>
    </div>

    <script>
    var places = [
        { "last_name":"Doe", "first_name": "John", "student_id":null, "card_id":53 },
        { "last_name":"Bate", "first_name": "Ala", "student_id":35397, "card_id":null },
        { "last_name":"Bob", "first_name": "Bob", "student_id":35398, "card_id":null },
        { "last_name":"Bob", "first_name": "Bobette", "student_id":35399, "card_id":null }
    ];
    </script>

    <script>
      var place = document.getElementById("place");
      var username = document.getElementById("username");
      var studentNumber = document.getElementById("studentNumber");
      var okay = document.getElementById("okay");
      var multiple = document.getElementById("multiple");

      place.focus();
      place.onkeypress = function (e) {
        if (e.keyCode === 13 || e.charCode === 13 || e.which === 13) {
          if (isNaN(place.value)) {
            checkLastname(place.value);
          } else {
            if (place.value.length <= 4) check(place.value);
            else {
              if (place.value.length >= 6) {
                place.value = place.value.substr(8, 5);
              }
              checkEtu(place.value);
            }
          }
          place.select();
        }
      };

      function checkLastname (value) {
        var found = [];
        for (var i = places.length - 1; i >= 0; i--) {
          if (places[i].last_name) {
            if (places[i].last_name.toLowerCase() === value.toLowerCase()) {
              found.push(places[i]);
            }
          }
        }

        if (found.length == 0) {
          hasNotFound(value);
        } else {
          hasFoundName(found);
        }
      }

      function check (value) {
        var found = false;
        for (var i = places.length - 1; i >= 0; i--) {
          if (places[i].card_id) {
            // Replace trailing zero on the left by nothing, since the
            // card id can start by one. ie: 053 and 53.
            if (places[i].card_id.toString() === value.replace(/^0+/g, '')) {
              found = places[i];
            }
          }
        }

        if (found === false) {
          hasNotFound(value);
        } else {
          hasFound(found);
        }
      }

      function checkEtu (value)  {
        var found = false;
        for (var i = places.length - 1; i >= 0; i--) {
          if (places[i].student_id) {
            if (places[i].student_id.toString() === value) {
              found = places[i];
            }
          }
        }

        if (found === false) {
          hasNotFound(value);
        } else {
          hasFound(found);
        }
      }

      function hasNotFound (value) {
        okay.style.color = "#c0392b";
        okay.innerHTML = value + " non trouvé !";
        username.innerHTML = "?";
        studentNumber.innerHTML = "?";
      }

      function hasFound (place) {
        okay.style.color = "green";
        okay.innerHTML = "Trouvé !";
        multiple.innerHTML = "";
        username.innerHTML = place.first_name + " " + place.last_name;
        studentNumber.innerHTML = place.student_id;
      }

      function hasFoundName (found) {
        if (found.length == 1) {
          hasFound(found[0]);
        } else {
          okay.style.color = "green";
          okay.innerHTML = "Plusieurs utilisateurs trouvés !";
          multiple.innerHTML = "";
          username.innerHTML = "?";
          studentNumber.innerHTML = "?";
          for (var i = found.length - 1; i >= 0; i--) {
            multiple.innerHTML += found[i].first_name + " " + found[i].last_name + " ("+found[i].student_id +")<br />";
          }
          multiple.innerHTML += "<br />";
        }
      }
    </script>
  </body>
</html>
{'fraction_non_alphanumeric': 0.15079548074706017, 'fraction_numerical': 0.01936822688494351, 'mean_word_length': 1.7288455489147532, 'pattern_counts': {'":': 24, '<': 74, '<?xml version=': 0, '>': 80, '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': '1238810', 'n_tokens_mistral': 2865, 'n_tokens_neox': 2698, 'n_words': 591}