-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi.js
42 lines (35 loc) · 1.59 KB
/
api.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
// to-do
const api = {
getUser : getUser,
alert:Alert
}
export function getUser() {
try {
const user = netlifyIdentity.currentUser();
return {"email":user.email,"user_metadata":user.user_metadata}
} catch {
location.reload()
}
}
export function Alert(message,title,callback) {
document.body.innerHTML = document.body.innerHTML + '<div id="dialogoverlay"></div><div id="dialogbox" class="slit-in-vertical"><div><div id="dialogboxhead"></div><div id="dialogboxbody"></div><div id="dialogboxfoot"></div></div></div>';
let dialogoverlay = document.getElementById('dialogoverlay');
let dialogbox = document.getElementById('dialogbox');
let winH = window.innerHeight;
dialogoverlay.style.height = winH + "px";
dialogbox.style.top = "100px";
dialogoverlay.style.display = "block";
dialogbox.style.display = "block";
document.getElementById('dialogboxhead').style.display = 'block';
if (typeof title === 'undefined') {
document.getElementById('dialogboxhead').style.display = 'none';
} else {
document.getElementById('dialogboxhead').innerHTML = '<i class="fa fa-exclamation-circle" aria-hidden="true"></i> ' + title;
}
document.getElementById('dialogboxbody').innerHTML = message;
document.getElementById('dialogboxfoot').innerHTML = '<button class="pure-material-button-contained active" onclick="' + `(() => {
document.getElementById('dialogbox').style.display = 'none';
document.getElementById('dialogoverlay').style.display = 'none';
${callback}})()
` + '">OK</button>';
}