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

61 lines
1.9 KiB
JavaScript
Raw Normal View History

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'),
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
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,
auto_start: this.$("form .auto-start").prop("checked"),
battle_eye: this.$("form .battle-eye").prop("checked"),
2017-10-01 14:58:30 +00:00
file_patching: this.$("form .file-patching").prop("checked"),
forcedDifficulty: this.$("form .forcedDifficulty").val(),
max_players: this.$("form .max-players").val(),
motd: this.$("form .motd").val(),
number_of_headless_clients: this.$("form .headless-clients").val(),
password: this.$("form .password").val(),
persistent: this.$("form .persistent").prop("checked"),
port: this.$("form .port").val(),
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-02-14 01:16:05 +00:00
submit: function (modal) {
modal.preventClose();
2014-04-06 21:03:44 +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
});