-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared.js
More file actions
55 lines (48 loc) · 1.39 KB
/
Copy pathshared.js
File metadata and controls
55 lines (48 loc) · 1.39 KB
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
(() => {
const CONFIG = {
API_BASE: 'https://api.agai.online/api',
PLANT_API_BASE: 'https://login.agai.online/api'
};
function escapeHTML(value) {
return String(value ?? '')
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
function escapeAttr(value) {
return escapeHTML(value).replace(/`/g, '`');
}
function showToast(message, type = 'info') {
let toast = document.getElementById('toast');
if (!toast) {
toast = document.createElement('div');
toast.id = 'toast';
toast.className = 'toast';
document.body.appendChild(toast);
}
toast.textContent = message;
toast.className = `toast ${type}`;
toast.style.display = 'block';
clearTimeout(toast.hideTimer);
toast.hideTimer = setTimeout(() => {
toast.style.display = 'none';
}, 3000);
}
function getToken() {
return localStorage.getItem('token');
}
function clearSession() {
localStorage.removeItem('token');
localStorage.removeItem('user');
localStorage.removeItem('attendancePassword');
localStorage.removeItem('pendingInviteCode');
}
window.APP_CONFIG = CONFIG;
window.escapeHTML = escapeHTML;
window.escapeAttr = escapeAttr;
window.showToast = showToast;
window.getToken = getToken;
window.clearSession = clearSession;
})();