Initial commit: conference app with Flask
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
// NetEvent - Main JavaScript
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Auto-hide flash messages after 5 seconds
|
||||
const flashMessages = document.querySelectorAll('.flash-message');
|
||||
flashMessages.forEach(msg => {
|
||||
setTimeout(() => {
|
||||
msg.style.transition = 'opacity 0.5s';
|
||||
msg.style.opacity = '0';
|
||||
setTimeout(() => msg.remove(), 500);
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
// Form validation
|
||||
const forms = document.querySelectorAll('form');
|
||||
forms.forEach(form => {
|
||||
form.addEventListener('submit', function(e) {
|
||||
const requiredInputs = form.querySelectorAll('[required]');
|
||||
let isValid = true;
|
||||
|
||||
requiredInputs.forEach(input => {
|
||||
if (!input.value.trim()) {
|
||||
isValid = false;
|
||||
input.style.borderColor = '#ef4444';
|
||||
} else {
|
||||
input.style.borderColor = '';
|
||||
}
|
||||
});
|
||||
|
||||
if (!isValid && !e.target.dataset.noValidate) {
|
||||
e.preventDefault();
|
||||
alert('Please fill in all required fields.');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Photo upload form
|
||||
const photoForm = document.querySelector('.photo-upload-form');
|
||||
if (photoForm) {
|
||||
photoForm.addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(this);
|
||||
|
||||
try {
|
||||
const response = await fetch(this.action, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
// Reload page to show new photo
|
||||
location.reload();
|
||||
} else {
|
||||
alert(data.error || 'Error uploading photo');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Error uploading photo');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Connection request buttons
|
||||
const connectForms = document.querySelectorAll('.connect-form');
|
||||
connectForms.forEach(form => {
|
||||
form.addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(this);
|
||||
|
||||
try {
|
||||
const response = await fetch(this.action, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
const card = this.closest('.attendee-card');
|
||||
const actionsDiv = card.querySelector('.attendee-actions');
|
||||
actionsDiv.innerHTML = '<span class="badge badge-pending">Request Pending</span>';
|
||||
} else {
|
||||
alert(data.error || 'Error sending connection request');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Error sending connection request');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user