aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEv Bogue <ev@evbogue.com>2019-05-02 19:48:29 -0500
committerEv Bogue <ev@evbogue.com>2019-05-02 19:48:29 -0500
commitfbbae53a5ae9953027b60896e2256f82e6db0260 (patch)
treeee21a0f3dba7d085ddbf1b9e869346ed272ab0dc
parent1349b24f20b404086cd4088e382e73ebf8b1a7e6 (diff)
include names when replying
-rw-r--r--app.js10
-rw-r--r--render.js7
2 files changed, 11 insertions, 6 deletions
diff --git a/app.js b/app.js
index 8758e18..053fe3a 100644
--- a/app.js
+++ b/app.js
@@ -1,11 +1,17 @@
var screen = h('div', {id: 'screen'})
document.body.appendChild(screen)
-function composer (keys, reply) {
+function composer (keys, reply, gotName) {
var messageDiv = h('div')
var message = h('div', {classList: 'message'})
- var textarea = h('textarea', {placeholder: 'Write a new bog post...'})
+ 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,
diff --git a/render.js b/render.js
index d820f2a..e1d92b8 100644
--- a/render.js
+++ b/render.js
@@ -52,16 +52,15 @@ function render (msg, keys) {
h('a', {href: '#' + msg.reply}, [msg.reply.substring(0, 10) + '...'])
]))
}
-
+ var gotName = getName(msg.author)
message.appendChild(h('div', {innerHTML: marked(msg.text)}))
message.appendChild(h('button', {
onclick: function () {
if (messageDiv.firstChild) {
- messageDiv.insertBefore(h('div', {classList: 'submessage'}, [composer(keys, msg)]), messageDiv.childNodes[1])
+ messageDiv.insertBefore(h('div', {classList: 'submessage'}, [composer(keys, msg, gotName)]), messageDiv.childNodes[1])
} else {
- messageDiv.appendChild(h('div', {classList: 'submessage'}, [composer(keys, msg)]))
+ messageDiv.appendChild(h('div', {classList: 'submessage'}, [composer(keys, msg, gotName)]))
}
-
}
}, ['Reply']))
} else if (msg.type == 'name') {