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
106
107
108
109
110
111
112
113
114
115
116
117
|
function threadPage (src, keys) {
get(src).then(msg => {
scroller.appendChild(render(msg, keys))
})
}
function profilePage (src, keys) {
var profile = h('div', {classList: 'profile'})
scroller.appendChild(profile)
sync(src, keys)
var input = h('input', {placeholder: 'New name'})
profile.appendChild(h('a', {href: '#' + src}, [getName(src)]))
profile.appendChild(h('div', [
input,
h('button', {
onclick: function () {
content = {
type: 'name',
named: src,
name: input.value
}
publish(content, keys).then(post => {
open(post).then(msg => {
input.value = ''
scroller.insertBefore(render(msg, keys), scroller.childNodes[1])
})
})
}
}, ['Identify'])
]))
/*profile.appendChild(h('button', {
onclick: function () {
sync(src, keys)
}
}, ['Sync feed']))*/
profile.appendChild(h('button', {
onclick: function () {
localforage.removeItem(src).then(function () {
location.hash = ''
regenerate()
})
}
}, ['Delete feed']))
bog(src).then(log => {
if (log) {
log.forEach(function (msg) {
open(msg).then(post => {
scroller.appendChild(render(post, keys))
})
})
}
})
}
function publicPage (keys) {
sync('@Q++V5BbvWIg8B+TqtC9ZKFhetruuw+nOgxEqfjlOZI0=', keys)
scroller.appendChild(h('button', {
onclick: function () {
localforage.clear().then(function () {location.reload()})
}
}, ['Delete Everything']))
scroller.appendChild(h('button', {
onclick: function () {
regenerate()
}
}, ['Regenerate']))
scroller.appendChild(composer(keys))
bog().then(log => {
log.forEach(function (msg) {
scroller.appendChild(render(msg, keys))
})
})
}
function keyPage (keys) {
var message = h('div', {classList: 'message'})
message.appendChild(h('p', {innerHTML: marked('This is your ed25519 public/private keypair. It was generated using [TweetNaCl.js](https://tweetnacl.js.org/#/). Your public key is your identity when using [Bogbook](http://bogbook.com/), save your key in a safe place so that you can continue to use the same identity.')}))
message.appendChild(h('pre', {style: 'width: 80%'}, [h('code', [JSON.stringify(keys)])]))
message.appendChild(h('button', {
onclick: function () {
localforage.removeItem('id', function () {
location.hash = ''
location.reload()
})
}
}, ['Delete Key']))
var textarea = h('textarea', {placeholder: 'Import your existing ed25519 keypair'})
message.appendChild(textarea)
message.appendChild(h('button', {
onclick: function () {
if (textarea.value) {
localforage.setItem('id', JSON.parse(textarea.value))
location.reload()
}
}
}, ['Import Key']))
scroller.appendChild(message)
}
|