diff options
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 72 |
1 files changed, 0 insertions, 72 deletions
@@ -1,78 +1,6 @@ var screen = h('div', {id: 'screen'}) document.body.appendChild(screen) -function composer (keys, reply, gotName) { - var messageDiv = h('div') - var message = h('div', {classList: 'message'}) - - if (gotName) { - console.log(gotName.textContent) - var textarea = h('textarea', ['[' + gotName.textContent + '](' + reply.author + ')']) - } else { - - var textarea = h('textarea', {placeholder: 'Write a new bog post...'}) - } - - - - var publisher = h('div', [ - textarea, - h('button', { - onclick: function () { - if (textarea.value) { - var content = { - type: 'post', - text: textarea.value - } - if (reply) { - content.reply = reply.key - } - - publish(content, keys, {preview: true}).then(post => { - open(post).then(msg => { - var preview = render(msg, keys, {preview: true}) - var cache = messageDiv.firstChild - messageDiv.appendChild(preview) - messageDiv.removeChild(messageDiv.firstChild) - preview.firstChild.appendChild(h('button', { - onclick: function () { - messageDiv.removeChild(messageDiv.firstChild) - messageDiv.appendChild(cache) - } - }, ['Cancel'])) - preview.firstChild.appendChild(h('button', { - onclick: function () { - publish(content, keys).then(post => { - open(post).then(msg => { - textarea.value = '' - if (reply) { - messageDiv.removeChild(messageDiv.firstChild) - } - if (messageDiv.firstChild) { - messageDiv.removeChild(messageDiv.firstChild) - messageDiv = h('div') - messageDiv.appendChild(cache) - scroller.insertBefore(messageDiv, scroller.childNodes[2]) - scroller.insertBefore(render(msg, keys), scroller.childNodes[3]) - } else { - messageDiv.appendChild(render(msg, keys)) - } - }) - }) - } - }, ['Publish'])) - }) - }) - } - } - }, ['Preview']) - ]) - - message.appendChild(publisher) - messageDiv.appendChild(message) - return messageDiv -} - function route (keys) { src = window.location.hash.substring(1) |