git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit 300a5135afd10610eb907dbdf31614142d3025ae

Add switch for showing message JSON

Charles Lehner committed on 7/24/2016, 3:46:17 PM
Parent: bf5b79d17d7fcf89a7cb0ad35bff87d0c66f184a

Files changed

modules/index.jschanged
modules/raw.jsadded
modules/index.jsView
@@ -23,8 +23,9 @@
2323 "notifications.js": require('./notifications.js'),
2424 "post.js": require('./post.js'),
2525 "private.js": require('./private.js'),
2626 "public.js": require('./public.js'),
27+ "raw.js": require('./raw.js'),
2728 "search-box.js": require('./search-box.js'),
2829 "search.js": require('./search.js'),
2930 "split.js": require('./split.js'),
3031 "suggest-mentions.js": require('./suggest-mentions.js'),
modules/raw.jsView
@@ -1,0 +1,39 @@
1+var h = require('hyperscript')
2+var u = require('../util')
3+var pull = require('pull-stream')
4+var Scroller = require('pull-scroll')
5+
6+var plugs = require('../plugs')
7+var message_render = plugs.first(exports.message_render = [])
8+var message_compose = plugs.first(exports.message_compose = [])
9+
10+exports.message_meta = function (msg) {
11+ var tmp = h('div')
12+ var el
13+ var pre
14+ return h('input', {
15+ type: 'checkbox',
16+ title: 'View Data',
17+ onclick: function () {
18+ var msgEl = this.parentNode.parentNode.parentNode
19+ var msgContentEl = msgEl.querySelector('.message_content')
20+ if (this.checked) {
21+ // move away the content
22+ while (el = msgContentEl.firstChild)
23+ tmp.appendChild(el)
24+ // show the raw stuff
25+ var json = JSON.stringify({key: msg.key, value: msg.value}, 0, 2)
26+ pre = h('pre', json)
27+ msgContentEl.appendChild(pre)
28+ } else {
29+ // hide the raw stuff
30+ msgContentEl.removeChild(pre)
31+ // put back the content
32+ while (el = tmp.firstChild)
33+ msgContentEl.appendChild(el)
34+ }
35+ }
36+ })
37+}
38+
39+

Built with git-ssb-web