web/public/js/edit_server.js
Corne Oppelaar ebddf2f031 [wip]
2016-06-12 19:48:33 +02:00

48 lines
No EOL
1.2 KiB
JavaScript

$(function () {
var error = $('<div class="alert alert-danger" role="alert"></div>');
$('.save').click(function () {
save(function(){});
});
$('.save-and-sign').click(function () {
save(function () {
sign();
})
});
function save(callback) {
var fingerprint = $('.server-form').data('fingerprint');
var data = $('.server-form input,.server-form select').serializeArray();
$.post('/panel/server/' + fingerprint, data, function (data) {
console.log(data);
if (!data.success) {
$('h2').after(error.text(data.error));
return;
}
callback();
}, 'json');
}
function sign() {
var fingerprint = $('.server-form').data('fingerprint');
$.post(
'/panel/server/sign',
{
fingerprint: fingerprint
},
function (data) {
if (!data.success) {
$('h2').after(error.text(data.error));
return;
}
location.reload();
},
'json'
);
}
});