aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/render-msg.js26
-rw-r--r--lib/serve.js1
2 files changed, 17 insertions, 10 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 91e7386..cda8eab 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -1747,23 +1747,29 @@ RenderMsg.prototype.poll = function (cb) {
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))}),
+ h('p', 'closes at: ', h('span', {
+ title: closeDate.toLocaleString()
+ }, closeDate.toString())),
details.type === 'chooseOne' ? h('form', {method: 'post', action: ''},
+ h('p', 'Choose one'),
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()))
+ choices.map(function (choice, i) {
+ return h('div',
+ h('input', {type: 'radio', name: 'poll_choice', value: i}), ' ', String(choice))
+ }),
+ h('p', 'reason: ',
+ h('div', h('textarea', {name: 'poll_reason'}))
+ ),
+ h('p', h('input', {type: 'submit', value: 'preview publish position'}))
+ ) : h('div', 'unknown poll type')
), cb)
}
RenderMsg.prototype.pollPosition = function (cb) {
var self = this
- var details = self.c.pollDetails || self.c.details || {}
+ var details = self.c.pollDetails || self.c.details || self.c
var reason = self.c.reason || ''
var done = multicb({pluck: 1, spread: true})
self.link(self.c.root, done())
@@ -1776,9 +1782,9 @@ RenderMsg.prototype.pollPosition = function (cb) {
done(function (err, rootLink, branchLinks, rootMsg) {
if (err) return cb(err)
var rootContent = rootMsg && rootMsg.value.content || {}
- var rootDetails = rootContent.pollDetails || rootContent.details || {}
+ var rootDetails = rootContent.pollDetails || rootContent.details || rootContent
var choices = u.toArray(rootDetails.choices)
- var choice = details.choice && choices && choices[details.choice]
+ var choice = details.choice != null && choices && choices[details.choice]
return self.wrap(h('div',
rootLink ? h('div', h('small', h('span.symbol', '→'), ' ', rootLink)) : '',
branchLinks.map(function (a, i) {
diff --git a/lib/serve.js b/lib/serve.js
index a05739a..448b18b 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -232,6 +232,7 @@ Serve.prototype.publishPollPosition = function (cb) {
version: 'v1',
channel: this.data.channel || undefined,
root: this.data.poll_root,
+ reason: this.data.poll_reason,
details: {
type: this.data.poll_type,
choice: this.data.poll_choice