<commit_before>$(document).ready(function() {
	//open login form into hidden div
	$('#login-button').click(function() {
		$('#login-wrapper').load("view/forms/login.html", function() {
			//check which submit button was clicked
			var registerClicked = false;
			var loginClicked = false;
			$('input[value=Login]').click(function(){
				loginClicked=true;
			});
			$('input[value=Register]').click(function(){
				registerClicked=true;
			});
			
			$('input').first().focus(); //focus first input
			
			$(this).submit(function() {
				//get all inputs besides submit
				var input = $('input').not('input[type=Submit]');
				//check input is valid(isn't empty)
				var check;
				$(input).each(function(){
					if(!$(this).val()) {
						$(this).addClass("error");
						check = false
					} else {
						$(this).removeClass("error");
						check = true;
					}
					console.log(check);
				});
				if(!check) {
					//input isn't valid so break out of function
					return false;
				} else if(loginClicked) {
					//input is valid so send it to model
					var item = $.post('pubmod/json/login.php', $('#login-form').serialize());
					item.done(function(data){
						//response. Notify user if error or welcome them if logged in successfully
						if(data=="User doesn\'t exist!") {
							$('#notifications').html(data); //this should never happen but just in case
						} else if(data=="Incorrect username or password!") {
							$('#notifications').html(data);
						} else {
							$('#login-wrapper').html('Welcome '+data+'!');
						}
					});
					item.error(function(){
						//errors go to hidden notifications div
						$('#notifications').html('Error: Something broke');
					});
					return false; //don't reload page on submit
				} else if(registerClicked) {
					//input is valid so send it to model<commit_msg>hotfix: Bug with login/register firing multiple times when only clicked once<commit_after>$(document).ready(function() {
	//open login form into hidden div
	$('#login-button').click(function() {
		$('#login-wrapper').load("view/forms/login.html", function() {
			//check which submit button was clicked
			var registerClicked = false;
			var loginClicked = false;
			$('input[value=Login]').click(function(){
				loginClicked=true;
			});
			$('input[value=Register]').click(function(){
				registerClicked=true;
			});
			
			$('input').first().focus(); //focus first input
			
			$(this).submit(function() {
				//get all inputs besides submit
				var input = $('input').not('input[type=Submit]');
				//check input is valid(isn't empty)
				var check;
				$(input).each(function(){
					if(!$(this).val()) {
						$(this).addClass("error");
						check = false
					} else {
						$(this).removeClass("error");
						check = true;
					}
					console.log(check);
				});
				if(!check) {
					//input isn't valid so break out of function
					return false;
				} else if(loginClicked) {
					//input is valid so send it to model
					loginClicked=false; //so doesn't fire again unless clicked again
					var item = $.post('pubmod/json/login.php', $('#login-form').serialize());
					item.done(function(data){
						//response. Notify user if error or welcome them if logged in successfully
						if(data=="User doesn\'t exist!") {
							$('#notifications').html(data); //this should never happen but just in case
						} else if(data=="Incorrect username or password!") {
							$('#notifications').html(data);
						} else {
							$('#login-wrapper').html('Welcome '+data+'!');
						}
					});
					item.error(function(){
						//errors go to hidden notifications div
						$('#notifications').html('Error: Something broke');
					});
					return false; //don't reload page on submit
				} else if(registerClicked) {
					//input is valid so send it to model
					registerClicked=false; //so doesn't fire again unless clicked again
{'fraction_non_alphanumeric': 0.16899224806201552, 'fraction_numerical': 0.0, 'mean_word_length': 2.95, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6691585', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1110, 'n_words': 309}