mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Added mail caching system
This commit is contained in:
parent
e04326c9f3
commit
72fe4108ba
@ -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
|
||||||
|
@ -334,6 +334,14 @@ var ComunicWeb = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mails caching component
|
||||||
|
*/
|
||||||
|
mailCaching: {
|
||||||
|
//TODO : implement
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
47
assets/js/components/mailCaching.js
Normal file
47
assets/js/components/mailCaching.js
Normal 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;
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
/**
|
|
||||||
* Mail caching controller
|
|
||||||
*
|
|
||||||
* @author Pierre HUBERT
|
|
||||||
*/
|
|
@ -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
|
||||||
|
@ -29,6 +29,7 @@ ComunicWeb.pagesList = {
|
|||||||
logout: {
|
logout: {
|
||||||
pageTitle: "Logout",
|
pageTitle: "Logout",
|
||||||
methodHandler: "ComunicWeb.pages.logout.openLogoutPage",
|
methodHandler: "ComunicWeb.pages.logout.openLogoutPage",
|
||||||
|
disableMenus: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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",
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user