IW4M-Admin/WebfrontCore/wwwroot/js/console.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-02-23 02:06:13 -05:00
function executeCommand() {
const serverId = $('#console_server_select').val();
const command = $('#console_command_value').val();
if (command.length === 0) {
return false;
}
if (command[0] !== '!') {
$('#console_command_response').text(_localization['WEBFRONT_CONSOLE_COMMAND']).addClass('text-danger');
return false;
}
showLoader();
2018-02-23 02:06:13 -05:00
$.get('/Console/ExecuteAsync', { serverId: serverId, command: command })
.done(function (response) {
hideLoader();
$('#console_command_response').append(response);
2018-02-23 02:06:13 -05:00
$('#console_command_value').val("");
})
.fail(function (jqxhr, textStatus, error) {
errorLoader();
hideLoader();
$('#console_command_response').text(_localization['WEBFRONT_CONSOLE_ERROR'] + error).addClass('text-danger');
2018-02-23 02:06:13 -05:00
});
}
$(document).ready(function () {
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;
2018-02-23 02:06:13 -05:00
if (keyCode === 13) {
executeCommand();
}
});
});