arma-server-web-admin/public/js/app/views/servers/info.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-04-04 08:20:13 +00:00
define(function (require) {
2014-04-06 21:09:52 +00:00
2014-04-04 08:20:13 +00:00
"use strict";
2014-04-06 21:09:52 +00:00
2014-04-04 08:20:13 +00:00
var $ = require('jquery'),
_ = require('underscore'),
Backbone = require('backbone'),
Marionette = require('marionette'),
2014-04-08 21:49:40 +00:00
GamespyView = require('app/views/servers/gamespy'),
2014-04-06 21:09:52 +00:00
tpl = require('text!tpl/servers/info.html');
2014-04-08 21:49:40 +00:00
return Marionette.Layout.extend({
2014-04-04 08:20:13 +00:00
template: _.template(tpl),
2014-04-06 21:09:52 +00:00
2014-04-08 21:49:40 +00:00
regions: {
gamespyView: "#gamespy",
},
2014-04-06 21:09:52 +00:00
events: {
2014-04-06 22:58:17 +00:00
"click #start": "start",
"click #stop": "stop",
2014-04-06 21:09:52 +00:00
},
2014-04-08 21:49:40 +00:00
onRender: function() {
this.gamespyView.show(new GamespyView({server: this.model}));
},
2014-04-06 21:09:52 +00:00
start: function (event) {
var self = this;
event.preventDefault();
$.ajax({
url: "/api/servers/" + this.model.get('id') + "/start",
type: 'GET',
success: function (resp) {
2014-04-06 22:58:17 +00:00
self.model.set("pid", resp.pid);
self.render();
},
error: $.noop
});
},
stop: function (event) {
var self = this;
event.preventDefault();
$.ajax({
url: "/api/servers/" + this.model.get('id') + "/stop",
type: 'GET',
success: function (resp) {
self.model.set("pid", resp.pid);
self.render();
2014-04-06 21:09:52 +00:00
},
error: $.noop
});
},
2014-04-04 08:20:13 +00:00
});
2014-04-06 21:09:52 +00:00
});