2014-02-09 03:19:48 +00:00
|
|
|
define(function (require) {
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
"use strict";
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
var $ = require('jquery'),
|
|
|
|
Backbone = require('backbone'),
|
|
|
|
LayoutView = require('app/views/layout'),
|
|
|
|
NavigationView = require('app/views/navigation'),
|
2014-04-13 17:10:40 +00:00
|
|
|
ServersView = require('app/views/servers/list'),
|
2014-09-28 08:50:03 +00:00
|
|
|
LogsListView = require('app/views/logs/list'),
|
2014-07-26 09:01:53 +00:00
|
|
|
MissionsView = require('app/views/missions/index'),
|
2014-02-09 03:19:48 +00:00
|
|
|
ModsListView = require('app/views/mods/list'),
|
|
|
|
ServerView = require('app/views/servers/view'),
|
2014-09-28 08:50:03 +00:00
|
|
|
Logs = require('app/collections/logs'),
|
2014-04-04 09:28:33 +00:00
|
|
|
Missions = require('app/collections/missions'),
|
2014-02-09 03:19:48 +00:00
|
|
|
Mods = require('app/collections/mods'),
|
2017-10-05 20:55:57 +00:00
|
|
|
Settings = require('app/models/settings'),
|
2014-02-09 03:19:48 +00:00
|
|
|
Servers = require('app/collections/servers'),
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
$body = $('body'),
|
2014-04-04 09:28:33 +00:00
|
|
|
missions = new Missions(),
|
2014-02-09 03:19:48 +00:00
|
|
|
mods = new Mods(),
|
2017-10-05 20:55:57 +00:00
|
|
|
settings = new Settings(),
|
2014-02-09 03:19:48 +00:00
|
|
|
servers = new Servers(),
|
2015-04-17 17:56:47 +00:00
|
|
|
layoutView = new LayoutView({el: $body}).render();
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
return Backbone.Router.extend({
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
routes: {
|
2014-09-28 08:50:03 +00:00
|
|
|
"logs": "logs",
|
2014-04-04 09:28:33 +00:00
|
|
|
"missions": "missions",
|
2014-02-09 03:19:48 +00:00
|
|
|
"mods": "mods",
|
|
|
|
"servers/:id": "server",
|
|
|
|
"": "home",
|
|
|
|
},
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
initialize: function () {
|
2017-10-05 20:55:57 +00:00
|
|
|
layoutView.navigation.show(new NavigationView({settings: settings, servers: servers}));
|
2014-06-04 22:19:54 +00:00
|
|
|
|
2015-08-23 22:45:35 +00:00
|
|
|
var initialized = false;
|
|
|
|
|
2014-06-08 12:29:38 +00:00
|
|
|
var socket = io.connect();
|
2018-08-18 11:04:33 +00:00
|
|
|
socket.on('missions', function (_missions) {
|
|
|
|
missions.set(_missions);
|
|
|
|
});
|
2015-02-01 04:27:12 +00:00
|
|
|
socket.on('mods', function (_mods) {
|
2017-10-05 20:55:57 +00:00
|
|
|
mods.set(_mods);
|
2015-02-01 04:27:12 +00:00
|
|
|
});
|
2014-06-04 22:19:54 +00:00
|
|
|
socket.on('servers', function (_servers) {
|
2017-10-05 20:55:57 +00:00
|
|
|
servers.set(_servers);
|
2015-08-23 22:45:35 +00:00
|
|
|
|
|
|
|
if (!initialized) {
|
|
|
|
initialized = true;
|
|
|
|
Backbone.history.start();
|
|
|
|
}
|
2014-06-04 22:19:54 +00:00
|
|
|
});
|
2018-08-18 10:31:41 +00:00
|
|
|
socket.on('settings', function (_settings) {
|
|
|
|
settings.set(_settings);
|
|
|
|
});
|
2014-02-09 03:19:48 +00:00
|
|
|
},
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
home: function () {
|
2015-04-17 17:56:47 +00:00
|
|
|
layoutView.content.show(new ServersView({collection: servers}));
|
2014-02-09 03:19:48 +00:00
|
|
|
},
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2014-09-28 08:50:03 +00:00
|
|
|
logs: function () {
|
|
|
|
var logs = new Logs();
|
|
|
|
logs.fetch();
|
|
|
|
layoutView.content.show(new LogsListView({collection: logs}));
|
|
|
|
},
|
|
|
|
|
2014-04-04 09:28:33 +00:00
|
|
|
missions: function () {
|
2015-04-17 17:56:47 +00:00
|
|
|
layoutView.content.show(new MissionsView({missions: missions}));
|
2014-04-04 09:28:33 +00:00
|
|
|
},
|
2014-04-06 22:35:04 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
mods: function () {
|
2015-04-17 17:56:47 +00:00
|
|
|
layoutView.content.show(new ModsListView({collection: mods}));
|
2014-02-09 03:19:48 +00:00
|
|
|
},
|
2014-04-06 21:09:52 +00:00
|
|
|
|
|
|
|
server: function (id) {
|
2014-04-06 22:35:04 +00:00
|
|
|
var server = servers.get(id);
|
|
|
|
if (server) {
|
2015-08-23 22:16:16 +00:00
|
|
|
layoutView.content.show(new ServerView({
|
|
|
|
model: server,
|
|
|
|
missions: missions,
|
|
|
|
mods: mods,
|
|
|
|
}));
|
2014-04-06 22:35:04 +00:00
|
|
|
} else {
|
2015-04-17 17:56:47 +00:00
|
|
|
this.navigate("#", true);
|
2014-04-06 22:35:04 +00:00
|
|
|
}
|
2014-02-09 03:19:48 +00:00
|
|
|
}
|
2014-04-06 21:09:52 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
});
|
2014-04-06 21:09:52 +00:00
|
|
|
|
|
|
|
});
|