2022-04-27 05:15:06 +00:00
|
|
|
let alertTimeout, alertCooldown = 3000
|
|
|
|
|
2022-04-27 05:24:45 +00:00
|
|
|
async function displayLoginAlert(message, type, cooldown = null) {
|
2022-04-27 05:15:06 +00:00
|
|
|
const elm = document.getElementById('loginAlert');
|
|
|
|
const text = document.getElementById('loginAlertText');
|
|
|
|
|
|
|
|
elm.style.removeProperty('display');
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case 'error':
|
|
|
|
elm.classList.add('error');
|
|
|
|
break;
|
|
|
|
|
2022-04-27 05:24:45 +00:00
|
|
|
case 'success':
|
|
|
|
elm.classList.add('success');
|
|
|
|
break;
|
|
|
|
|
2022-04-27 05:15:06 +00:00
|
|
|
case 'warn':
|
|
|
|
default:
|
|
|
|
elm.classList.add('warn');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
text.innerText = message;
|
|
|
|
|
2022-04-27 05:24:45 +00:00
|
|
|
// Disappear after cooldown
|
2022-04-27 05:15:06 +00:00
|
|
|
alertTimeout = setTimeout(() => {
|
|
|
|
elm.style.display = 'none';
|
2022-04-27 05:24:45 +00:00
|
|
|
}, cooldown || alertCooldown)
|
2022-04-27 05:15:06 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 05:24:45 +00:00
|
|
|
async function displayRegisterAlert(message, type, cooldown = null) {
|
2022-04-27 05:15:06 +00:00
|
|
|
const elm = document.getElementById('registerAlert');
|
2022-04-27 05:24:45 +00:00
|
|
|
const text = document.getElementById('registerAlertText');
|
2022-04-27 05:15:06 +00:00
|
|
|
|
|
|
|
elm.style.removeProperty('display');
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case 'error':
|
|
|
|
elm.classList.add('error');
|
|
|
|
break;
|
|
|
|
|
2022-04-27 05:24:45 +00:00
|
|
|
case 'success':
|
|
|
|
elm.classList.add('success');
|
|
|
|
break;
|
|
|
|
|
2022-04-27 05:15:06 +00:00
|
|
|
case 'warn':
|
|
|
|
default:
|
|
|
|
elm.classList.add('warn');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
text.innerText = message;
|
|
|
|
|
2022-04-27 05:24:45 +00:00
|
|
|
// Disappear after cooldown
|
2022-04-27 05:15:06 +00:00
|
|
|
alertTimeout = setTimeout(() => {
|
|
|
|
elm.style.display = 'none';
|
2022-04-27 05:24:45 +00:00
|
|
|
}, cooldown || alertCooldown)
|
2022-04-27 05:15:06 +00:00
|
|
|
}
|