git ssb

0+

ev / 0qc



Tree: 231a81f9e0adf80fa3566be93221cf1f5158fcb6

Files: 231a81f9e0adf80fa3566be93221cf1f5158fcb6 / index.js

1759 bytesRaw
1var h = require('hyperscript')
2var route = require('./views')
3var avatar = require('./avatar')
4var compose = require('./compose')
5var id = require('./keys').id
6
7// append global stylesheet to <head> (built using style.js)
8document.head.appendChild(h('style', require('./style.css.json')))
9
10// #screen is the element everything else gets appended.
11var screen = h('div#screen')
12
13// navbar is appended to the top of the document (outside of screen)
14var nav = h('div.navbar',
15 h('div.internal',
16 h('li', h('a', {href: '#' + id}, h('span.avatar--small', avatar.image(id)))),
17 h('li', h('a', {href: '#' + id}, avatar.name(id))),
18 h('li', h('a', 'New Post', {
19 onclick: function () {
20 if (document.getElementById('composer')) { return }
21 else {
22 var currentScreen = document.getElementById('screen')
23 var opts = {}
24 opts.type = 'post'
25 var composer = h('div.content#composer', h('div.message', compose(opts)))
26 if (currentScreen.firstChild.firstChild) {
27 currentScreen.firstChild.insertBefore(composer, currentScreen.firstChild.firstChild)
28 } else {
29 currentScreen.firstChild.appendChild(composer)
30 }
31 }
32 }
33 })),
34 h('li', h('a', {href: '#' }, 'All')),
35 h('li', h('a', {href: '#wall/' + id }, 'Wall')),
36 h('li', h('a', {href: '#key' }, 'Key'))
37 )
38)
39
40//append those two elements
41document.body.appendChild(nav)
42document.body.appendChild(screen)
43
44// call the router
45route()
46
47// this code clears the #screen element when the #hash changes
48window.onhashchange = function () {
49 var oldscreen = document.getElementById('screen')
50 var newscreen = h('div#screen')
51 oldscreen.parentNode.replaceChild(newscreen, oldscreen)
52 route()
53}
54
55

Built with git-ssb-web