Added mail caching system

This commit is contained in:
Pierre 2017-05-24 16:37:41 +02:00
parent e04326c9f3
commit 72fe4108ba
8 changed files with 71 additions and 7 deletions

View File

@ -33,7 +33,7 @@ ComunicWeb.common.formChecker = {
//MailInput //MailInput
else if(inputType == "email"){ else if(inputType == "email"){
inputOK = input.value.match(/^[a-zA-Z0-9_.]+@[a-zA-Z0-9-]{1,}[.][a-zA-Z]{2,3}$/); inputOK = checkMail(input.value);
} }
//Password input //Password input

View File

@ -334,6 +334,14 @@ var ComunicWeb = {
} }
}, },
/**
* Mails caching component
*/
mailCaching: {
//TODO : implement
}
}, },
/** /**

View File

@ -31,6 +31,16 @@ function byId(nodeName){
return document.getElementById(nodeName); return document.getElementById(nodeName);
} }
/**
* Check a given email address
*
* @param {String} emailAddress The email address to check
* @return {Boolean} True for a valid email address / false else
*/
function checkMail(emailAddress){
return (emailAddress.match(/^[a-zA-Z0-9_.]+@[a-zA-Z0-9-]{1,}[.][a-zA-Z]{2,5}$/) === null ? false : true);
}
/** /**
* Create a quick language access function shorcut * Create a quick language access function shorcut
*/ */

View File

@ -0,0 +1,47 @@
/**
* Mail caching controller
*
* @author Pierre HUBERT
*/
ComunicWeb.components.mailCaching = {
/**
* @var Mail caching variable name
*/
__mailCachingVarName: "lastLoginMail",
/**
* Get current cached value
*
* @return {String} The current stored mail / Empty string if it doesn't exist
*/
get: function(){
//Try to get mail value
var mail = localStorage.getItem(this.__mailCachingVarName);
//If not any mail was defined
if(!mail)
return ""; //Empty value
return mail;
},
/**
* Set a new mail value
*
* @param {String} mail The mail address
* @return {Boolean} True for a success
*/
set: function(mail){
//Check mail first
if(!checkMail(mail))
return false;
//Try to save mail
localStorage.setItem(this.__mailCachingVarName, mail);
return true;
},
}

View File

@ -1,5 +0,0 @@
/**
* Mail caching controller
*
* @author Pierre HUBERT
*/

View File

@ -23,7 +23,9 @@ ComunicWeb.components.menuBar.notAuthenticated = {
loginForm.setAttribute("role", "login"); loginForm.setAttribute("role", "login");
loginForm.onsubmit = function(){ loginForm.onsubmit = function(){
//Try to login user; in case of failure redirect //Try to login user; in case of failure redirect to login page
return false;
} }
//Add email address formGroup //Add email address formGroup

View File

@ -29,6 +29,7 @@ ComunicWeb.pagesList = {
logout: { logout: {
pageTitle: "Logout", pageTitle: "Logout",
methodHandler: "ComunicWeb.pages.logout.openLogoutPage", methodHandler: "ComunicWeb.pages.logout.openLogoutPage",
disableMenus: true,
}, },
/** /**

View File

@ -58,6 +58,7 @@ $config['JSfiles'] = array(
"%PATH_ASSETS%js/common/system.js", "%PATH_ASSETS%js/common/system.js",
//Components //Components
"%PATH_ASSETS%js/components/mailCaching.js",
"%PATH_ASSETS%js/components/menuBar/common.js", "%PATH_ASSETS%js/components/menuBar/common.js",
"%PATH_ASSETS%js/components/menuBar/notAuthenticated.js", "%PATH_ASSETS%js/components/menuBar/notAuthenticated.js",