mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
92 lines
2.3 KiB
JavaScript
92 lines
2.3 KiB
JavaScript
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')
|
|
var ModsView = require('app/views/mods/index')
|
|
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()
|
|
}
|
|
})
|
|
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 () {
|
|
layoutView.content.show(new ModsView({ mods: mods }))
|
|
},
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
})
|