Files
GOV_QR_Codes_Management/templates/edit_qr_code.html
T
2025-08-16 10:25:25 -04:00

1090 lines
36 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Edit QR Code - QR Management System</title>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
rel="stylesheet"
/>
<style>
:root {
--primary-color: #2563eb;
--secondary-color: #64748b;
--success-color: #10b981;
--warning-color: #f59e0b;
--error-color: #ef4444;
--gray-50: #f8fafc;
--gray-100: #f1f5f9;
--gray-200: #e2e8f0;
--gray-300: #cbd5e1;
--gray-500: #64748b;
--gray-600: #475569;
--gray-700: #334155;
--gray-800: #1e293b;
--gray-900: #0f172a;
--white: #ffffff;
--radius-lg: 8px;
--radius-xl: 12px;
--radius-2xl: 16px;
--shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1),
0 1px 2px 0 rgba(0, 0, 0, 0.06);
--transition: all 0.2s ease-in-out;
--font-size-base: 1rem;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
sans-serif;
background: linear-gradient(
135deg,
var(--gray-50) 0%,
var(--gray-100) 100%
);
color: var(--gray-800);
line-height: 1.6;
min-height: 100vh;
padding: 2rem 1rem;
}
.container {
max-width: 1000px;
margin: 0 auto;
}
.main-content {
display: grid;
grid-template-columns: 1fr 300px;
gap: 2rem;
margin-bottom: 2rem;
}
.form-container {
background: var(--white);
border-radius: var(--radius-2xl);
box-shadow: var(--shadow);
padding: 2rem;
}
.current-info-panel {
background: var(--white);
border-radius: var(--radius-2xl);
box-shadow: var(--shadow);
padding: 1.5rem;
height: fit-content;
position: sticky;
top: 2rem;
}
.form-header {
text-align: center;
margin-bottom: 2rem;
padding-bottom: 1.5rem;
border-bottom: 1px solid var(--gray-200);
}
.form-header h1 {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
font-size: 2rem;
font-weight: 700;
color: var(--gray-900);
margin-bottom: 0.5rem;
}
.form-header p {
color: var(--gray-500);
font-size: 1rem;
}
.current-info-header {
text-align: center;
margin-bottom: 1.5rem;
padding-bottom: 1rem;
border-bottom: 1px solid var(--gray-200);
}
.current-info-header h3 {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
font-size: 1.25rem;
font-weight: 600;
color: var(--gray-800);
margin-bottom: 0.5rem;
}
.current-info-content {
display: flex;
flex-direction: column;
gap: 1rem;
}
.detail-row {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.detail-row strong {
font-size: 0.875rem;
color: var(--gray-600);
font-weight: 500;
}
.detail-row span {
font-size: 0.9rem;
color: var(--gray-800);
word-break: break-word;
}
.coordinate-info {
background: var(--primary-color);
color: white;
padding: 1rem;
border-radius: var(--radius-lg);
text-align: center;
}
.coordinate-value {
font-family: "Courier New", monospace;
font-size: 1rem;
font-weight: 600;
margin-bottom: 0.25rem;
}
.coordinate-label {
font-size: 0.75rem;
opacity: 0.8;
}
.no-coordinates {
background: var(--gray-100);
color: var(--gray-600);
padding: 1rem;
border-radius: var(--radius-lg);
text-align: center;
font-size: 0.875rem;
}
.form-section {
margin-bottom: 2rem;
padding: 1.5rem;
background: var(--gray-50);
border-radius: var(--radius-xl);
border: 1px solid var(--gray-200);
}
.section-header {
margin-bottom: 1.5rem;
padding-bottom: 1rem;
border-bottom: 1px solid var(--gray-200);
}
.section-header h3 {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 1.25rem;
font-weight: 600;
color: var(--gray-800);
margin-bottom: 0.5rem;
}
.section-header p {
color: var(--gray-600);
font-size: 0.875rem;
}
.form-group {
position: relative;
margin-bottom: 1.5rem;
}
.form-group label {
display: flex;
align-items: center;
gap: 0.5rem;
font-weight: 600;
color: var(--gray-700);
margin-bottom: 0.5rem;
font-size: 0.875rem;
}
.form-group input,
.form-group select,
.form-group textarea {
width: 100%;
padding: 0.75rem;
border: 2px solid var(--gray-200);
border-radius: var(--radius-lg);
font-size: var(--font-size-base);
transition: var(--transition);
background-color: var(--white);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group textarea {
resize: vertical;
min-height: 80px;
}
.form-help {
display: block;
margin-top: 0.5rem;
font-size: 0.75rem;
color: var(--gray-500);
}
.character-counter {
position: absolute;
bottom: -1.5rem;
right: 0;
font-size: 0.75rem;
color: var(--gray-500);
}
.character-counter.warning {
color: var(--warning-color);
}
.coordinates-section {
background: var(--primary-color);
color: white;
border-radius: var(--radius-xl);
padding: 1.5rem;
margin-top: 1rem;
}
.coordinates-header {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 1rem;
}
.coordinates-header h4 {
font-size: 1.125rem;
font-weight: 600;
}
.coordinates-content {
display: flex;
flex-direction: column;
gap: 1rem;
}
.coordinate-display {
background: rgba(255, 255, 255, 0.1);
padding: 1rem;
border-radius: var(--radius-lg);
display: flex;
align-items: center;
justify-content: space-between;
}
.coordinate-display .coordinate-info {
background: transparent;
padding: 0;
color: inherit;
text-align: left;
}
.coordinate-display .coordinate-info .coordinate-value {
font-family: "Courier New", monospace;
font-size: 1.125rem;
font-weight: 600;
}
.coordinate-display .coordinate-info .coordinate-label {
font-size: 0.875rem;
opacity: 0.8;
}
.coordinates-actions {
display: flex;
gap: 0.75rem;
margin-top: 1rem;
}
.btn-coordinate {
padding: 0.5rem 1rem;
background: rgba(255, 255, 255, 0.2);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: var(--radius-lg);
color: white;
font-size: 0.875rem;
cursor: pointer;
transition: var(--transition);
}
.btn-coordinate:hover {
background: rgba(255, 255, 255, 0.3);
}
.btn-coordinate:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.loading-spinner {
display: inline-block;
width: 1rem;
height: 1rem;
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.status-message {
padding: 0.75rem;
border-radius: var(--radius-lg);
margin-top: 1rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.status-success {
background: rgba(16, 185, 129, 0.1);
color: var(--success-color);
border: 1px solid rgba(16, 185, 129, 0.2);
}
.status-error {
background: rgba(239, 68, 68, 0.1);
color: var(--error-color);
border: 1px solid rgba(239, 68, 68, 0.2);
}
.status-warning {
background: rgba(245, 158, 11, 0.1);
color: var(--warning-color);
border: 1px solid rgba(245, 158, 11, 0.2);
}
.form-actions {
display: flex;
gap: 1rem;
justify-content: center;
margin-top: 2rem;
padding-top: 2rem;
border-top: 1px solid var(--gray-200);
}
.btn {
padding: 0.75rem 2rem;
border: none;
border-radius: var(--radius-lg);
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: var(--transition);
text-decoration: none;
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.btn-primary {
background: var(--primary-color);
color: white;
}
.btn-primary:hover {
background: #1d4ed8;
}
.btn-secondary {
background: var(--gray-200);
color: var(--gray-700);
}
.btn-secondary:hover {
background: var(--gray-300);
}
.error-message {
color: var(--error-color);
font-size: 0.875rem;
margin-top: 0.5rem;
}
.form-group.has-error input,
.form-group.has-error textarea {
border-color: var(--error-color);
}
@media (max-width: 768px) {
.main-content {
grid-template-columns: 1fr;
gap: 1rem;
}
.current-info-panel {
position: static;
}
.container {
padding: 0 0.5rem;
}
.form-container {
padding: 1.5rem;
}
.form-actions {
flex-direction: column;
}
}
</style>
</head>
<body>
<div class="container">
<div class="main-content">
<!-- Main Form -->
<div class="form-container">
<div class="form-header">
<h1>
<i class="fas fa-edit"></i>
Edit QR Code
</h1>
<p>Update the information for your QR code</p>
</div>
<form method="POST" class="form" id="editQRForm">
<!-- Basic Information Section -->
<div class="form-section">
<div class="section-header">
<h3>
<i class="fas fa-info-circle"></i>
Basic Information
</h3>
<p>Update the basic details for your QR code</p>
</div>
<div class="form-group">
<label for="name">
<i class="fas fa-tag"></i>
QR Code Name <span style="color: var(--error-color)">*</span>
</label>
<input
type="text"
id="name"
name="name"
required
value="{{ qr_code.name }}"
data-original="{{ qr_code.name }}"
placeholder="e.g., Main Office Entrance, Conference Room A"
maxlength="100"
/>
<small class="form-help"
>A unique name to identify this QR code</small
>
<div class="character-counter">
<span id="nameCounter">{{ qr_code.name|length }}/100</span>
</div>
</div>
<div class="form-group">
<label for="location">
<i class="fas fa-map-marker-alt"></i>
Location Name <span style="color: var(--error-color)">*</span>
</label>
<input
type="text"
id="location"
name="location"
required
value="{{ qr_code.location }}"
data-original="{{ qr_code.location }}"
placeholder="e.g., Corporate Headquarters, Branch Office"
maxlength="100"
/>
<small class="form-help"
>The name of the physical location where this QR code will be
used</small
>
<div class="character-counter">
<span id="locationCounter"
>{{ qr_code.location|length }}/100</span
>
</div>
</div>
<div class="form-group">
<label for="project_id">
<i class="fas fa-folder"></i>
Project (Optional)
</label>
<select id="project_id" name="project_id" class="form-select">
<option value="">No project assigned</option>
{% for project in projects %}
<option value="{{ project.id }}"
{% if qr_code.project_id == project.id %}selected{% endif %}>
{{ project.name }} ({{ project.qr_count }} QR codes)
</option>
{% endfor %}
</select>
<small class="form-help">
<i class="fas fa-info-circle"></i>
{% if qr_code.project %}
Currently assigned to: <strong>{{ qr_code.project.name }}</strong>
{% else %}
This QR code is not assigned to any project
{% endif %}
</small>
</div>
</div>
<!-- Location Details Section -->
<div class="form-section">
<div class="section-header">
<h3>
<i class="fas fa-building"></i>
Location Details
</h3>
<p>Update the complete address and event information</p>
</div>
<div class="form-group">
<label for="location_address">
<i class="fas fa-home"></i>
Complete Address
<span style="color: var(--error-color)">*</span>
</label>
<textarea
id="location_address"
name="location_address"
required
data-original="{{ qr_code.location_address }}"
placeholder="Enter the full address including street, city, state, and ZIP code"
rows="3"
maxlength="500"
>
{{ qr_code.location_address }}</textarea
>
<small class="form-help"
>Include all address details for accurate location
identification</small
>
<div class="character-counter">
<span id="addressCounter"
>{{ qr_code.location_address|length }}/500</span
>
</div>
<!-- Address Coordinates Section -->
<div class="coordinates-section" id="coordinatesSection">
<div class="coordinates-header">
<i class="fas fa-crosshairs"></i>
<h4>Address Coordinates</h4>
</div>
<div class="coordinates-content">
<div class="coordinate-display">
<div class="coordinate-info">
<div class="coordinate-value" id="latitudeDisplay">
{% if qr_code.has_coordinates %} {{
"%.6f"|format(qr_code.address_latitude) }} {% else %}
---.------ {% endif %}
</div>
<div class="coordinate-label">Latitude</div>
</div>
<div class="coordinate-info">
<div class="coordinate-value" id="longitudeDisplay">
{% if qr_code.has_coordinates %} {{
"%.6f"|format(qr_code.address_longitude) }} {% else %}
---.------ {% endif %}
</div>
<div class="coordinate-label">Longitude</div>
</div>
</div>
<div class="coordinates-actions">
<button
type="button"
class="btn-coordinate"
id="geocodeBtn"
>
<i class="fas fa-search-location"></i>
{% if qr_code.has_coordinates %}Update{% else %}Get{%
endif %} Coordinates
</button>
<button
type="button"
class="btn-coordinate"
id="clearCoordinatesBtn"
style="display: {% if qr_code.has_coordinates %}inline-flex{% else %}none{% endif %};"
>
<i class="fas fa-times"></i>
Clear
</button>
</div>
<div id="coordinateStatus"></div>
</div>
</div>
</div>
<div class="form-group">
<label for="location_event">
<i class="fas fa-calendar-alt"></i>
Event or Purpose
<span style="color: var(--error-color)">*</span>
</label>
<select
id="location_event"
name="location_event"
required
class="form-control"
data-original="{{ qr_code.location_event }}"
>
<option value="">Select Event Type</option>
<option value="Check In" {% if qr_code.location_event == 'Check In' %}selected{% endif %}>Check In</option>
<option value="Check Out" {% if qr_code.location_event == 'Check Out' %}selected{% endif %}>Check Out</option>
</select>
<small class="form-help"
>Select the event type for this QR code</small
>
</div>
</div>
<!-- Hidden coordinate fields for form submission -->
<input
type="hidden"
id="address_latitude"
name="address_latitude"
value="{% if qr_code.has_coordinates %}{{ qr_code.address_latitude }}{% endif %}"
/>
<input
type="hidden"
id="address_longitude"
name="address_longitude"
value="{% if qr_code.has_coordinates %}{{ qr_code.address_longitude }}{% endif %}"
/>
<input
type="hidden"
id="coordinate_accuracy"
name="coordinate_accuracy"
value="{% if qr_code.has_coordinates %}{{ qr_code.coordinate_accuracy }}{% endif %}"
/>
<!-- Form Actions -->
<div class="form-actions">
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i>
Cancel
</a>
<button type="submit" class="btn btn-primary" id="submitBtn">
<i class="fas fa-save"></i>
Update QR Code
</button>
</div>
</form>
</div>
<!-- Current Information Panel -->
<div class="current-info-panel">
<div class="current-info-header">
<h3>
<i class="fas fa-info-circle"></i>
Current Information
</h3>
</div>
<div class="current-info-content">
<div class="detail-row">
<strong>QR Code Name:</strong>
<span id="currentName">{{ qr_code.name }}</span>
</div>
<div class="detail-row">
<strong>Location:</strong>
<span id="currentLocation">{{ qr_code.location }}</span>
</div>
<div class="detail-row">
<strong>Event:</strong>
<span id="currentEvent">{{ qr_code.location_event }}</span>
</div>
<div class="detail-row">
<strong>Address:</strong>
<span id="currentAddress">{{ qr_code.location_address }}</span>
</div>
<!-- Current Coordinates Display -->
{% if qr_code.has_coordinates %}
<div class="coordinate-info">
<div class="coordinate-value">
{{ qr_code.coordinates_display }}
</div>
<div class="coordinate-label">Current Coordinates</div>
<div style="font-size: 0.75rem; margin-top: 0.5rem; opacity: 0.8">
Accuracy: {{ qr_code.coordinate_accuracy|title }} {% if
qr_code.coordinates_updated_date %}
<br />Updated: {{
qr_code.coordinates_updated_date.strftime('%Y-%m-%d') }} {%
endif %}
</div>
</div>
{% else %}
<div class="no-coordinates">
<i class="fas fa-map-marker-alt"></i>
<div>No coordinates available</div>
<div style="font-size: 0.75rem; margin-top: 0.25rem">
Add coordinates using the form
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<script>
// Global variables
let coordinatesData = {
latitude: {% if qr_code.has_coordinates %}{{ qr_code.address_latitude }}{% else %}null{% endif %},
longitude: {% if qr_code.has_coordinates %}{{ qr_code.address_longitude }}{% else %}null{% endif %},
accuracy: "{% if qr_code.has_coordinates %}{{ qr_code.coordinate_accuracy }}{% else %}{% endif %}"
};
let originalData = {};
let originalProjectId = {% if qr_code.project_id %}{{ qr_code.project_id }}{% else %}null{% endif %};
// Initialize the form when page loads
document.addEventListener('DOMContentLoaded', function() {
storeOriginalData();
initializeForm();
initializeCharacterCounters();
initializeCoordinatesFeature();
initializeChangeTracking();
});
function storeOriginalData() {
originalData = {
name: document.getElementById('name').dataset.original,
location: document.getElementById('location').dataset.original,
location_address: document.getElementById('location_address').dataset.original,
location_event: document.getElementById('location_event').dataset.original
};
}
function initializeForm() {
// Form validation on submit - REMOVED COORDINATE UPDATE REQUIREMENT
document.getElementById('editQRForm').addEventListener('submit', function(e) {
if (!validateForm()) {
e.preventDefault();
return false;
}
// REMOVED: Check if changes were made - Allow form submission regardless of changes
// This enables updates even when only project changes or coordinate updates occur
// Show loading state
const submitBtn = document.getElementById('submitBtn');
submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Updating QR Code...';
submitBtn.disabled = true;
});
}
function initializeCharacterCounters() {
const fields = [
{ id: 'name', counter: 'nameCounter', max: 100 },
{ id: 'location', counter: 'locationCounter', max: 150 },
{ id: 'location_address', counter: 'addressCounter', max: 255 }
];
fields.forEach(field => {
const input = document.getElementById(field.id);
const counter = document.getElementById(field.counter);
if (input && counter) {
function updateCounter() {
const length = input.value.length;
counter.textContent = `${length}/${field.max}`;
if (length > field.max * 0.9) {
counter.style.color = 'var(--warning-color)';
} else {
counter.style.color = '';
}
}
input.addEventListener('input', updateCounter);
updateCounter();
}
});
}
function geocodeAddress(address) {
const geocodeBtn = document.getElementById('geocodeBtn');
const statusDiv = document.getElementById('coordinateStatus');
// Show loading state
geocodeBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Getting Coordinates...';
geocodeBtn.disabled = true;
showStatus('info', 'Getting coordinates from address...');
// Use backend API instead of OpenCage
fetch('/api/geocode', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
'address': address
})
})
.then(response => response.json())
.then(data => {
console.log('Geocoding response:', data);
if (data.success && data.data) {
const result = data.data;
const lat = result.latitude;
const lng = result.longitude;
const accuracy = result.accuracy || 'medium';
// Update coordinates data
coordinatesData = {
latitude: lat,
longitude: lng,
accuracy: accuracy
};
updateCoordinatesDisplay();
updateHiddenFields();
showStatus('success', `Coordinates updated successfully! Accuracy: ${accuracy}`);
console.log('✓ Coordinates updated:', coordinatesData);
} else {
const errorMessage = data.message || 'Could not find coordinates for this address. Please check the address and try again.';
showStatus('error', errorMessage);
}
})
.catch(error => {
console.error('Geocoding error:', error);
showStatus('error', 'Failed to get coordinates. Please try again.');
})
.finally(() => {
// Reset button state
geocodeBtn.innerHTML = '<i class="fas fa-search-location"></i> Update Coordinates';
geocodeBtn.disabled = false;
});
}
function updateCoordinatesDisplay() {
const latDisplay = document.getElementById('latitudeDisplay');
const lngDisplay = document.getElementById('longitudeDisplay');
const clearBtn = document.getElementById('clearCoordinatesBtn');
if (coordinatesData.latitude && coordinatesData.longitude) {
latDisplay.textContent = coordinatesData.latitude.toFixed(10);
lngDisplay.textContent = coordinatesData.longitude.toFixed(10);
clearBtn.style.display = 'inline-flex';
} else {
latDisplay.textContent = '---.----------';
lngDisplay.textContent = '---.----------';
clearBtn.style.display = 'none';
}
}
function updateHiddenFields() {
document.getElementById('address_latitude').value = coordinatesData.latitude || '';
document.getElementById('address_longitude').value = coordinatesData.longitude || '';
document.getElementById('coordinate_accuracy').value = coordinatesData.accuracy || '';
}
function clearCoordinates() {
coordinatesData = {
latitude: null,
longitude: null,
accuracy: null
};
updateCoordinatesDisplay();
updateHiddenFields();
// Clear status
document.getElementById('coordinateStatus').innerHTML = '';
showStatus('warning', 'Coordinates cleared. Click "Update QR Code" to save changes.');
}
// ENHANCED hasChanges function - Now includes project changes and allows coordinate-only updates
function hasChanges() {
const currentData = {
name: document.getElementById('name').value.trim(),
location: document.getElementById('location').value.trim(),
location_address: document.getElementById('location_address').value.trim(),
location_event: document.getElementById('location_event').value.trim()
};
// Check basic field changes
const fieldChanges = Object.keys(originalData).some(key => {
return currentData[key] !== originalData[key];
});
// Check project changes
const currentProjectId = document.getElementById('project_id').value;
const projectIdValue = currentProjectId ? parseInt(currentProjectId) : null;
const projectChanged = originalProjectId !== projectIdValue;
console.log('Change detection:', {
fieldChanges,
projectChanged,
originalProjectId,
currentProjectId: projectIdValue
});
return fieldChanges || projectChanged;
}
// REMOVED: confirmSaveChanges function - No longer needed since we're allowing all updates
function showStatus(type, message) {
const statusDiv = document.getElementById('coordinateStatus');
const iconMap = {
'success': 'fas fa-check-circle',
'error': 'fas fa-exclamation-circle',
'warning': 'fas fa-exclamation-triangle',
'info': 'fas fa-info-circle'
};
statusDiv.innerHTML = `
<div class="status-message status-${type}">
<i class="${iconMap[type]}"></i>
<span>${message}</span>
</div>
`;
// Auto-clear after 5 seconds for success messages
if (type === 'success') {
setTimeout(() => {
statusDiv.innerHTML = '';
}, 5000);
}
}
function validateForm() {
const requiredFields = [
{ id: 'name', name: 'QR Code Name' },
{ id: 'location', name: 'Location Name' },
{ id: 'location_address', name: 'Complete Address' },
{ id: 'location_event', name: 'Event or Purpose' }
];
let isValid = true;
requiredFields.forEach(field => {
const input = document.getElementById(field.id);
if (!input.value.trim()) {
showFieldError(input, `${field.name} is required`);
isValid = false;
} else {
clearFieldError(input);
}
});
// Additional validation
const name = document.getElementById('name').value.trim();
if (name && name.length < 3) {
showFieldError(document.getElementById('name'), 'QR Code name must be at least 3 characters');
isValid = false;
}
const address = document.getElementById('location_address').value.trim();
if (address && address.length < 10) {
showFieldError(document.getElementById('location_address'), 'Please provide a complete address');
isValid = false;
}
return isValid;
}
function showFieldError(input, message) {
const formGroup = input.closest('.form-group');
formGroup.classList.add('has-error');
let errorElement = formGroup.querySelector('.error-message');
if (!errorElement) {
errorElement = document.createElement('div');
errorElement.className = 'error-message';
formGroup.appendChild(errorElement);
}
errorElement.textContent = message;
}
function clearFieldError(input) {
const formGroup = input.closest('.form-group');
formGroup.classList.remove('has-error');
const errorElement = formGroup.querySelector('.error-message');
if (errorElement) {
errorElement.remove();
}
}
function initializeCoordinatesFeature() {
const geocodeBtn = document.getElementById('geocodeBtn');
const clearBtn = document.getElementById('clearCoordinatesBtn');
// Geocode button click
geocodeBtn.addEventListener('click', function() {
const address = document.getElementById('location_address').value.trim();
if (address.length > 10) {
geocodeAddress(address);
} else {
showStatus('error', 'Please enter a complete address first');
}
});
// Clear coordinates button
clearBtn.addEventListener('click', clearCoordinates);
}
function initializeChangeTracking() {
const inputs = document.querySelectorAll('#name, #location, #location_address, #location_event');
inputs.forEach(input => {
input.addEventListener('input', updateCurrentInfo);
});
}
function updateCurrentInfo() {
document.getElementById('currentName').textContent = document.getElementById('name').value || '-';
document.getElementById('currentLocation').textContent = document.getElementById('location').value || '-';
document.getElementById('currentEvent').textContent = document.getElementById('location_event').value || '-';
document.getElementById('currentAddress').textContent = document.getElementById('location_address').value || '-';
}
</script>
</body>
</html>