git ssb

2+

ev / mvd



Tree: 863e8a538677038443dd0724e2e80cf71c5b62a0

Files: 863e8a538677038443dd0724e2e80cf71c5b62a0 / index.js

2600 bytesRaw
1var h = require('hyperscript')
2var route = require('./views')
3var avatar = require('./avatar')
4
5var compose = require('./compose')
6
7var id = require('./keys').id
8
9document.head.appendChild(h('style', require('./style.css.json')))
10
11var screen = h('div#screen')
12
13var search = h('input.search', {placeholder: 'Search'})
14
15var nav = h('div.navbar',
16 h('div.internal',
17 h('li', h('a', {href: '#' + id}, h('span.avatar--small', avatar.image(id)))),
18 h('li', h('a', {href: '#' + id}, avatar.name(id))),
19 h('li', h('a', 'New Post', {
20 onclick: function () {
21 if (document.getElementById('composer')) { return }
22 else {
23 var currentScreen = document.getElementById('screen')
24 var opts = {}
25 opts.type = 'post'
26 var composer = h('div.content#composer', h('div.message', compose(opts)))
27 if (currentScreen.firstChild.firstChild) {
28 currentScreen.firstChild.insertBefore(composer, currentScreen.firstChild.firstChild)
29 } else {
30 currentScreen.firstChild.appendChild(composer)
31 }
32 }
33 }
34 })),
35 h('li', h('a', 'New Wiki', {
36 onclick: function () {
37 if (document.getElementById('composer')) { return }
38 else {
39 var currentScreen = document.getElementById('screen')
40 var opts = {}
41 opts.type = 'wiki'
42 var composer = h('div.content#composer', h('div.message', compose(opts)))
43 if (currentScreen.firstChild.firstChild) {
44 currentScreen.firstChild.insertBefore(composer, currentScreen.firstChild.firstChild)
45 } else {
46 currentScreen.firstChild.appendChild(composer)
47 }
48 }
49 }
50 })),
51 h('li', h('a', {href: '#' }, 'All')),
52 h('li', h('a', {href: '#private' }, 'Private')),
53 h('li', h('a', {href: '#friends/' + id }, 'Friends')),
54 h('li', h('a', {href: '#wall/' + id }, 'Wall')),
55 h('li', h('a', {href: '#queue'}, 'Queue')),
56 h('li', h('a', {href: '#key' }, 'Key')),
57 h('li.right', h('a', {href: '#about'}, '?')),
58 h('form.search', {
59 onsubmit: function (e) {
60 if (search.value[0] == '#')
61 window.location.hash = '#' + search.value
62 else
63 window.location.hash = '?' + search.value
64 e.preventDefault()
65 }},
66 search
67 )
68 )
69)
70
71document.body.appendChild(nav)
72document.body.appendChild(screen)
73route()
74
75window.onhashchange = function () {
76 var oldscreen = document.getElementById('screen')
77 var newscreen = h('div#screen')
78 oldscreen.parentNode.replaceChild(newscreen, oldscreen)
79 route()
80}
81
82

Built with git-ssb-web