Commit 76e471a1d7f948aaea0a1f022cc8842d66dff10e
add boost button
Ev Bogue committed on 9/19/2018, 4:10:47 PMParent: b755159ec8727b3aa0e1d46c6eb1e68b95b771f1
Files changed
compose.js | changed |
render.js | changed |
compose.js | ||
---|---|---|
@@ -4,8 +4,9 @@ | ||
4 | 4 | var human = require('human-time') |
5 | 5 | var id = require('./keys').id |
6 | 6 | var mentions = require('ssb-mentions') |
7 | 7 | |
8 | +var avatar = require('./avatar') | |
8 | 9 | var tools = require('./tools') |
9 | 10 | |
10 | 11 | var mime = require('simple-mime')('application/octect-stream') |
11 | 12 | var split = require('split-buffer') |
@@ -43,10 +44,23 @@ | ||
43 | 44 | var filesById = {} |
44 | 45 | |
45 | 46 | var composer = h('div.composer') |
46 | 47 | var container = h('div.container') |
48 | + var boostName = avatar.cachedName(opts.boostAuthor) | |
47 | 49 | |
48 | - if (opts.mentions) { | |
50 | + if (opts.boostContent) { | |
51 | + var textarea = h('textarea.compose', 'Blah') | |
52 | + var str = opts.boostContent | |
53 | + var lines = str.split("\n") | |
54 | + for(var i=0; i<lines.length; i++) { | |
55 | + lines[i] = "> " + lines[i] | |
56 | + } | |
57 | + var newContent = lines.join("\n") | |
58 | + var content = 'Boosting: ' + opts.boostKey + ' by [' + boostName.textContent + ']('+ opts.boostAuthor + ')\n\n' + newContent | |
59 | + textarea.value = content | |
60 | + } | |
61 | + | |
62 | + else if (opts.mentions) { | |
49 | 63 | var textarea = h('textarea.compose', opts.mentions) |
50 | 64 | } |
51 | 65 | |
52 | 66 | else if (opts.type == 'wiki') |
render.js | ||
---|---|---|
@@ -237,8 +237,9 @@ | ||
237 | 237 | |
238 | 238 | var name = avatar.name(msg.value.author) |
239 | 239 | |
240 | 240 | var buttons = h('div.buttons') |
241 | + | |
241 | 242 | buttons.appendChild(h('button.btn', 'Reply', { |
242 | 243 | onclick: function () { |
243 | 244 | opts.type = 'post' |
244 | 245 | opts.mentions = '[' + name.textContent + '](' + msg.value.author + ')' |
@@ -255,8 +256,30 @@ | ||
255 | 256 | message.parentNode.insertBefore(compose, message.nextSibling) |
256 | 257 | } |
257 | 258 | })) |
258 | 259 | |
260 | + buttons.appendChild(h('button.btn', 'Boost', { | |
261 | + onclick: function () { | |
262 | + opts.type = 'post' | |
263 | + opts.mentions = '[' + name.textContent + '](' + msg.value.author + ')' | |
264 | + if (msg.value.content.recps) { | |
265 | + opts.recps = msg.value.content.recps | |
266 | + } | |
267 | + var r = message.childNodes.length - 1 | |
268 | + delete opts.updated | |
269 | + delete opts.original | |
270 | + delete fallback.messageText | |
271 | + opts.boostContent = msg.value.content.text | |
272 | + opts.boostKey = msg.key | |
273 | + opts.boostAuthor = msg.value.author | |
274 | + fallback.buttons = message.childNodes[r] | |
275 | + var compose = h('div.message#re:' + msg.key.substring(0, 44), composer(opts, fallback)) | |
276 | + message.removeChild(message.childNodes[r]) | |
277 | + message.parentNode.insertBefore(compose, message.nextSibling) | |
278 | + } | |
279 | + })) | |
280 | + | |
281 | + | |
259 | 282 | if (msg.value.author == id) |
260 | 283 | buttons.appendChild(h('button.btn', 'Edit', { |
261 | 284 | onclick: function () { |
262 | 285 | opts.type = 'edit' |
Built with git-ssb-web