aboutsummaryrefslogtreecommitdiff
path: root/lib.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib.js')
-rw-r--r--lib.js33
1 files changed, 33 insertions, 0 deletions
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) {