-
`;
-
+
toast.style.cssText = `
position: fixed;
top: 20px;
@@ -1287,14 +1216,14 @@
border-left: 4px solid ${getToastColor(type)};
max-width: 350px;
`;
-
+
document.body.appendChild(toast);
-
+
setTimeout(() => {
toast.style.opacity = '1';
toast.style.transform = 'translateX(0)';
}, 100);
-
+
setTimeout(() => {
toast.style.opacity = '0';
toast.style.transform = 'translateX(100%)';
@@ -1330,23 +1259,23 @@
function validateQRCustomization() {
const fillColor = document.getElementById('fill_color_text').value;
const backColor = document.getElementById('back_color_text').value;
-
+
// Check if colors are too similar
if (fillColor.toLowerCase() === backColor.toLowerCase()) {
showToast('QR code color and background color cannot be the same', 'error');
return false;
}
-
+
return true;
}
// Geocoding functionality
function geocodeAddress(address) {
showStatus('info', 'Getting coordinates...');
-
+
// Using server API which prefers Google Maps with OpenStreetMap fallback
const encodedAddress = encodeURIComponent(address);
-
+
// First try the server API
fetch('/api/geocode', {
method: 'POST',
@@ -1355,32 +1284,32 @@
},
body: JSON.stringify({ address: address })
})
- .then(response => response.json())
- .then(data => {
- if (data.success) {
- const lat = data.data.latitude;
- const lng = data.data.longitude;
-
- updateCoordinates(lat, lng, 'geocoded');
- showStatus('success', data.message || 'Coordinates updated successfully');
- } else {
- showStatus('warning', data.message || 'No coordinates found for this address');
- }
- })
- .catch(error => {
- console.error('Geocoding error:', error);
- showStatus('error', 'Failed to get coordinates. Please try again.');
- });
+ .then(response => response.json())
+ .then(data => {
+ if (data.success) {
+ const lat = data.data.latitude;
+ const lng = data.data.longitude;
+
+ updateCoordinates(lat, lng, 'geocoded');
+ showStatus('success', data.message || 'Coordinates updated successfully');
+ } else {
+ showStatus('warning', data.message || 'No coordinates found for this address');
+ }
+ })
+ .catch(error => {
+ console.error('Geocoding error:', error);
+ showStatus('error', 'Failed to get coordinates. Please try again.');
+ });
}
function updateCoordinates(lat, lng, accuracy) {
document.getElementById('address_latitude').value = lat;
document.getElementById('address_longitude').value = lng;
document.getElementById('coordinate_accuracy').value = accuracy;
-
+
document.getElementById('latitudeDisplay').textContent = lat.toFixed(10);
document.getElementById('longitudeDisplay').textContent = lng.toFixed(10);
-
+
document.getElementById('clearCoordinatesBtn').style.display = 'inline-flex';
document.getElementById('geocodeBtn').innerHTML = '
Update Coordinates';
}
@@ -1389,13 +1318,13 @@
document.getElementById('address_latitude').value = '';
document.getElementById('address_longitude').value = '';
document.getElementById('coordinate_accuracy').value = '';
-
+
document.getElementById('latitudeDisplay').textContent = '---.----------';
document.getElementById('longitudeDisplay').textContent = '---.----------';
-
+
document.getElementById('clearCoordinatesBtn').style.display = 'none';
document.getElementById('geocodeBtn').innerHTML = '
Get Coordinates';
-
+
showStatus('info', 'Coordinates cleared');
}
@@ -1403,7 +1332,7 @@
const statusDiv = document.getElementById('coordinateStatus');
if (statusDiv) {
statusDiv.innerHTML = `
${message}
`;
-
+
setTimeout(() => {
statusDiv.innerHTML = '';
}, 5000);
@@ -1418,12 +1347,8 @@
}
// Initialize on page load
- document.addEventListener('DOMContentLoaded', function() {
+ document.addEventListener('DOMContentLoaded', function () {
// Set up character counters
- document.getElementById('name').addEventListener('input', () => {
- updateCharacterCount('name', 'nameCounter', 100);
- updateCurrentInfo();
- });
document.getElementById('location').addEventListener('input', () => {
updateCharacterCount('location', 'locationCounter', 100);
updateCurrentInfo();
@@ -1432,33 +1357,33 @@
updateCharacterCount('location_address', 'addressCounter', 500);
updateCurrentInfo();
});
-
+
// Set up event listener for location_event
document.getElementById('location_event').addEventListener('change', updateCurrentInfo);
-
+
// Set up initial values for QR customization
updateRangeValue('box_size');
updateRangeValue('border');
updatePreview();
-
+
// Add form validation
const form = document.getElementById('editQRForm');
if (form) {
- form.addEventListener('submit', function(e) {
+ form.addEventListener('submit', function (e) {
if (!validateQRCustomization()) {
e.preventDefault();
return false;
}
});
}
-
+
// Add color input synchronization
- document.getElementById('fill_color').addEventListener('change', function() {
+ document.getElementById('fill_color').addEventListener('change', function () {
document.getElementById('fill_color_text').value = this.value.toUpperCase();
updatePreview();
});
-
- document.getElementById('back_color').addEventListener('change', function() {
+
+ document.getElementById('back_color').addEventListener('change', function () {
document.getElementById('back_color_text').value = this.value.toUpperCase();
updatePreview();
});
@@ -1467,7 +1392,7 @@
const geocodeBtn = document.getElementById('geocodeBtn');
const clearBtn = document.getElementById('clearCoordinatesBtn');
- geocodeBtn.addEventListener('click', function() {
+ geocodeBtn.addEventListener('click', function () {
const address = document.getElementById('location_address').value.trim();
if (address.length > 10) {
geocodeAddress(address);
@@ -1483,26 +1408,26 @@