<commit_before>'use strict';
function register() {
  $('#registerBtn').addClass('hide');
  $('#registerLoadingCircle').removeClass('hide');
  var username = $('#username').val();
  var email = $('#eml').val();
  var password1 = $('#pass1').val();
  var password2 = $('#pass2').val();
  if (username &&  email && password1 && password2) {
    var re = /^(\w{3,63})$/;
    if (re.test(username)) {
      $("#badUsername").addClass("hide");
      var url = getServer()+'/register/checkusername';
      var unameObj = {
        "username": username
      };
      $.ajax({
        type: "POST",
        url: url,
        data: unameObj,
        success: function(data1) {
          if (data1.status === 200 && data1.validity) {
            re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            if (re.test(email)) {
              url = getServer()+'/register/checkemail';
              var emlObj = {
                "email": email
              };
              $.ajax({
                type: "POST",
                url: url,
                data: emlObj,
                success: function(data2) {
                  if(data2.status === 200) {
                    if (data2.validity) {
                      $("#badEmail").addClass("hide");
                      if (checkPass(password1,password2)) {
                        insertUser(username,email,password1);
                      }
                      else {
                        stopLoading();
                      }
                    }
                    else {
                      $("#badEmail").removeClass("hide");
                      stopLoading();
                    }
                  }
                  else {
                    $("#badEmail").removeClass("hide");
                    stopLoading();
                  }
                }
              });
            }
            else {
              $("#badEmail").removeClass("hide");
              Materialize.toast('Please enter a valid email address!', 5000, 'warning-toast');
              stopLoading();
            }
          }
          else {
            $("#badUsername").removeClass("hide");
            Materialize.toast('Username Already In Use!', 5000, 'warning-toast');
            stopLoading();
          }
        }
      });
    }
    else {
      $("#badUsername").removeClass("hide");
      Materialize.toast('Invalid Username!', 5000, 'warning-toast');
      stopLoading();
    }
  }
  else {
    stopLoading();
    Materialize.toast('Please fill in ALL fields!', 5000, 'warning-toast');
  }
};

function stopLoading() {
  $('#registerLoadingCircle').addClass('hide');
  $('#registerBtn').removeClass('hide');
}

function insertUser(username,email,password) {
  var url = getServer()+'/register/submit';
  var data = {
    "username": username,
    "email": email,
    "password": password
  };
  $.ajax({
    type: "POST",
    url: url,
    data: data,
    success: function(data) {
      if (data.status === 201) {
        var homeUrl = getServer()+'/'
        window.location.replace(homeUrl);
      }
      else {
        $('#registerLoadingCircle').addClass('hide');
        $('#registerBtn').removeClass('hide');
      }
    }
  });
}

function loadModal() {
  console.log('opening modal');
  $('#terms-modal').openModal();
}

function rejectTerms() {
  $('#terms-modal').closeModal();
}

function acceptTerms() {
  $('#terms-modal').closeModal();
  register();
}

function checkPass(pass1, pass2) {<commit_msg>forgot to remove logging<commit_after>'use strict';
function register() {
  $('#registerBtn').addClass('hide');
  $('#registerLoadingCircle').removeClass('hide');
  var username = $('#username').val();
  var email = $('#eml').val();
  var password1 = $('#pass1').val();
  var password2 = $('#pass2').val();
  if (username &&  email && password1 && password2) {
    var re = /^(\w{3,63})$/;
    if (re.test(username)) {
      $("#badUsername").addClass("hide");
      var url = getServer()+'/register/checkusername';
      var unameObj = {
        "username": username
      };
      $.ajax({
        type: "POST",
        url: url,
        data: unameObj,
        success: function(data1) {
          if (data1.status === 200 && data1.validity) {
            re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            if (re.test(email)) {
              url = getServer()+'/register/checkemail';
              var emlObj = {
                "email": email
              };
              $.ajax({
                type: "POST",
                url: url,
                data: emlObj,
                success: function(data2) {
                  if(data2.status === 200) {
                    if (data2.validity) {
                      $("#badEmail").addClass("hide");
                      if (checkPass(password1,<PASSWORD>)) {
                        insertUser(username,email,password1);
                      }
                      else {
                        stopLoading();
                      }
                    }
                    else {
                      $("#badEmail").removeClass("hide");
                      stopLoading();
                    }
                  }
                  else {
                    $("#badEmail").removeClass("hide");
                    stopLoading();
                  }
                }
              });
            }
            else {
              $("#badEmail").removeClass("hide");
              Materialize.toast('Please enter a valid email address!', 5000, 'warning-toast');
              stopLoading();
            }
          }
          else {
            $("#badUsername").removeClass("hide");
            Materialize.toast('Username Already In Use!', 5000, 'warning-toast');
            stopLoading();
          }
        }
      });
    }
    else {
      $("#badUsername").removeClass("hide");
      Materialize.toast('Invalid Username!', 5000, 'warning-toast');
      stopLoading();
    }
  }
  else {
    stopLoading();
    Materialize.toast('Please fill in ALL fields!', 5000, 'warning-toast');
  }
};

function stopLoading() {
  $('#registerLoadingCircle').addClass('hide');
  $('#registerBtn').removeClass('hide');
}

function insertUser(username,email,password) {
  var url = getServer()+'/register/submit';
  var data = {
    "username": username,
    "email": email,
    "password": password
  };
  $.ajax({
    type: "POST",
    url: url,
    data: data,
    success: function(data) {
      if (data.status === 201) {
        var homeUrl = getServer()+'/'
        window.location.replace(homeUrl);
      }
      else {
        $('#registerLoadingCircle').addClass('hide');
        $('#registerBtn').removeClass('hide');
      }
    }
  });
}

function loadModal() {
  $('#terms-modal').openModal();
}

function rejectTerms() {
  $('#terms-modal').closeModal();
}

function acceptTerms() {
  $('#terms-modal').closeModal();
  register();
}

function checkPass(pass1, pass2) {
{'fraction_non_alphanumeric': 0.19418832075998882, 'fraction_numerical': 0.017742386141380274, 'mean_word_length': 1.6564007421150277, 'pattern_counts': {'":': 10, '<': 8, '<?xml version=': 0, '>': 8, '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': '2338054', 'n_tokens_mistral': 2131, 'n_tokens_neox': 2055, 'n_words': 343}