forked from rebillar/site-accueil-insa
80 lines
2.1 KiB
JavaScript
80 lines
2.1 KiB
JavaScript
|
|
$(document).ready(function () {
|
|
getMapInfo(getSelectedMap());
|
|
$(".save.getMapInfo").click(function () {
|
|
let info = {};
|
|
info['title'] = $('.mapEdition #titleInput').val();
|
|
info['description'] = $('.mapEdition #descriptionInput').val();
|
|
let object = {
|
|
"function": 'save_map_info',
|
|
'selector': getSelectedMap(),
|
|
'info': info,
|
|
};
|
|
$.get(
|
|
"ajax.php",
|
|
object,
|
|
function (data) {
|
|
//console.log(data);
|
|
alert(data);
|
|
}
|
|
);
|
|
});
|
|
$(".addBuilding").click(function () {
|
|
let info = {};
|
|
info['title'] = $('.buildingManager #titleInput').val();
|
|
info['description'] = $('.buildingManager #descriptionInput').val();
|
|
info['selector'] = $('.buildingManager #selectorInput').val();
|
|
let object = {
|
|
"function": 'create_building',
|
|
'info': info,
|
|
};
|
|
//alert(JSON.stringify(object));
|
|
$.post(
|
|
"ajax.php",
|
|
object,
|
|
function (data) {
|
|
alert(data);
|
|
}
|
|
);
|
|
});
|
|
$(".mapEdition .delete").click(function() {
|
|
let info = {};
|
|
info['selector'] = getSelectedMap();
|
|
let object = {
|
|
"function": 'delete_building',
|
|
'info': info,
|
|
};
|
|
//alert(JSON.stringify(object));
|
|
|
|
$.post(
|
|
"ajax.php",
|
|
object,
|
|
function (data) {
|
|
alert(data);
|
|
}
|
|
);
|
|
});
|
|
$('#mapSelect').on('change', function () {
|
|
getMapInfo(getSelectedMap());
|
|
});
|
|
});
|
|
|
|
function getSelectedMap() {
|
|
return $('#mapSelect').val();
|
|
}
|
|
|
|
function getMapInfo(selector) {
|
|
let object = {
|
|
"function": 'get_map_info',
|
|
'selector': selector,
|
|
};
|
|
$.get(
|
|
"../../ajax/read",
|
|
object,
|
|
function (data) {
|
|
console.log(data);
|
|
$('#titleInput').val(data[0]['title']);
|
|
$('#descriptionInput').val(data[0]['description']);
|
|
}
|
|
);
|
|
}
|