Compare commits

...

1 Commits

Author SHA1 Message Date
7c96ba24d6 MAPG-146 [WIP] 2020-06-14 22:10:36 +02:00

View File

@ -13,6 +13,7 @@
added: {}, added: {},
edited: {}, edited: {},
deleted: {}, deleted: {},
saved: true,
editMetadata: function () { editMetadata: function () {
var form = document.getElementById('metadataForm'); var form = document.getElementById('metadataForm');
@ -24,6 +25,7 @@
MapGuesser.hideModal(); MapGuesser.hideModal();
MapEditor.saved = false;
document.getElementById('saveButton').disabled = false; document.getElementById('saveButton').disabled = false;
}, },
@ -210,6 +212,7 @@
MapEditor.selectedMarker.setLatLng({ lat: places[placeId].lat, lng: places[placeId].lng }); MapEditor.selectedMarker.setLatLng({ lat: places[placeId].lat, lng: places[placeId].lng });
MapEditor.saved = false;
document.getElementById('saveButton').disabled = false; document.getElementById('saveButton').disabled = false;
}, },
@ -243,6 +246,7 @@
document.getElementById('added').innerHTML = String(Object.keys(MapEditor.added).length); document.getElementById('added').innerHTML = String(Object.keys(MapEditor.added).length);
document.getElementById('edited').innerHTML = String(Object.keys(MapEditor.edited).length); document.getElementById('edited').innerHTML = String(Object.keys(MapEditor.edited).length);
MapEditor.saved = false;
document.getElementById('saveButton').disabled = false; document.getElementById('saveButton').disabled = false;
}, },
@ -300,6 +304,7 @@
document.getElementById('edited').innerHTML = '0'; document.getElementById('edited').innerHTML = '0';
document.getElementById('deleted').innerHTML = '0'; document.getElementById('deleted').innerHTML = '0';
MapEditor.saved = true;
document.getElementById('saveButton').disabled = true; document.getElementById('saveButton').disabled = true;
}, data); }, data);
}, },
@ -440,4 +445,13 @@
document.getElementById('deleteButton').onclick = function () { document.getElementById('deleteButton').onclick = function () {
MapEditor.deletePlace(); MapEditor.deletePlace();
}; };
window.addEventListener('beforeunload', function (e) {
if (MapEditor.saved) {
return;
}
e.preventDefault();
e.returnValue = '';
});
})(); })();