diff --git a/public/js/app.js b/public/js/app.js index 2684e1c..d35f9d0 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -111,7 +111,7 @@ L.control.scale({ L.control.fullscreen({ position: 'topright', title: 'Vollbild', - titleCancel: 'Vollbild beenden' + titleCancel: 'Vollbild deaktivieren' }).addTo(map); // Geocoder Address Search @@ -242,11 +242,11 @@ map.pm.addControls({ rotateMode: false }); -// When a Shape is drawn, capture the Geometry and open the Create Modal +// Captures drawn Geometry and opens the Create Modal map.on('pm:create', function (e) { var geojson = e.layer.toGeoJSON().geometry; - // Determine Geometry Type and normalize to simple Types + // Determines drawn Geometry Type and normalizes to simple Types if (e.shape === 'Marker') { drawnGeometry = { type: 'Point', coordinates: geojson.coordinates }; drawnGeomType = 'point'; @@ -257,22 +257,22 @@ map.on('pm:create', function (e) { drawnGeometry = { type: 'Polygon', coordinates: geojson.coordinates }; drawnGeomType = 'polygon'; } else { - // Unsupported Shape — remove from Map and exit + // removes unsupported Objects map.removeLayer(e.layer); return; } - // Remove the drawn Layer — it will be re-added after API Confirmation + // Removes the drawn Layer, which will be re-added after Moderation Confirmation map.removeLayer(e.layer); - // Check if User is logged in + // Checks if User is logged in if (!currentUser) { - Swal.fire('Bitte anmelden', 'Sie müssen sich anmelden, um Beiträge zu erstellen.', 'info'); + Swal.fire('Bitte anmelden', 'Sie sollten sich anmelden, um Beiträge hinzuzufügen oder zu bearbeiten.', 'info'); showLoginModal(); return; } - // Populate hidden Fields and open Create Modal + // Populates hidden Fields and opens Create Modal document.getElementById('create-geom').value = JSON.stringify(drawnGeometry); document.getElementById('create-geom-type').value = drawnGeomType; document.getElementById('create-modal').style.display = 'flex'; @@ -302,11 +302,11 @@ function apiCall(data, callback) { }) .catch(function (error) { console.error('API Error:', error); - Swal.fire('Verbindungsfehler', 'Die Verbindung zum Server ist fehlgeschlagen.', 'error'); + Swal.fire('Verbindungsfehler', 'Verbindung zum Server fehlgeschlagen.', 'error'); }); } -// Load all Contributions from API and display on Map +// Loads all Contributions from API and displays Contributions on Map function loadContributions() { apiCall({ action: 'read', municipality_id: MUNICIPALITY.id }, function (data) { if (data.error) { @@ -316,13 +316,13 @@ function loadContributions() { contributionsData = data.features || []; - // Remove existing Layer if present + // Removes existing Layer if present if (contributionsLayer) { map.removeLayer(contributionsLayer); layerControl.removeLayer(contributionsLayer); } - // Create new GeoJSON Layer + // Creates new GeoJSON Layer contributionsLayer = L.geoJSON(data, { pointToLayer: stylePoint, style: styleLinePolygon, @@ -370,20 +370,20 @@ function styleLinePolygon(feature) { // ===================================================================== -// Block 9: Feature Popups (Read, Vote, Edit, Delete) +// Block 9: Feature Popups for Read, Edit, Delete and Vote // ===================================================================== function bindFeaturePopup(feature, layer) { var props = feature.properties; var cat = CATEGORIES[props.category] || CATEGORIES.other; - // Format Date + // Formats Date var date = new Date(props.created_at); var dateStr = date.toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric' }); - // Build Popup HTML + // Builds Popup on Click var html = '' + '