git ssb

16+

Dominic / patchbay



Tree: 5db5f5879a68ea7da4a9376e6e95b8ef07522e10

Files: 5db5f5879a68ea7da4a9376e6e95b8ef07522e10 / modules_core / message-confirm.js

1691 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
9exports.needs = {
10 publish: 'first', message_content: 'first', avatar: 'first',
11 message_meta: 'map'
12}
13
14exports.gives = 'message_confirm'
15
16//var publish = plugs.first(exports.sbot_publish = [])
17//var message_content = plugs.first(exports.message_content = [])
18//var avatar = plugs.first(exports.avatar = [])
19//var message_meta = plugs.map(exports.message_meta = [])
20//
21exports.create = function (api) {
22 return function (content, cb) {
23
24 cb = cb || function () {}
25
26 var lb = lightbox()
27 document.body.appendChild(lb)
28
29 var msg = {
30 key: "DRAFT",
31 value: {
32 author: self_id,
33 previous: null,
34 sequence: null,
35 timestamp: Date.now(),
36 content: content
37 }
38 }
39
40 var okay = h('button', 'okay', {onclick: function () {
41 lb.remove()
42 api.publish(content, cb)
43 }})
44
45 var cancel = h('button', 'Cancel', {onclick: function () {
46 lb.remove()
47 cb(null)
48 }})
49
50 okay.addEventListener('keydown', function (ev) {
51 if(ev.keyCode === 27) cancel.click() //escape
52 })
53
54 lb.show(h('div.column.message-confirm',
55 h('div.message',
56 h('div.title.row',
57 h('div.avatar', api.avatar(msg.value.author, 'thumbnail')),
58 h('div.message_meta.row', api.message_meta(msg))
59 ),
60 h('div.message_content', api.message_content(msg)
61 || h('pre', JSON.stringify(msg, null, 2)))
62 ),
63 h('div.row.message-confirm__controls', okay, cancel)
64 ))
65
66 okay.focus()
67 }
68}
69
70

Built with git-ssb-web