EVR.Account.Form.Forms.Login_Form = function(forms)
{
   EVR.Account.Form.call(this, forms.element, "Login");
   this.forms = forms;
   this.initialize();
   this.add_inputs();
}
EVR.Account.Form.Forms.Login_Form.prototype = new EVR.Account.Form;
EVR.Account.Form.Forms.Login_Form.prototype.add_inputs = function()
{
   this.add_input("name", "username");
   this.add_input("pass", "password", "password");
}
EVR.Account.Form.Forms.Login_Form.prototype.respond = function()
{
   var response = this.submit();
   if (response == "")
   {
      this.clear_errors();
      this.forms.account.evr.log_in();
   }
   else
   {
      var current = this;
      window.setTimeout(
	 function()
	 {
	    current.clear_errors();
	    current.handle_error(response)
	    current.display_errors();
	 }, FORM_RESULTS_DELAY);
   }
}
EVR.Account.Form.Forms.Login_Form.prototype.submit = function()
{
   var script = SOURCE_PATH + "account/submit_login_request.php";
   var query = this.build_query();
   return new EVR.Requester(script, query, true).execute();
}
EVR.Account.Form.Forms.Login_Form.prototype.handle_error = function(error)
{
   var erroneous = "";
   if (error == "username not found (note: usernames are case-sensitive)")
   {
      erroneous = "name";
   }
   else if (error == "password doesn't match username")
   {
      erroneous = "pass";
   }
   if (erroneous != "")
   {
      this.add_error(error, erroneous);
   }
   else
   {
      alert(error);
   }
}
EVR.Account.Form.Forms.Registration_Form = function(forms)
{
   EVR.Account.Form.call(this, forms.element, "Register");
   this.forms = forms;
   this.initialize();
   this.add_inputs();
}
EVR.Account.Form.Forms.Registration_Form.prototype = new EVR.Account.Form;
EVR.Account.Form.Forms.Registration_Form.prototype.add_inputs = function()
{
   this.add_input("user", "username");
   this.add_input("pass", "password", "password");
   this.add_input("repeat", "confirm password", "password");
   this.add_input("email", "email address");
}
EVR.Account.Form.Forms.Registration_Form.prototype.respond = function()
{
   var response = this.submit();
   if (response[0] == "")
   {
      this.clear_errors();
      this.forms.account.evr.log_in();
   }
   else
   {
      var current = this;
      window.setTimeout(
	 function()
	 {
	    current.clear_errors();
	    current.add_errors(response);
	    current.display_errors();
	 }, FORM_RESULTS_DELAY);
   }
}
EVR.Account.Form.Forms.Registration_Form.prototype.submit = function()
{
   var script = SOURCE_PATH + "account/submit_registration_request.php";
   var query = this.build_query();
   return new EVR.Requester(script, query, true).execute().split("\n");
}
EVR.Account.Form.Forms.Registration_Form.prototype.add_errors = function(errors)
{
   var error, erroneous, found, display_response = false;
   for (var ii = 0; ii < errors.length; ii++)
   {
      error = errors[ii];
      erroneous = [];
      found = false;
      switch (error)
      {
         case "username taken":
         case "username too short":
         case "username too long":
         case "username contains invalid characters":
	    erroneous.push("user");
	    found = true;
      }
      switch (error)
      {
         case "submitted passwords don't match":
         case "password too short":
         case "password too long":
	    erroneous.push("pass");
	    erroneous.push("repeat");
	    found = true;
      }
      switch (error)
      {
         case "invalid email address format":
	    erroneous.push("email");
	    found = true;
      }
      if (!found)
      {
	 display_response = true;
      }
      else
      {
	 this.add_error(error, erroneous);
      }
   }
   if (display_response)
   {
      alert(errors);
   }
}
EVR.Account.Form.Forms.Forgot_Password_Form = function(forms)
{
   EVR.Account.Form.call(this, forms.element, "Reset Password");
   this.forms = forms;
   this.initialize();
   this.add_inputs();
}
EVR.Account.Form.Forms.Forgot_Password_Form.prototype = new EVR.Account.Form;
EVR.Account.Form.Forms.Forgot_Password_Form.prototype.add_inputs = function()
{
   this.add_input("name", "username");
   this.add_input("email", "email address");
}
EVR.Account.Form.Forms.Forgot_Password_Form.prototype.respond = function()
{
   var response = this.submit();
   if (response == "")
   {
      this.clear_errors();
      this.forms.account.evr.unload_account();
   }
   else
   {
      var current = this;
      window.setTimeout(
	 function()
	 {
	    current.clear_errors();
	    current.handle_errors(response);
	    current.display_errors();
	 }, FORM_RESULTS_DELAY);
   }
}
EVR.Account.Form.Forms.Forgot_Password_Form.prototype.submit = function()
{
   var script = SOURCE_PATH + "account/submit_reset_password_request.php";
   var query = this.build_query();
   return new EVR.Requester(script, query, true).execute();
}
EVR.Account.Form.Forms.Forgot_Password_Form.prototype.handle_errors =
   function(error)
{
   switch (error)
   {
      case "submitted address doesn't match account address":
      case "mail delivery failed":
         this.add_error(error, "email");
         break;
      case "username not found":
         this.add_error(error, "name");
         break;
      default:
         alert(error);
   }
}
54.162.227.37
54.162.227.37
54.162.227.37
 
June 7, 2018


↠ RSS Feed ↞