aboutsummaryrefslogtreecommitdiff
path: root/lib/render-msg.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-04-29 20:52:20 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-04-29 20:59:37 -1000
commit0cd677474be505a645696c9364d74c8662aeea2b (patch)
tree170d0f88e48b53d0ef3772fdb4e387e05c2c2203 /lib/render-msg.js
parenta448b261d6bffa420d1f0c4d57ebe852146001bf (diff)
downloadpatchfoo-0cd677474be505a645696c9364d74c8662aeea2b.tar.gz
patchfoo-0cd677474be505a645696c9364d74c8662aeea2b.zip
Render poll messages
Reference message: %N32nKJ79k1G14lfdtr+4o+c1ftjfW22QChiQmR0oP18=.sha256 &2QHE6nnsg2i9JnFmCLq5fExlPwljCyYQYbfxQMXhONs=.sha256
Diffstat (limited to 'lib/render-msg.js')
-rw-r--r--lib/render-msg.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 68c8147..f749328 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -294,6 +294,7 @@ RenderMsg.prototype.message = function (cb) {
case 'line-comment': return this.lineComment(cb)
case 'web-init': return this.webInit(cb)
case 'web-root': return this.webRoot(cb)
+ case 'poll': return this.poll(cb)
default: return this.object(cb)
}
}
@@ -1712,3 +1713,25 @@ RenderMsg.prototype.webRoot = function (cb) {
] : ''
), cb)
}
+
+RenderMsg.prototype.poll = function (cb) {
+ var self = this
+ var closeDate = new Date(self.c.closesAt)
+ var details = self.c.pollDetails || {}
+ var choices = u.toArray(details.choices)
+ return self.wrap(h('div',
+ h('h3', {innerHTML: unwrapP(self.render.markdown(self.c.title))}),
+ h('div', {innerHTML: unwrapP(self.render.markdown(self.c.body, self.c.mentions))}),
+ details.type === 'chooseOne' ? h('form', {method: 'post', action: ''},
+ h('input', {type: 'hidden', name: 'action', value: 'poll-position'}),
+ h('input', {type: 'hidden', name: 'poll_root', value: self.msg.key}),
+ h('input', {type: 'hidden', name: 'poll_type', value: 'chooseOne'}),
+ choices.map(function (choice) {
+ return [h('input', {type: 'submit', name: 'poll_choice', value: choice}), ' ']
+ })
+ ) : h('div', 'unknown poll type'),
+ h('p', 'closes at: ', h('span', {
+ title: closeDate.toLocaleString()
+ }, closeDate.toString()))
+ ), cb)
+}