2019-03-30 23:04:15 -04:00
|
|
|
|
$(document).ready(function() {
|
2020-01-17 18:31:53 -05:00
|
|
|
|
$.each($('.has-related-content'), function(key, value) {
|
2019-03-30 23:04:15 -04:00
|
|
|
|
value = $(value);
|
2019-04-11 21:43:05 -04:00
|
|
|
|
if (value.attr('checked') !== undefined && value.attr('checked').length > 0) {
|
2019-03-30 23:04:15 -04:00
|
|
|
|
$(value.data('related-content')).slideDown();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-17 18:31:53 -05:00
|
|
|
|
$('input:checkbox').change(function() {
|
2019-03-30 23:04:15 -04:00
|
|
|
|
var isChecked = $(this).is(':checked');
|
|
|
|
|
isChecked ? $($(this).data('related-content')).slideDown() : $($(this).data('related-content')).slideUp();
|
|
|
|
|
});
|
2019-04-11 21:43:05 -04:00
|
|
|
|
|
2020-01-17 18:31:53 -05:00
|
|
|
|
// this is used for regular simple form adds
|
|
|
|
|
$(document).on('click', '.configuration-add-new', function(e) {
|
2019-04-11 21:43:05 -04:00
|
|
|
|
e.preventDefault();
|
2020-01-17 18:31:53 -05:00
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
let parentElement = $(this).parent();
|
2020-01-17 18:31:53 -05:00
|
|
|
|
let label = $(this).siblings('label');
|
|
|
|
|
let forAttr = $(label).attr('for');
|
|
|
|
|
let match = /Servers_+([0-9+])_+.*/g.exec(forAttr);
|
|
|
|
|
let additionalData = '';
|
|
|
|
|
if (match !== null && match.length === 2) {
|
|
|
|
|
additionalData = '&serverIndex=' + match[1].toString();
|
|
|
|
|
}
|
2019-04-11 21:43:05 -04:00
|
|
|
|
|
2020-01-17 18:31:53 -05:00
|
|
|
|
$.get($(this).attr('href') + '&itemCount=' + $(this).siblings('input').length.toString() + additionalData, function (response) {
|
2019-04-14 11:55:05 -04:00
|
|
|
|
$(response).insertBefore(parentElement.children().last());
|
2019-04-11 21:43:05 -04:00
|
|
|
|
});
|
|
|
|
|
});
|
2020-01-17 18:31:53 -05:00
|
|
|
|
|
|
|
|
|
// this is used for server adds which are little more complex
|
|
|
|
|
$(document).on('click', '.configuration-server-add-new', function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
let parentElement = $(this).parent();
|
|
|
|
|
|
|
|
|
|
$.get($(this).attr('href') + '&itemCount=' + $('.server-configuration-header').length.toString(), function (response) {
|
|
|
|
|
$(response).insertBefore(parentElement.children().last());
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// removes the server when clicking the delete button
|
|
|
|
|
$(document).on('click', '.delete-server-button', function (e) {
|
|
|
|
|
$(this).parents('.server-configuration-header').remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#configurationForm').submit(function (e) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
data: $(this).serialize(),
|
|
|
|
|
type: $(this).attr('method'),
|
|
|
|
|
url: $(this).attr('action'),
|
|
|
|
|
complete: function(response) {
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
$('#actionModal .modal-message').removeClass('text-danger');
|
|
|
|
|
$('#actionModal').data('should-refresh', true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$('#actionModal .modal-message').addClass('text-danger');
|
|
|
|
|
}
|
|
|
|
|
$('#actionModal .modal-body-content').html('');
|
|
|
|
|
let errors = '';
|
|
|
|
|
|
|
|
|
|
if (response.responseJSON.errors !== undefined) {
|
|
|
|
|
errors = response.responseJSON.errors[0].join('<br/>');
|
|
|
|
|
}
|
|
|
|
|
message = response.responseJSON.message;
|
|
|
|
|
$('#actionModal .modal-message').html(message + '<br/>' + errors);
|
|
|
|
|
$('#actionModal').modal();
|
|
|
|
|
$('#actionModal .modal-message').fadeIn('fast');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
2021-11-02 19:02:04 -04:00
|
|
|
|
|
2021-09-16 17:27:40 -04:00
|
|
|
|
$('.edit-file' ).on('keydown .editable', function(e){
|
|
|
|
|
if(e.keyCode === 9) {
|
|
|
|
|
document.execCommand ( 'styleWithCSS', true, null )
|
|
|
|
|
document.execCommand ( 'insertText', true, ' ' )
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.expand-file-icon').click((e) => {
|
|
|
|
|
const selector = $(e.target).data('editor-id');
|
|
|
|
|
$(selector).toggleClass('d-none').toggleClass('d-flex');
|
|
|
|
|
$(e.target).toggleClass('oi-expand-up', 'oi-expand-down');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.file-save-button').click(e => {
|
|
|
|
|
const id = $(e.target).prev().find('.editable').attr('id');
|
|
|
|
|
const content = document.getElementById(id).textContent;
|
|
|
|
|
const file = $(e.target).data('file-name');
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
data: content,
|
|
|
|
|
type: 'PATCH',
|
|
|
|
|
url: 'File/' + file,
|
|
|
|
|
contentType: 'text/plain',
|
|
|
|
|
complete: function(response) {
|
|
|
|
|
if (response.status !== 204) {
|
|
|
|
|
$('#actionModal').modal();
|
|
|
|
|
$('#actionModal .modal-message').text(response.responseText);
|
|
|
|
|
$('#actionModal .modal-message').addClass('text-danger');
|
|
|
|
|
$('#actionModal .modal-message').fadeIn('fast');
|
|
|
|
|
$(e.target).toggleClass('btn-danger');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(e.target).removeClass('btn-danger')
|
|
|
|
|
$(e.target).toggleClass('btn-success')
|
|
|
|
|
window.setTimeout(function() {
|
|
|
|
|
$(e.target).toggleClass('btn-success');
|
|
|
|
|
}, 500);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|