Files: f37a22d0e5735c492bc3ad775666f1a96e290f9d / index.js
2543 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 search = h('input.search', {placeholder: 'Search'}) |
14 | |
15 | var 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: '#mentions' }, 'Mentions')), |
54 | h('li', h('a', {href: '#queue'}, 'Queue')), |
55 | h('li', h('a', {href: '#key' }, 'Key')), |
56 | h('li.right', h('a', {href: '#about'}, '?')), |
57 | h('form.search', { |
58 | onsubmit: function (e) { |
59 | if (search.value[0] == '#') |
60 | window.location.hash = '#' + search.value |
61 | else |
62 | window.location.hash = '?' + search.value |
63 | e.preventDefault() |
64 | }}, |
65 | search |
66 | ) |
67 | ) |
68 | ) |
69 | |
70 | document.body.appendChild(nav) |
71 | document.body.appendChild(screen) |
72 | route() |
73 | |
74 | window.onhashchange = function () { |
75 | var oldscreen = document.getElementById('screen') |
76 | var newscreen = h('div#screen') |
77 | oldscreen.parentNode.replaceChild(newscreen, oldscreen) |
78 | route() |
79 | } |
80 | |
81 |
Built with git-ssb-web