theflowercat's picture
太丑了,设计好看点。按苹果风格。2.历史和角色列表,能弄为挂件形式么,侧边栏
e900964 verified
Raw History Blame Contribute Delete
2.33 kB
// Form submission handler
document.getElementById('videoForm').addEventListener('submit', function(e) {
e.preventDefault();
// Get form values
const script = document.getElementById('videoText').value;
const voice = document.getElementById('voiceSelect').value;
const style = document.getElementById('styleSelect').value;
const files = document.getElementById('file-upload').files;
// Show loading state
const submitBtn = e.target.querySelector('button[type="submit"]');
const originalText = submitBtn.innerHTML;
submitBtn.innerHTML = '<i data-feather="loader" class="animate-spin mr-2"></i> Generating...';
submitBtn.disabled = true;
// Simulate API call
setTimeout(() => {
// Reset button
submitBtn.innerHTML = originalText;
submitBtn.disabled = false;
feather.replace();
// Show success message
alert('Your video is being generated! You will be notified when it\'s ready.');
// In a real app, you would redirect to the video preview page
// window.location.href = '/video-preview?id=123';
}, 2000);
});
// Drag and drop functionality
const dropArea = document.querySelector('.border-dashed');
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
dropArea.addEventListener(eventName, preventDefaults, false);
});
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
['dragenter', 'dragover'].forEach(eventName => {
dropArea.addEventListener(eventName, highlight, false);
});
['dragleave', 'drop'].forEach(eventName => {
dropArea.addEventListener(eventName, unhighlight, false);
});
function highlight() {
dropArea.classList.add('border-purple-500', 'bg-purple-50');
}
function unhighlight() {
dropArea.classList.remove('border-purple-500', 'bg-purple-50');
}
dropArea.addEventListener('drop', handleDrop, false);
function handleDrop(e) {
const dt = e.dataTransfer;
const files = dt.files;
document.getElementById('file-upload').files = files;
// Show file names
const fileList = Array.from(files).map(file => file.name).join(', ');
const infoText = dropArea.querySelector('p:last-child');
infoText.textContent = `${files.length} file(s) selected: ${fileList}`;
}