-
Notifications
You must be signed in to change notification settings - Fork 0
/
kinds.js
86 lines (76 loc) · 2.56 KB
/
kinds.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
let kindsReady = false
function waitForKindsReady(callback) {
var interval = setInterval(function() {
if (kindsReady) {
clearInterval(interval);
callback();
}
}, 200);
}
function displayKinds() {
document.getElementById("maincontent").replaceChildren(prepWindow())
document.getElementById("heading").innerText = "Nostr Event Kind Registry"// spontaneously organising tree of self-published notes and other stuff
document.getElementById("content").replaceChildren(loadingSign())
waitForKindsReady(function () {
renderKinds()
})
rewriteURL("nostr-event-kind-registry")
}
function renderKinds() {
box = document.createElement("div")
box.className = "content"
document.getElementById("content").replaceChildren(box)
table = document.createElement("table")
table.className = "table"
thead = document.createElement("thead")
theadr = document.createElement("tr")
theadr.appendChild(createTh("Kind"))
theadr.appendChild(createTh("Count"))
theadr.appendChild(createTh("NIP"))
theadr.appendChild(createTh("App"))
theadr.appendChild(createTh("Description"))
theadr.appendChild(createTh("Curator"))
thead.appendChild(theadr)
table.appendChild(thead)
tbody = document.createElement("tbody")
eventbucketObjects.forEach(function (v,k) {
if (v > 0) {
tbodyr = document.createElement("tr")
tbodyr.appendChild(createTd(k))
tbodyr.appendChild(createTd(v))
tbodyr.appendChild(createTd("add"))
if ((k >= 640000) && (k < 650000)) {
tbodyr.appendChild(createTd("Stackerstan"))
} else if (k < 8) {
tbodyr.appendChild(createTd("Generic"))
} else {
tbodyr.appendChild(createClaimButton())
}
tbodyr.appendChild(createTd("feature coming soon"))
tbodyr.appendChild(createClaimButton())
tbody.appendChild(tbodyr)
}
})
table.appendChild(tbody)
box.appendChild(table)
}
function createTh(title) {
theadh = document.createElement("th")
theadh.innerText = title
return theadh
}
function createTd(title) {
theadh = document.createElement("td")
if (title !== undefined) {
theadh.innerText = title
}
return theadh
}
function createClaimButton() {
claim = createTd()
claimLink = document.createElement("button")
claimLink.className = "button is-small is-primary"
claimLink.innerText = "claim"
claim.appendChild(claimLink)
return claim
}