-
Notifications
You must be signed in to change notification settings - Fork 4
/
ushtree.js
105 lines (100 loc) · 3.8 KB
/
ushtree.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
function displayUshTree() {
waitForDokiReady(function () {
document.getElementById("maincontent").replaceChildren(prepWindow())
document.getElementById("heading").innerText = "Identity Tree: Cheapest Sybil Attack Mitigation, Ever."
document.getElementById("heading").appendChild(spacer())
document.getElementById("heading").appendChild(helpButton("2a60437d8637d0d3f18ded4a5435ae47794c047c2968d0b29903aafc93dc4b66"))
document.getElementById("details").replaceChildren(unverifiedHeader(), dokiInABubble("6a2205445c6c24f35b353f3662fc8baaa937067ba94cb3d1c854e6aa4a0df516"), getUnverified())
renderUshTree()
rewriteURL("identity_tree")
})
}
function unverifiedHeader() {
h = document.createElement("h3")
h.className = "is-3"
h.innerText = "Accounts waiting to be added"
return h
}
function renderUshTree() {
cont = document.getElementById("content")
identityObjects.forEach(function (ident) {
if (ident.UshBy.length > 0) {
parentIdent = document.getElementById(ident.UshBy)
if (parentIdent !== null) {
parentIdent.appendChild(getIdentityLayout(ident))
} else {
cont.appendChild(getIdentityLayout(ident))
}
}
})
}
function getUnverified() {
box = document.createElement("div")
box.className = "content"
identityObjects.forEach(function (ident) {
if (typeof ident !== undefined) {
if (typeof ident.UshBy !== undefined) {
if (ident.UshBy.length === 0) {
box.appendChild(getIdentityLayout(ident))
}
}
}
})
return box
}
function getIdentityLayout(ident) {
article = document.createElement("article")
article.className = "media"
figure = document.createElement("figure")
figure.className = "media-left"
pic = document.createElement("p")
pic.className = "image is-64x64"
pic.innerHTML = `<img src="https://bulma.io/images/placeholders/128x128.png">`
figure.appendChild(pic)
article.appendChild(figure)
mcontent = document.createElement("div")
mcontent.className = "media-content"
mcontent.id = ident.Account
content = document.createElement("div")
content.className = "content"
contentNameAndText = document.createElement("p")
contentName = document.createElement("a")
contentName.onclick = function () {
setURLID("profile_id", ident.Account)
}
contentName.innerText = ((ident.Name.length > 0) ? ident.Name : ident.Account) + " "
if (typeof ident === "object") {
if (ident.UshBy.length > 0) {
contentName.appendChild(bluecheck())
}
}
contentNameAndText.appendChild(contentName)
contentCred = document.createElement("p")
contentCred.innerText = "Account Number: " + ident.Order.toString()
contentNameAndText.appendChild(contentCred)
contentText = document.createElement("p")
contentText.innerText = ident.About
contentNameAndText.appendChild(contentText)
content.appendChild(contentNameAndText)
mcontent.appendChild(content)
nav = document.createElement("nav")
nav.className = "level is-mobile"
left = document.createElement("div")
left.className = "level-left"
// reply = document.createElement("a")
// reply.className = "level-item"
// reply.onclick = function () {
// //document.getElementById(ident.Account).replaceChildren()
// }
// span = document.createElement("span")
// span.className = "icon is-small"
// icon = document.createElement("i")
// icon.className = "fas fa-reply"
// span.appendChild(icon)
// reply.appendChild(span)
// left.appendChild(reply)
nav.appendChild(left)
mcontent.appendChild(nav)
article.appendChild(mcontent)
return article
}