<commit_before><!DOCTYPE html>
{% load staticfiles %}
<html lang="en">
  <head>
  {{header}}
  <script type="text/javascript" src="{% static "js/check_username.js"%}"></script>
  <script type="text/javascript" src="{% static "js/get_csrf_token.js"%}"></script>
  </head>

  <body>
  {{navbar}}
  	<div class="container-fluid">
  		<div class="row-fluid">
       <div class="span2">
        <p> <i class="glyphicon glyphicon-ok"></i> Learn to code </p>
        <p> <i class="glyphicon glyphicon-ok"></i> Teach coding </p>
      </div>
      <div class="span9">
       <div class="" id="loginModal">
        <div class="modal-body" style="max-height:800px;">
          <div class="well">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#login" data-toggle="tab">Login</a></li>
              <li><a href="#createstudentaccount" data-toggle="tab">Register</a></li>
            </ul>
            <div id="myTabContent" class="tab-content">
              <div class="tab-pane active in" id="login">
                <form class="form-horizontal" action='/authenticate_{{type}}/' method="POST">
                  {% csrf_token %}
                  {{ login_form.non_field_errors }}
                  <fieldset>
                    {% if error_text %}
                      <div class="control-group" id="login_err">
                        <label class="control-label" for="username">{{error_text}}</label>
                      </div>
                    {% endif%}
                    <div class="control-group">
                      <!-- Username -->
                      {{ login_form.username.errors }}
                      <label class="control-label" for="username">Username</label>
                      <div class="controls">
                        {{ login_form.username }}
                      </div>
                    </div>
                    <div class="control-group">
                      <!-- Password-->
                      {{ login_form.password.errors }}
                      <label class="control-label" for="password">Password</label>
                      <div class="controls">
                        {{ login_form.password}}
                      </div>
                    </div>
                    <div class="control-group">
                      <!-- Button -->
                      <div class="controls">
                        <button class="btn btn-success" value="Submit">Login</button>
                      </div>
                    </div>
                  </fieldset>
                </form>
              </div>
              <div id="createstudentaccount" class="tab-pane fade">
                <form class="form-horizontal" action='/register-{{type}}/' method="POST"> 
                  {% csrf_token %}
                  {{ register_form.non_field_errors }}
                  <fieldset>
                    <div class="control-group">
                      {{ register_form.reg_username.errors }}
                      <label class="control-label" for="username">Username</label>
                      <div class="controls">
                        {{ register_form.reg_username }}
                      </div>
                      <label id="user_ok">
                        <i class="glyphicon glyphicon-ok ok"></i> Username is available!
                      </label>
                      <label id="user_taken">
                        <i class="glyphicon glyphicon-remove wrong"></i> Username is taken.
                      </label>                    
                    </div>
                    <div class="control-group">
                      {{ register_form.first_name.errors}}
                      <label class="control-label" for="firstname">First Name</label>
                      <div class="controls">
                        {{ register_form.first_name }}
                      </div>
                    </div>
                    <div class="control-group">
                      {{register_form.last_name.errors}}
                      <label class="control-label" for="lastname">Last Name</label>
                      <div class="controls">
                        {{register_form.last_name}}
                      </div>
                    </div>
                    <div class="control-group">
                      {{register_form.email.errors}}
                      <label class="control-label" for="email">E-mail</label>
                      <div class="controls">
                        {{register_form.email}}
                        <div id="emailText"></div>
                      </div>
                    </div>
                    <div class="control-group">
                      {{register_form.school.errors}}
                      <label class="control-label" for="school">School</label>
                      <div class="controls">
                        {{register_form.school}}
                      </div>
                    </div>
                    {% if type|stringformat:"s" == "student"%}
                      <div class="control-group">
                        {{ register_form.year.errors}}
                        <label class="control-label" for="year">Year</label>
                        <div class="controls">
                          {{register_form.year}}
                        </div>
                      </div>
                      <div class="control-group">
                        {{register_form.Class.errors}}
                        <label class="control-label" for="class">Class</label>
                        <div class="controls">
                          {{register_form.Class}}
                        </div>
                      </div>
                    {% endif %}
                    <div class="control-group">
                      {{register_form.reg_password.errors}}
                      <label class="control-label" for="password">Password</label>
                      <div class="controls">
                        {{register_form.reg_password}}
                        <div id="divCheckPasswordValid"></div>
                      </div>
                    </div>
                    <div class="control-group">
                      {{register_form.repeat_password.errors}}
                      <label class="control-label" for="passwordconf">Re-enter your password</label>
                      <div class="controls">
                        {{register_form.repeat_password}}
                        <div id="divCheckPasswordMatch"></div>
                      </div>
                    </div>
                    <div class="control-group">
                      <!-- Button -->
                      <div class="controls">
                        <table><tr><td>
                        <button class="btn btn-success" id="submit" value="Submit" >Submit</button></td>
                        <td><div id="divCheckFilledIn" style="padding-left:5px"></div></td></tr></table>
                      </div>
                    </fieldset>
                  </form>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>

  var first = $('#id_first_name');
  var last = $('#id_last_name');
  var user = $('#id_reg_username');
  var email = $("#id_email");
  var school = $('#id_school');
  var year = $('#id_year');
  var group = $('#id_Class');
  var pwId = $("#id_reg_password");
  var pwConf = $("#id_repeat_password");

  var filledInBoolean = false, emailBoolean = false, pwBoolean = false, confBoolean = false; 

  var all = [first, last, user, email, school, pwId, pwConf];
  {% if type|stringformat:"s" == "student"%}
    all.push(year);
    all.push(school);
  {% endif %}

  var submit = $('#submit');

  //For filled in forms check
  for (var i = 0; i < all.length; i++) {
    all[i].keyup(checkFilledForms);
  }

  $('#user_ok').hide();
  $('#user_taken').hide();

  user.keyup(checkUserNotTaken);
  email.keyup(checkEmailValid);
  pwId.keyup(checkPasswordValid);
  pwConf.keyup(checkPasswordValid);

  function checkFilledForms() {
    var forms = $('#divCheckFilledIn');
    for (var i = 0; i < all.length; i++) {
      if (all[i].val() == "") {
        forms.text("All fields must be filled in to complete registration.");
        filledInBoolean = false;
        setSubmitButton();
        return;
      }
    }
    forms.text("");
    filledInBoolean = true;
    setSubmitButton();
  }

  function checkUserNotTaken() {

    if (user.val().length < 2) 
    {
      $('#user_ok').hide();
      $('#user_taken').hide();
    } else 
    {
      if (check_username_exists())
      {
        $('#user_ok').hide();
        $('#user_taken').fadeIn();
      } else
      {
        $('#user_taken').hide();
        $('#user_ok').fadeIn();
      }
    }
  }

  function checkEmailValid() {
    var emailVal = email.val();
    var text = $("#emailText");
    if (!validateEmail(emailVal)) {
      text.text("Please enter a valid e-mail address.");
      emailBoolean = false;
      setSubmitButton();
    } else {
      text.text("");
      emailBoolean = true;
      setSubmitButton();
    }
  }
  
  function checkPasswordValid() {
    var pw = pwId.val();
    var conf = pwConf.val();
    var checkValidText = $("#divCheckPasswordValid");
    var checkMatchText = $("#divCheckPasswordMatch");

    if (pw.length < 8 && conf.length == 0) {
      checkValidText.text("The password must be at least 8 characters long.");
      pwBoolean = false;
      setSubmitButton();
    }
    else if (pw.length < 8 && conf.length < 8) {
      checkValidText.text("The password must be at least 8 characters long.");
      checkMatchText.text("Passwords don't match :(");
      pwBoolean = false;
      setSubmitButton();
    } else if (pw.length < 8 && conf.length >= 8) {
      checkValidText.text("The password must be at least 8 characters long.");
      pwBoolean = false;
      setSubmitButton();
    } else if (pw != conf) {
      checkValidText.text("");
      checkMatchText.text("Passwords don't match :(");
      pwBoolean = false;
      setSubmitButton();
    } else if (pw == conf && pw.length >= 8) {
      checkValidText.text("");
      checkMatchText.text("");
      pwBoolean = true;
      setSubmitButton();
    } 
  }

  function validateEmail($email) 
  {
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    if( !emailReg.test( $email ) ) {
      return false;
    } else {
      return true;
    }
  }

  function setSubmitButton() {
    submit.attr('disabled', !(
      filledInBoolean
      && emailBoolean
      && pwBoolean));
  }
