git ssb

16+

Dominic / patchbay



Tree: 1ebcea6c780b22911d8d71b9326be4539254272a

Files: 1ebcea6c780b22911d8d71b9326be4539254272a / modules_core / message-confirm.js

1432 bytesRaw
1var lightbox = require('hyperlightbox')
2var h = require('hyperscript')
3var u = require('../util')
4var self_id = require('../keys').id
5//publish or add
6
7var plugs = require('../plugs')
8
9var publish = plugs.first(exports.sbot_publish = [])
10var message_content = plugs.first(exports.message_content = [])
11var avatar = plugs.first(exports.avatar = [])
12var message_meta = plugs.map(exports.message_meta = [])
13
14exports.message_confirm = function (content, cb) {
15
16 cb = cb || function () {}
17
18 var lb = lightbox()
19 document.body.appendChild(lb)
20
21 var msg = {
22 key: "DRAFT",
23 value: {
24 author: self_id,
25 previous: null,
26 sequence: null,
27 timestamp: Date.now(),
28 content: content
29 }
30 }
31
32 var okay = h('button', 'okay', {onclick: function () {
33 lb.remove()
34 publish(content, cb)
35 }})
36
37 var cancel = h('button', 'Cancel', {onclick: function () {
38 lb.remove()
39 cb(null)
40 }})
41
42 okay.addEventListener('keydown', function (ev) {
43 if(ev.keyCode === 27) cancel.click() //escape
44 })
45
46 lb.show(h('div.column.message-confirm',
47 h('div.message',
48 h('div.title.row',
49 h('div.avatar', avatar(msg.value.author, 'thumbnail')),
50 h('div.message_meta.row', message_meta(msg))
51 ),
52 h('div.message_content', message_content(msg)
53 || h('pre', JSON.stringify(msg, null, 2)))
54 ),
55 h('div.row.message-confirm__controls', okay, cancel)
56 ))
57
58 okay.focus()
59
60}
61
62

Built with git-ssb-web