-
Notifications
You must be signed in to change notification settings - Fork 4
/
modal.js
56 lines (44 loc) · 1.49 KB
/
modal.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
function claimKind() {
id = makeid(6)
modal = makeModal(id)
document.getElementById("content").appendChild(modal)
return id
}
function makeModal(id) {
modal = document.createElement("div")
modal.id = id
modal.className = "modal"
modal.classList.add('is-active')
background = document.createElement("div")
background.className = "modal-background"
card = document.createElement("div")
card.className = "modal-card"
header = document.createElement("header")
header.className = "modal-card-head"
title = document.createElement("p")
title.className = "modal-card-title"
title.id = id + "_title"
closer = document.createElement("button")
closer.className = "delete"
closer.ariaLabel = "close"
closer.onclick = function () {document.getElementById(id).classList.remove('is-active')}
body = document.createElement("section")
body.className = "modal-card-body"
body.id = id + "_body"
header.appendChild(title)
header.appendChild(closer)
card.appendChild(header)
card.appendChild(body)
modal.appendChild(background)
modal.appendChild(card)
return modal
}
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}