Files
2024-10-25 14:16:28 +02:00

68 lines
1.9 KiB
JavaScript

var TOKEN = document.location.href.split('&token=')[1].split('&')[0].replace('#', '');
$(function () {
$(document).on('click', '.copy-config-btn', function () {
id = $(this).attr('id');
txt = $('#' + id + '-txt').html();
fancyMsgBox(txt);
});
$(document).on('click', 'a.showLoader', function () {
$('.full-screen-loader').fadeIn();
$('.bootstrap#footer').hide();
});
$(document).on('click', 'a.uploadConfigFile', function (e) {
e.preventDefault();
var form = '<form method="post" action="' + $(this).attr('href') + '" enctype="multipart/form-data">';
form += '<p><label for="file">Select .yml file:</label></p>';
form += '<p><input type="file" name="file" id="form-control" accept=".yml"></p>';
form += '<p><input type="submit" class="btn btn-default" value="Upload"></p>';
form += '</form>';
fancyMsgBox(form, 'Upload configuration file');
return false;
});
$(document).on('click', 'a.ajaxClearLog', function (e) {
e.preventDefault();
var filename = $(this).attr('data-filename');
$.ajax({
url: 'ajax-tab.php',
dataType: 'json',
method: 'POST',
data: 'token=' + TOKEN + '&controller=PShowImporterMain&filename=' + filename + '&clearLog=1'
}).done(function (result) {
console.log(result);
if (result === 'ok') {
showSuccessMessage('Log cleared.');
} else {
showErrorMessage(result);
}
});
return false;
});
updateUploadAuthInfo();
$(document).on('change', 'input[name="auth_req"]', function () {
updateUploadAuthInfo();
});
});
function updateUploadAuthInfo() {
if ($('input[name="auth_req"]:checked').val() === '1') {
$('.form-upload-auth').show("slow");
} else {
$('.form-upload-auth').hide("slow");
}
}