About Input
Autocomplete: https://www.w3schools.com/howto/howto_js_autocomplete.asp
Regular expression:
Email :
1const pattern = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;Number:
1const pattern = /^\d+$/;US phone:
12
Expiration of login session
authLog:
1234567891011121314151617181920212223242526272829export const authLogIn = (email, password) => {return dispatch => {dispatch(authStart());const authData = {email: email,password: password};let url = '/login';axios.post(url, authData).then(response => {if(response.data.status == "Success"){const expirationDate = new Date(new Date().getTime() + 3600*1000);localStorage.setItem('username',response.data.info.uname);localStorage.setItem('expirationDate', expirationDate);localStorage.setItem('email', response.data.info.email);localStorage.setItem('uid', response.data.info.uid);localStorage.setItem('token', response.data.info.token); //splitdispatch(authSuccess(response.data.info.email, response.data.info.uname, response.data.info.uid,response.data.info.token));dispatch(checkAuthTimeout(3600));}else{alert(response.data.info);}}).catch(error => {console.log(error);alert("Connection Failed....");});}}
authCheckState:
1234567891011121314151617181920212223export const authCheckState = () => {return dispatch => {const email = localStorage.getItem('email');if(!email){dispatch(logout());}else{const expirationDate = new Date(localStorage.getItem('expirationDate'));if(expirationDate > new Date()){const username = localStorage.getItem('username');const userId = localStorage.getItem('uid');const token = localStorage.getItem('token');dispatch(authSuccess(email, username, userId, token));dispatch(checkAuthTimeout((expirationDate.getTime() - new Date().getTime())/1000));}else{alert("Your token has been expired.. Please log in again!");dispatch(logout());}}};}logout:
12345678910export const logout = () => {localStorage.removeItem('email');localStorage.removeItem('expirationDate');localStorage.removeItem('username');localStorage.removeItem("token");localStorage.removeItem("uid");return {type: actionTypes.AUTH_LOGOUT};}checkAuthTimeOut:
12345678export const checkAuthTimeout = (expirationTime) => {return dispatch => {setTimeout(() => {alert("You have logged in for 1 hour, for security, please log in again!");dispatch(logout());},expirationTime * 1000);};};React 404
|
|
Customize your own modal box
Create modal: https://www.w3schools.com/howto/howto_css_modals.asp
Modal Animation: https://codepen.io/designcouch/pen/obvKxm
React solution:
css
|
|
JS:
|
|
Vue HTML5 editor
Upload.vue
|
|
main.js
|
|
initHTMLEditor.js
|
|
Vue load data before render()
|
|
Save JSON object to a .json file
|
|
CSS unit
https://github.com/simaQ/cssfun/issues/1
CSS FlexBox
People will easily face a problem that is using flexbox to display contents, and set the justify-content as space-between
However, if the last line is not full-filled, we may see that it looks like
|
|
Rather than
|
|
Here comes a good solution to solve this
|
|