aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEv Bogue <ev@evbogue.com>2019-04-19 09:58:39 -0500
committerEv Bogue <ev@evbogue.com>2019-04-19 09:58:39 -0500
commitd4e69ef860b7715536bde821f49b1d2830338df2 (patch)
tree5e028344ab95cac4161974b5a6ff43d1c27cb20e
parent4d276bb344ce91a5481afddaabe8716f5731a98d (diff)
move composer to lib
-rw-r--r--app.js30
-rw-r--r--lib.js33
2 files changed, 33 insertions, 30 deletions
diff --git a/app.js b/app.js
index f2a66f8..17715de 100644
--- a/app.js
+++ b/app.js
@@ -1,35 +1,5 @@
var screen = h('div', {id: 'screen'})
document.body.appendChild(screen)
-function compose (keys) {
- var message = h('div', {classList: 'message'})
-
- var scroller = document.getElementById('scroller')
-
- scroller.insertBefore(message, scroller.firstChild)
-
- var textarea = h('textarea', {placeholder: 'Write a new bog post'})
-
- message.appendChild(textarea)
-
- var composer = h('div', [
- h('button', {
- onclick: function () {
- if (textarea.value) {
- var content = {
- author: keys.publicKey,
- type: 'post',
- text: textarea.value,
- timestamp: Date.now()
- }
- textarea.value = ''
- publish(content, keys)
- }
- }
- }, ['Publish'])
- ])
- message.appendChild(composer)
-}
-
function keyPage (keys) {
var scroller = document.getElementById('scroller')
diff --git a/lib.js b/lib.js
index 6062940..23a570e 100644
--- a/lib.js
+++ b/lib.js
@@ -1,5 +1,7 @@
// generate a public.private keypair with TweetNaCl.js
+
+
function requestFeed (src, server) {
var ws = new WebSocket(server + src)
@@ -106,6 +108,37 @@ function publish (content, keys) {
})
}
+function compose (keys) {
+ var message = h('div', {classList: 'message'})
+
+ var scroller = document.getElementById('scroller')
+
+ scroller.insertBefore(message, scroller.firstChild)
+
+ var textarea = h('textarea', {placeholder: 'Write a new bog post'})
+
+ message.appendChild(textarea)
+
+ var composer = h('div', [
+ h('button', {
+ onclick: function () {
+ if (textarea.value) {
+ var content = {
+ author: keys.publicKey,
+ type: 'post',
+ text: textarea.value,
+ timestamp: Date.now()
+ }
+ textarea.value = ''
+ publish(content, keys)
+ }
+ }
+ }, ['Publish'])
+ ])
+ message.appendChild(composer)
+}
+
+
// update your log in the browser
function updateLog (feed, post) {