</script>
</body>
</html><commit_msg>fixed login check to unfocus, instead of using keyup<commit_after><!DOCTYPE html>
{% load staticfiles %}
<html lang="en">
  <head>
  {{header}}
  <script type="text/javascript" src="{% static "js/check_username.js"%}"></script>
  <script type="text/javascript" src="{% static "js/get_csrf_token.js"%}"></script>
  </head>

  <body>
  {{navbar}}
  	<div class="container-fluid">
  		<div class="row-fluid">
       <div class="span2">
        <p> <i class="glyphicon glyphicon-ok"></i> Learn to code </p>
        <p> <i class="glyphicon glyphicon-ok"></i> Teach coding </p>
      </div>
      <div class="span9">
       <div class="" id="loginModal">
        <div class="modal-body" style="max-height:800px;">
          <div class="well">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#login" data-toggle="tab">Login</a></li>
              <li><a href="#createstudentaccount" data-toggle="tab">Register</a></li>
            </ul>
            <div id="myTabContent" class="tab-content">
              <div class="tab-pane active in" id="login">
                <form class="form-horizontal" action='/authenticate_{{type}}/' method="POST">
                  {% csrf_token %}
                  {{ login_form.non_field_errors }}
                  <fieldset>
                    {% if error_text %}
                      <div class="control-group" id="login_err">
                        <label class="control-label" for="username">{{error_text}}</label>
                      </div>
                    {% endif%}
                    <div class="control-group">
                      <!-- Username -->
                      {{ login_form.username.errors }}
                      <label class="control-label" for="username">Username</label>
                      <div class="controls">
                        {{ login_form.username }}
                      </div>
                    </div>
                    <div class="control-group">
                      <!-- Password-->
                      {{ login_form.password.errors }}
                      <label class="control-label" for="password">Password</label>
                      <div class="controls">
                        {{ login_form.password}}
                      </div>
                    </div>
                    <div class="control-group">
                      <!-- Button -->
                      <div class="controls">
                        <button class="btn btn-success" value="Submit">Login</button>
                      </div>
                    </div>
                  </fieldset>
                </form>
              </div>
              <div id="createstudentaccount" class="tab-pane fade">
                <form class="form-horizontal" action='/register-{{type}}/' method="POST"> 
                  {% csrf_token %}
                  {{ register_form.non_field_errors }}
                  <fieldset>
                    <div class="control-group">
                      {{ register_form.reg_username.errors }}
                      <label class="control-label" for="username">Username</label>
                      <div class="controls">
                        {{ register_form.reg_username }}
                      </div>
                      <label id="user_ok">
                        <i class="glyphicon glyphicon-ok ok"></i> Username is available!
                      </label>
                      <label id="user_taken">
                        <i class="glyphicon glyphicon-remove wrong"></i> Username is taken.
                      </label>                    
                    </div>
                    <div class="control-group">
                      {{ register_form.first_name.errors}}
                      <label class="control-label" for="firstname">First Name</label>
                      <div class="controls">
                        {{ register_form.first_name }}
                      </div>
                    </div>
                    <div class="control-group">
                      {{register_form.last_name.errors}}
                      <label class="control-label" for="lastname">Last Name</label>
                      <div class="controls">
                        {{register_form.last_name}}
                      </div>
                    </div>
                    <div class="control-group">
                      {{register_form.email.errors}}
                      <label class="control-label" for="email">E-mail</label>
                      <div class="controls">
                        {{register_form.email}}
                        <div id="emailText"></div>
                      </div>
                    </div>
                    <div class="control-group">
                      {{register_form.school.errors}}
                      <label class="control-label" for="school">School</label>
                      <div class="controls">
                        {{register_form.school}}
                      </div>
                    </div>
                    {% if type|stringformat:"s" == "student"%}
                      <div class="control-group">
                        {{ register_form.year.errors}}
                        <label class="control-label" for="year">Year</label>
                        <div class="controls">
                          {{register_form.year}}
                        </div>
                      </div>
                      <div class="control-group">
                        {{register_form.Class.errors}}
                        <label class="control-label" for="class">Class</label>
                        <div class="controls">
                          {{register_form.Class}}
                        </div>
                      </div>
                    {% endif %}
                    <div class="control-group">
                      {{register_form.reg_password.errors}}
                      <label class="control-label" for="password">Password</label>
                      <div class="controls">
                        {{register_form.reg_password}}
                        <div id="divCheckPasswordValid"></div>
                      </div>
                    </div>
                    <div class="control-group">
                      {{register_form.repeat_password.errors}}
                      <label class="control-label" for="passwordconf">Re-enter your password</label>
                      <div class="controls">
                        {{register_form.repeat_password}}
                        <div id="divCheckPasswordMatch"></div>
                      </div>
                    </div>
                    <div class="control-group">
                      <!-- Button -->
                      <div class="controls">
                        <table><tr><td>
                        <button class="btn btn-success" id="submit" value="Submit" >Submit</button></td>
                        <td><div id="divCheckFilledIn" style="padding-left:5px"></div></td></tr></table>
                      </div>
                    </fieldset>
                  </form>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>

  var first = $('#id_first_name');
  var last = $('#id_last_name');
  var user = $('#id_reg_username');
  var email = $("#id_email");
  var school = $('#id_school');
  var year = $('#id_year');
  var group = $('#id_Class');
  var pwId = $("#id_reg_password");
  var pwConf = $("#id_repeat_password");

  var filledInBoolean = false, emailBoolean = false, pwBoolean = false, confBoolean = false; 

  var all = [first, last, user, email, school, pwId, pwConf];
  {% if type|stringformat:"s" == "student"%}
    all.push(year);
    all.push(school);
  {% endif %}

  var submit = $('#submit');

  //For filled in forms check
  for (var i = 0; i < all.length; i++) {
    all[i].blur(checkFilledForms);
  }

  $('#user_ok').hide();
  $('#user_taken').hide();

  user.blur(checkUserNotTaken);
  email.blur(checkEmailValid);
  pwId.blur(checkPasswordValid);
  pwConf.blur(checkPasswordValid);

  function checkFilledForms() {
    var forms = $('#divCheckFilledIn');
    for (var i = 0; i < all.length; i++) {
      if (all[i].val() == "") {
        forms.text("All fields must be filled in to complete registration.");
        filledInBoolean = false;
        setSubmitButton();
        return;
      }
    }
    forms.text("");
    filledInBoolean = true;
    setSubmitButton();
  }

  function checkUserNotTaken() {

    if (user.val().length < 2) 
    {
      $('#user_ok').hide();
      $('#user_taken').hide();
    } else 
    {
      if (check_username_exists())
      {
        $('#user_ok').hide();
        $('#user_taken').fadeIn();
      } else
      {
        $('#user_taken').hide();
        $('#user_ok').fadeIn();
      }
    }
  }

  function checkEmailValid() {
    var emailVal = email.val();
    var text = $("#emailText");
    if (!validateEmail(emailVal)) {
      text.text("Please enter a valid e-mail address.");
      emailBoolean = false;
      setSubmitButton();
    } else {
      text.text("");
      emailBoolean = true;
      setSubmitButton();
    }
  }
  
  function checkPasswordValid() {
    var pw = pwId.val();
    var conf = pwConf.val();
    var checkValidText = $("#divCheckPasswordValid");
    var checkMatchText = $("#divCheckPasswordMatch");

    if (pw.length < 8 && conf.length == 0) {
      checkValidText.text("The password must be at least 8 characters long.");
      pwBoolean = false;
      setSubmitButton();
    }
    else if (pw.length < 8 && conf.length < 8) {
      checkValidText.text("The password must be at least 8 characters long.");
      checkMatchText.text("Passwords don't match :(");
      pwBoolean = false;
      setSubmitButton();
    } else if (pw.length < 8 && conf.length >= 8) {
      checkValidText.text("The password must be at least 8 characters long.");
      pwBoolean = false;
      setSubmitButton();
    } else if (pw != conf) {
      checkValidText.text("");
      checkMatchText.text("Passwords don't match :(");
      pwBoolean = false;
      setSubmitButton();
    } else if (pw == conf && pw.length >= 8) {
      checkValidText.text("");
      checkMatchText.text("");
      pwBoolean = true;
      setSubmitButton();
    } 
  }

  function validateEmail($email) 
  {
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    if( !emailReg.test( $email ) ) {
      return false;
    } else {
      return true;
    }
  }

  function setSubmitButton() {
    submit.attr('disabled', !(
      filledInBoolean
      && emailBoolean
      && pwBoolean));
  }
</script>
</body>
</html>
{'fraction_non_alphanumeric': 0.15047681376215408, 'fraction_numerical': 0.001963350785340314, 'mean_word_length': 1.448552134599977, 'pattern_counts': {'":': 0, '<': 355, '<?xml version=': 0, '>': 345, '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': '2110411', 'n_tokens_mistral': 5891, 'n_tokens_neox': 5499, 'n_words': 1119}