2019-09-22 21:02:31 +00:00
|
|
|
var $ = require('jquery')
|
|
|
|
var Backbone = require('backbone')
|
|
|
|
|
|
|
|
var LayoutView = require('app/views/layout')
|
|
|
|
var NavigationView = require('app/views/navigation')
|
|
|
|
var ServersView = require('app/views/servers/list')
|
|
|
|
var LogsListView = require('app/views/logs/list')
|
|
|
|
var MissionsView = require('app/views/missions/index')
|
2021-10-07 09:45:03 +00:00
|
|
|
var ModsView = require('app/views/mods/index')
|
2019-09-22 21:02:31 +00:00
|
|
|
var ServerView = require('app/views/servers/view')
|
|
|
|
var Logs = require('app/collections/logs')
|
|
|
|
var Missions = require('app/collections/missions')
|
|
|
|
var Mods = require('app/collections/mods')
|
|
|
|
var Settings = require('app/models/settings')
|
|
|
|
var Servers = require('app/collections/servers')
|
|
|
|
|
|
|
|
var $body = $('body')
|
|
|
|
var missions = new Missions()
|
|
|
|
var mods = new Mods()
|
|
|
|
var settings = new Settings()
|
|
|
|
var servers = new Servers()
|
|
|
|
var layoutView = new LayoutView({ el: $body }).render()
|
|
|
|
|
|
|
|
module.exports = Backbone.Router.extend({
|
|
|
|
|
|
|
|
routes: {
|
|
|
|
logs: 'logs',
|
|
|
|
missions: 'missions',
|
|
|
|
mods: 'mods',
|
|
|
|
'servers/:id': 'server',
|
|
|
|
'': 'home'
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
layoutView.navigation.show(new NavigationView({ settings: settings, servers: servers }))
|
|
|
|
|
|
|
|
var initialized = false
|
|
|
|
|
|
|
|
/* global io */
|
|
|
|
var socket = io.connect()
|
|
|
|
socket.on('missions', function (_missions) {
|
|
|
|
missions.set(_missions)
|
|
|
|
})
|
|
|
|
socket.on('mods', function (_mods) {
|
|
|
|
mods.set(_mods)
|
|
|
|
})
|
|
|
|
socket.on('servers', function (_servers) {
|
|
|
|
servers.set(_servers)
|
|
|
|
|
|
|
|
if (!initialized) {
|
|
|
|
initialized = true
|
|
|
|
Backbone.history.start()
|
2014-04-06 22:35:04 +00:00
|
|
|
}
|
2019-09-22 21:02:31 +00:00
|
|
|
})
|
|
|
|
socket.on('settings', function (_settings) {
|
|
|
|
settings.set(_settings)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
home: function () {
|
|
|
|
layoutView.content.show(new ServersView({ collection: servers }))
|
|
|
|
},
|
|
|
|
|
|
|
|
logs: function () {
|
|
|
|
var logs = new Logs()
|
|
|
|
logs.fetch()
|
|
|
|
layoutView.content.show(new LogsListView({ collection: logs }))
|
|
|
|
},
|
|
|
|
|
|
|
|
missions: function () {
|
|
|
|
layoutView.content.show(new MissionsView({ missions: missions }))
|
|
|
|
},
|
|
|
|
|
|
|
|
mods: function () {
|
2021-10-07 09:45:03 +00:00
|
|
|
layoutView.content.show(new ModsView({ mods: mods }))
|
2019-09-22 21:02:31 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
server: function (id) {
|
|
|
|
var server = servers.get(id)
|
|
|
|
if (server) {
|
|
|
|
layoutView.content.show(new ServerView({
|
|
|
|
model: server,
|
|
|
|
missions: missions,
|
|
|
|
mods: mods
|
|
|
|
}))
|
|
|
|
} else {
|
|
|
|
this.navigate('#', true)
|
2014-02-09 03:19:48 +00:00
|
|
|
}
|
2019-09-22 21:02:31 +00:00
|
|
|
}
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2019-09-22 21:02:31 +00:00
|
|
|
})
|