67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
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;
|
|
}
|
|
|
|
function dropdown(i,e) {
|
|
document.getElementById(i).innerHTML = e;
|
|
document.getElementById(i +'h').value = e;
|
|
}
|
|
|
|
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);
|
|
var vmname = $(this).data('deleteName');
|
|
var vmid = $(this).data('deleteVm');
|
|
post('?', {deletevm: vmid,deletename: vmname});
|
|
});
|
|
$('#confirm-delete').on('show.bs.modal', function(e) {
|
|
var data = $(e.relatedTarget).data();
|
|
$('.title', this).text(data.deleteVm);
|
|
document.getElementById('modaltext2').innerHTML = data.deleteText;
|
|
$('.btn-ok', this).data({'deleteName': data.deleteName,'deleteVm': data.deleteVm});
|
|
});
|
|
|
|
function submitbutton(formid){
|
|
console.log(formid);
|
|
data = $('#'+ formid).serialize();
|
|
console.log(data);
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: "?rand="+ makeid(),
|
|
data: data,
|
|
success: function(response) {
|
|
if (response != "success"){
|
|
window.alert('Failure!\n'+ response);
|
|
} else {
|
|
window.location.href = "";
|
|
}
|
|
},
|
|
});
|
|
}
|