2018-02-23 02:06:13 -05:00
|
|
|
|
function executeCommand() {
|
|
|
|
|
const serverId = $('#console_server_select').val();
|
|
|
|
|
const command = $('#console_command_value').val();
|
2018-02-24 00:56:03 -05:00
|
|
|
|
|
|
|
|
|
if (command.length === 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (command[0] !== '!') {
|
|
|
|
|
$('#console_command_response').text('All commands must start with !').addClass('text-danger');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-04-09 23:33:42 -04:00
|
|
|
|
showLoader();
|
2018-02-23 02:06:13 -05:00
|
|
|
|
$.get('/Console/ExecuteAsync', { serverId: serverId, command: command })
|
|
|
|
|
.done(function (response) {
|
2018-04-09 23:33:42 -04:00
|
|
|
|
hideLoader();
|
2018-09-02 17:59:27 -04:00
|
|
|
|
$('#console_command_response').append(response);
|
2018-02-23 02:06:13 -05:00
|
|
|
|
$('#console_command_value').val("");
|
|
|
|
|
})
|
|
|
|
|
.fail(function (jqxhr, textStatus, error) {
|
2018-04-09 23:33:42 -04:00
|
|
|
|
errorLoader();
|
|
|
|
|
hideLoader();
|
2018-02-23 02:06:13 -05:00
|
|
|
|
$('#console_command_response').text('Could not execute command: ' + error).addClass('text-danger');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
2018-04-19 01:48:14 -04:00
|
|
|
|
|
|
|
|
|
if ($('#console_command_button').length === 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-23 02:06:13 -05:00
|
|
|
|
$('#console_command_button').click(function (e) {
|
|
|
|
|
executeCommand();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(document).keydown(function (event) {
|
|
|
|
|
const keyCode = (event.keyCode ? event.keyCode : event.which);
|
|
|
|
|
if (keyCode === 13) {
|
|
|
|
|
executeCommand();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|