2014-02-09 03:19:48 +00:00
|
|
|
define(function (require) {
|
2014-04-06 21:03:44 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
"use strict";
|
2014-04-06 21:03:44 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
var $ = require('jquery'),
|
|
|
|
_ = require('underscore'),
|
|
|
|
Backbone = require('backbone'),
|
|
|
|
Marionette = require('marionette'),
|
2014-09-12 23:51:31 +00:00
|
|
|
tpl = require('text!tpl/servers/form.html');
|
2014-04-06 21:03:44 +00:00
|
|
|
|
2014-02-09 03:19:48 +00:00
|
|
|
return Marionette.ItemView.extend({
|
|
|
|
template: _.template(tpl),
|
2014-04-06 21:03:44 +00:00
|
|
|
|
2014-02-14 01:16:05 +00:00
|
|
|
initialize: function (options) {
|
|
|
|
this.servers = options.servers;
|
|
|
|
this.bind("ok", this.submit);
|
|
|
|
},
|
2014-04-06 21:03:44 +00:00
|
|
|
|
2014-09-12 23:51:31 +00:00
|
|
|
serialize : function() {
|
|
|
|
return {
|
|
|
|
admin_password: this.$("form .admin-password").val(),
|
2017-10-01 14:58:30 +00:00
|
|
|
allowed_file_patching: this.$("form .allowed-file-patching").prop("checked") ? 2 : 1,
|
2017-02-20 08:44:07 +00:00
|
|
|
auto_start: this.$("form .auto-start").prop("checked"),
|
2014-09-12 23:51:31 +00:00
|
|
|
battle_eye: this.$("form .battle-eye").prop("checked"),
|
2017-10-01 14:58:30 +00:00
|
|
|
file_patching: this.$("form .file-patching").prop("checked"),
|
2017-09-30 19:49:42 +00:00
|
|
|
forcedDifficulty: this.$("form .forcedDifficulty").val(),
|
2014-09-12 23:51:31 +00:00
|
|
|
max_players: this.$("form .max-players").val(),
|
2017-09-30 19:49:42 +00:00
|
|
|
motd: this.$("form .motd").val(),
|
2017-09-11 09:28:47 +00:00
|
|
|
number_of_headless_clients: this.$("form .headless-clients").val(),
|
2014-09-12 23:51:31 +00:00
|
|
|
password: this.$("form .password").val(),
|
|
|
|
persistent: this.$("form .persistent").prop("checked"),
|
2015-01-16 22:09:53 +00:00
|
|
|
port: this.$("form .port").val(),
|
2014-09-12 23:51:31 +00:00
|
|
|
title: this.$("form .title").val(),
|
|
|
|
von: this.$("form .von").prop("checked"),
|
2017-08-07 03:15:25 +00:00
|
|
|
verify_signatures: this.$("form .verify_signatures").prop("checked"),
|
2014-09-12 23:51:31 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2014-02-14 01:16:05 +00:00
|
|
|
submit: function (modal) {
|
|
|
|
modal.preventClose();
|
2014-04-06 21:03:44 +00:00
|
|
|
|
2014-09-12 23:51:31 +00:00
|
|
|
this.model.set(this.serialize());
|
2014-04-06 21:03:44 +00:00
|
|
|
|
2014-02-14 01:16:05 +00:00
|
|
|
var self = this;
|
2014-04-06 21:03:44 +00:00
|
|
|
|
2014-02-14 01:16:05 +00:00
|
|
|
this.model.save({}, {
|
|
|
|
success: function() {
|
|
|
|
modal.close();
|
2014-04-06 21:03:44 +00:00
|
|
|
self.servers.fetch({success : function () {
|
|
|
|
Backbone.history.navigate('#servers/' + self.model.get('id'), true);
|
|
|
|
}});
|
2014-02-14 01:16:05 +00:00
|
|
|
},
|
|
|
|
error: function() {
|
|
|
|
alert("Error :(");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-02-09 03:19:48 +00:00
|
|
|
});
|
2014-04-06 21:03:44 +00:00
|
|
|
|
|
|
|
});
|