-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.js
59 lines (51 loc) · 1.61 KB
/
helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
export const partials = {
header: './templates/common/header.hbs',
footer: './templates/common/footer.hbs'
}
export function sessionInfo(data) {
sessionStorage.setItem('id', data._id)
sessionStorage.setItem('name', data.username);
sessionStorage.setItem('authtoken', data._kmd.authtoken);
}
export function getUserInfo(ctx) {
ctx.name = sessionStorage.getItem('name')
ctx.loggedIn = sessionStorage.getItem('authtoken') !== null;
ctx.id = sessionStorage.getItem('id')
}
export function checkInput() {
return [ ...arguments ].some(x => x.trim() === '');
}
export function passwordCheck(password, rePassword) {
if (password === '' || rePassword === '') {
alert('Password must be filled out');
return false;
}
if (password !== rePassword) {
alert('Your password and confirmation password do not match.');
return false;
}
return true;
}
export function displaySucces(message){
const successBox = document.getElementById('successBox')
successBox.style.display = 'block'
successBox.textContent = message
setTimeout(()=>{
successBox.style.display = 'none'
}, 2000)
}
export function displayLoading(){
const loadingBox = document.getElementById("loadingBox");
loadingBox.style.display = "block";
setTimeout(() => {
loadingBox.style.display = "none"
}, 2000);
}
export function displayError(message){
const errorBox = document.getElementById("errorBox");
errorBox.style.display = "block";
errorBox.textContent = message;
setTimeout(() => {
errorBox.style.display = "none"
}, 2000);
}