nlvmi/web/nlvmi.js

76 lines
2.3 KiB
JavaScript
Raw Normal View History

2018-08-15 13:50:00 +02:00
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 5; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
2018-08-12 15:09:47 +02:00
function dropdown(i,e) {
document.getElementById(i).innerHTML = e;
document.getElementById(i +'h').value = e;
if (i == "serverbutton") {
2018-08-21 14:25:19 +02:00
$.ajax({
type: 'POST',
url: "?rand="+ makeid(),
data: "serverbuttoni="+ e,
success: function(response) {
document.getElementById('drivesdiv').innerHTML = response;
},
});
}
2018-08-12 15:09:47 +02:00
}
2018-08-13 16:49:49 +02:00
function post(path, params, method) {
method = method || "post";
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
$('#confirm-delete').on('click', '.btn-ok', function(e) {
var $modalDiv = $('#confirm-detele'.delegateTarget);
2018-08-21 14:00:09 +02:00
var dname = $(this).data('deleteName');
var did = $(this).data('deleteId');
var delwhat = $(this).data('deleteWhat');
post('?', {delwhat: delwhat,deleteid: did,deletename: dname});
2018-08-13 16:49:49 +02:00
});
$('#confirm-delete').on('show.bs.modal', function(e) {
var data = $(e.relatedTarget).data();
$('.title', this).text(data.deleteVm);
document.getElementById('modaltext2').innerHTML = data.deleteText;
2018-08-21 14:00:09 +02:00
$('.btn-ok', this).data({'deleteWhat': data.deleteWhat,'deleteName': data.deleteName,'deleteId': data.deleteId});
2018-08-13 16:49:49 +02:00
});
2018-08-15 13:50:00 +02:00
function submitbutton(formid){
data = $('#'+ formid).serialize();
$.ajax({
type: 'POST',
url: "?rand="+ makeid(),
data: data,
success: function(response) {
if (response != "success"){
window.alert('Failure!\n'+ response);
} else {
window.location.href = "";
}
},
});
}