From 5950fec6b8dddd0ce894dedff5b6cf3f170d6bd7 Mon Sep 17 00:00:00 2001 From: Ev Bogue Date: Fri, 12 Jul 2019 18:20:46 -0500 Subject: show a welcome message with an invitation to identify if a person has no name --- app.js | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 17c2de0..b85ed5b 100644 --- a/app.js +++ b/app.js @@ -8,6 +8,75 @@ function route (keys) { var screen = document.getElementById('screen') screen.appendChild(scroller) + var identify = h('div', {id: 'identify', classList: 'message'}) + + function nameCheck (id) { + console.log('Checking for name of ' + id) + + scroller.appendChild(identify) + + identify.appendChild(h('span', {innerHTML: marked("Hey! Welcome to Bogbook. If you have any questions be sure to reach out to [@ev](/#@Q++V5BbvWIg8B+TqtC9ZKFhetruuw+nOgxEqfjlOZI0=).")})) + + identify.appendChild(h('span', {innerHTML: marked("We noticed that your current public key doesn't have a name yet. Either import your existing id on the [key](/#key) page, or identify yourself using the box below. Identifying is optional, but you'll see this welcome message as long as you don't give yourself a name.")})) + + var input = h('input', {placeholder: 'Give yourself a name'}) + + identify.appendChild(h('div', [ + input, + h('button', { + onclick: function () { + content = { + type: 'name', + named: id, + name: input.value + } + + publish(content, keys).then(post => { + open(post).then(msg => { + input.value = '' + scroller.insertBefore(render(msg, keys), scroller.childNodes[1]) + identify.parentNode.removeChild(identify) + }) + }) + } + }, ['Identify']) + ])) + + + identify.appendChild(h('span', {innerHTML: marked("Next, make sure to save your public/private keypair on the [key](/#key) page, so that you can continue to use the same identity. No one has access to your private key, so no one can restore your ability to publish under this identity if you lose your keypair.")})) + + identify.appendChild(h('span', {innerHTML: marked("Finally, be sure to check out the code on [Github](http://github.com/bogbook/bog) or [SourceHut](http://git.sr.ht/~ev/bogbook)")})) + + bog(keys.publicKey).then(log => { + if (log) { + log.forEach(function (msg) { + open(msg).then(post => { + if (post.named == id) { + var identifyExists = (document.getElementById('identify') !== null) + console.log('You named yourself ' + post.name) + if (identifyExists) { + identify.parentNode.removeChild(identify) + } + } + }) + }) + } + }) + + /*bog(id).then(feed => { + if (feed) { + for (var i = 0; i < feed.length; i++) { + console.log(feed[i]) + if (feed[i].named == id) { + console.log('You named yourself already') + } + } + } + })*/ + } + + nameCheck(keys.publicKey) + if (src === 'key') { keyPage(keys) } else if (src === 'pubs') { @@ -22,7 +91,6 @@ function route (keys) { } keys().then(key => { - var navbar = h('div', {classList: 'navbar'}, [ h('div', {classList: 'internal'}, [ h('li', [h('a', {href: '#'}, ['Home'])]), -- cgit v1.2.3-70-g09d2