diff options
| author | Ev Bogue <ev@evbogue.com> | 2019-04-19 09:58:39 -0500 | 
|---|---|---|
| committer | Ev Bogue <ev@evbogue.com> | 2019-04-19 09:58:39 -0500 | 
| commit | d4e69ef860b7715536bde821f49b1d2830338df2 (patch) | |
| tree | 5e028344ab95cac4161974b5a6ff43d1c27cb20e | |
| parent | 4d276bb344ce91a5481afddaabe8716f5731a98d (diff) | |
move composer to lib
| -rw-r--r-- | app.js | 30 | ||||
| -rw-r--r-- | lib.js | 33 | 
2 files changed, 33 insertions, 30 deletions
| @@ -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')  @@ -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) { | 
