Files: 7a856ed68d3f4c64fac98fce38e8ead1b4b005e1 / index.js
1507 bytesRaw
1 | var h = require('hyperscript') |
2 | var route = require('./views') |
3 | var avatar = require('./avatar') |
4 | |
5 | var compose = require('./compose') |
6 | |
7 | var id = require('./keys').id |
8 | |
9 | document.head.appendChild(h('style', require('./style.css.json'))) |
10 | |
11 | var screen = h('div#screen') |
12 | |
13 | var nav = h('div.navbar', |
14 | h('div.internal', |
15 | h('li', h('a', {href: '#' + id}, h('span.avatar--small', avatar.image(id)))), |
16 | h('li', h('a', {href: '#' + id}, avatar.name(id))), |
17 | h('li', h('a', 'Compose', { |
18 | onclick: function () { |
19 | if (document.getElementById('composer')) { return } |
20 | else { |
21 | var currentScreen = document.getElementById('screen') |
22 | var opts = {} |
23 | opts.type = 'post' |
24 | var composer = h('div.content#composer', h('div.message', compose(opts))) |
25 | if (currentScreen.firstChild.firstChild) { |
26 | currentScreen.firstChild.insertBefore(composer, currentScreen.firstChild.firstChild) |
27 | } else { |
28 | currentScreen.firstChild.appendChild(composer) |
29 | } |
30 | } |
31 | } |
32 | })), |
33 | h('li', h('a', {href: '#' }, 'All')), |
34 | h('li', h('a', {href: '#queue'}, 'Queue')), |
35 | h('li', h('a', {href: '#key' }, 'Key')), |
36 | h('li.right', h('a', {href: '#about'}, '?')) |
37 | ) |
38 | ) |
39 | |
40 | document.body.appendChild(nav) |
41 | document.body.appendChild(screen) |
42 | route() |
43 | |
44 | window.onhashchange = function () { |
45 | var oldscreen = document.getElementById('screen') |
46 | var newscreen = h('div#screen') |
47 | oldscreen.parentNode.replaceChild(newscreen, oldscreen) |
48 | route() |
49 | } |
50 | |
51 |
Built with git-ssb-web