-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (51 loc) · 1.55 KB
/
index.js
File metadata and controls
57 lines (51 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import m from 'mithril'
import { Layout } from './Menu'
import { LaunchGame } from './LaunchGame'
import { Login } from './Login'
import 'construct-ui/lib/index.css'
import './style.css'
import { User } from './User'
import { GamePage, GamePageOnline, Games, getGames } from './Games'
import { ProfilePage } from './Profile'
import { Connector, ConnectionPage } from './Connector'
import { State, Actions, OnlineActions } from './Actions'
import { LaunchpadX } from './Launchpad'
import { Home } from './Home'
import { WebMidi } from 'webmidi'
console.log('launchchess started!')
var state = State()
export var actions = {}
Object.assign(actions, Actions(state, actions))
Object.assign(actions, LaunchGame(state, actions))
Object.assign(actions, Connector(state, actions))
Object.assign(actions, getGames(state, actions))
export var onlineActions = {
...actions,
...OnlineActions(state, actions),
}
actions.initConnector()
console.log(state, actions)
m.mount(document.body, Layout(state))
let main = document.getElementById('main')
document.body.className += state.theme
m.route(main, '/', {
'/': Home(state, actions),
'/connect': ConnectionPage(state, actions),
'/otb': GamePage(state, actions),
'/games': Games(state, actions),
'/online': GamePageOnline(state, onlineActions),
'/login': Login,
'/profile': ProfilePage,
})
// auto login
if (!User.loggedIn) {
m.request('/oauth/token').then(res => {
if (res) {
console.log('session continued', res)
User.login(res)
}
})
}
window.state = state
window.actions = actions
window.midi = WebMidi