hlsitech commited on
Commit
64745de
·
verified ·
1 Parent(s): 4d23774

enhance all functions - Follow Up Deployment

Browse files
Files changed (1) hide show
  1. index.html +133 -15
index.html CHANGED
@@ -5,6 +5,7 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Elegant Wedding Invitations | AI-Powered Card Creator</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
 
8
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
  <script>
10
  tailwind.config = {
@@ -226,6 +227,51 @@
226
  </div>
227
  <button class="w-full mt-4 bg-sage hover:bg-navy text-white py-2 px-4 rounded-lg font-medium transition duration-300 select-template" data-template="3">Select This Design</button>
228
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  </div>
230
  <button class="carousel-prev absolute left-0 top-1/2 -translate-y-1/2 -ml-4 bg-white rounded-full w-10 h-10 flex items-center justify-center shadow-md hover:bg-gray-100 transition"><i class="fas fa-chevron-left text-mauve"></i></button>
231
  <button class="carousel-next absolute right-0 top-1/2 -translate-y-1/2 -mr-4 bg-white rounded-full w-10 h-10 flex items-center justify-center shadow-md hover:bg-gray-100 transition"><i class="fas fa-chevron-right text-mauve"></i></button>
@@ -506,27 +552,49 @@
506
  form.addEventListener('submit', function(e) {
507
  e.preventDefault();
508
 
 
 
 
509
  // Show loading state
510
  submitText.textContent = 'Designing your invitation...';
511
  loadingSpinner.classList.remove('hidden');
 
 
 
512
 
513
- // Update preview with form data
514
- updatePreview();
515
-
516
- // Simulate AI working
517
  setTimeout(() => {
518
- aiMessage.textContent = "I've created 3 beautiful designs for you based on your preferences. Which one do you like best?";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
 
520
  // Show success state
521
  submitText.textContent = 'View Designs';
522
  loadingSpinner.classList.add('hidden');
 
 
 
523
 
524
- // Show templates carousel
525
  document.getElementById('templatesCarousel').classList.remove('hidden');
 
526
 
527
  // Update template previews with form data
528
  updateTemplatePreviews();
529
- }, 3000);
530
  });
531
 
532
  // Update preview as user types
@@ -536,12 +604,27 @@
536
  });
537
 
538
  function updatePreview() {
539
- // Get form values
540
- const names = document.getElementById('coupleNames').value || 'Sarah & Michael';
541
  const dateInput = document.getElementById('weddingDate').value;
542
- const venue = document.getElementById('venue').value || 'The Grand Ballroom, New York';
543
  const time = document.getElementById('time').value || '16:30';
544
- const message = document.getElementById('message').value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
545
 
546
  // Format date
547
  let formattedDate = 'Saturday, June 10th, 2023';
@@ -622,9 +705,26 @@
622
  });
623
  });
624
 
 
 
 
 
 
 
 
 
 
 
 
625
  // Initialize with default values
626
  updatePreview();
627
 
 
 
 
 
 
 
628
  // Carousel navigation
629
  document.querySelector('.carousel-prev').addEventListener('click', () => {
630
  document.querySelector('.carousel-inner').scrollBy({ left: -300, behavior: 'smooth' });
@@ -634,12 +734,30 @@
634
  document.querySelector('.carousel-inner').scrollBy({ left: 300, behavior: 'smooth' });
635
  });
636
 
637
- // Template selection
638
  document.querySelectorAll('.select-template').forEach(button => {
639
  button.addEventListener('click', function() {
640
  const templateNum = this.getAttribute('data-template');
641
- // In a real app, you would apply the selected template
642
- alert(`Template ${templateNum} selected! This would apply the design to your invitation.`);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
643
  });
644
  });
645
 
@@ -658,7 +776,7 @@
658
  }
659
 
660
  // Update all template previews
661
- for (let i = 1; i <= 3; i++) {
662
  document.getElementById(`template${i}Names`).textContent = names;
663
  document.getElementById(`template${i}Date`).textContent = formattedDate;
664
  document.getElementById(`template${i}Venue`).textContent = venue;
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Elegant Wedding Invitations | AI-Powered Card Creator</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
9
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
10
  <script>
11
  tailwind.config = {
 
227
  </div>
228
  <button class="w-full mt-4 bg-sage hover:bg-navy text-white py-2 px-4 rounded-lg font-medium transition duration-300 select-template" data-template="3">Select This Design</button>
229
  </div>
230
+
231
+ <!-- Template 4 -->
232
+ <div class="carousel-item flex-shrink-0 w-full sm:w-1/2 lg:w-1/3 snap-start">
233
+ <div class="card-preview w-full h-96 rounded-lg p-8 flex flex-col justify-center items-center text-center text-white relative overflow-hidden">
234
+ <div class="absolute inset-0 bg-navy bg-opacity-70"></div>
235
+ <div class="relative z-10">
236
+ <h3 id="template4Names" class="font-playfair text-2xl mb-2">Sarah & Michael</h3>
237
+ <p class="text-sm mb-4">Request the honour of your presence</p>
238
+ <div class="w-16 h-px bg-white mx-auto my-4"></div>
239
+ <p id="template4Date" class="text-sm mb-1">Saturday, June 10th, 2023</p>
240
+ <p id="template4Venue" class="text-sm">The Grand Ballroom, New York</p>
241
+ </div>
242
+ </div>
243
+ <button class="w-full mt-4 bg-navy hover:bg-mauve text-white py-2 px-4 rounded-lg font-medium transition duration-300 select-template" data-template="4">Select This Design</button>
244
+ </div>
245
+
246
+ <!-- Template 5 -->
247
+ <div class="carousel-item flex-shrink-0 w-full sm:w-1/2 lg:w-1/3 snap-start">
248
+ <div class="card-preview w-full h-96 rounded-lg p-8 flex flex-col justify-center items-center text-center text-white relative overflow-hidden">
249
+ <div class="absolute inset-0 bg-champagne bg-opacity-80"></div>
250
+ <div class="relative z-10 text-navy">
251
+ <h3 id="template5Names" class="font-playfair text-2xl mb-2">Sarah & Michael</h3>
252
+ <p class="text-sm mb-4">Would love you to join their celebration</p>
253
+ <div class="w-16 h-px bg-navy mx-auto my-4"></div>
254
+ <p id="template5Date" class="text-sm mb-1">Saturday, June 10th, 2023</p>
255
+ <p id="template5Venue" class="text-sm">The Grand Ballroom, New York</p>
256
+ </div>
257
+ </div>
258
+ <button class="w-full mt-4 bg-champagne hover:bg-blush text-navy py-2 px-4 rounded-lg font-medium transition duration-300 select-template" data-template="5">Select This Design</button>
259
+ </div>
260
+
261
+ <!-- Template 6 -->
262
+ <div class="carousel-item flex-shrink-0 w-full sm:w-1/2 lg:w-1/3 snap-start">
263
+ <div class="card-preview w-full h-96 rounded-lg p-8 flex flex-col justify-center items-center text-center text-white relative overflow-hidden">
264
+ <div class="absolute inset-0 bg-blush bg-opacity-50"></div>
265
+ <div class="relative z-10">
266
+ <h3 id="template6Names" class="font-playfair text-2xl mb-2">Sarah & Michael</h3>
267
+ <p class="text-sm mb-4">Joyfully invite you to their wedding</p>
268
+ <div class="w-16 h-px bg-white mx-auto my-4"></div>
269
+ <p id="template6Date" class="text-sm mb-1">Saturday, June 10th, 2023</p>
270
+ <p id="template6Venue" class="text-sm">The Grand Ballroom, New York</p>
271
+ </div>
272
+ </div>
273
+ <button class="w-full mt-4 bg-blush hover:bg-navy text-white py-2 px-4 rounded-lg font-medium transition duration-300 select-template" data-template="6">Select This Design</button>
274
+ </div>
275
  </div>
276
  <button class="carousel-prev absolute left-0 top-1/2 -translate-y-1/2 -ml-4 bg-white rounded-full w-10 h-10 flex items-center justify-center shadow-md hover:bg-gray-100 transition"><i class="fas fa-chevron-left text-mauve"></i></button>
277
  <button class="carousel-next absolute right-0 top-1/2 -translate-y-1/2 -mr-4 bg-white rounded-full w-10 h-10 flex items-center justify-center shadow-md hover:bg-gray-100 transition"><i class="fas fa-chevron-right text-mauve"></i></button>
 
552
  form.addEventListener('submit', function(e) {
553
  e.preventDefault();
554
 
555
+ // Validate form first
556
+ if (!updatePreview()) return;
557
+
558
  // Show loading state
559
  submitText.textContent = 'Designing your invitation...';
560
  loadingSpinner.classList.remove('hidden');
561
+ form.querySelectorAll('input, select, textarea').forEach(el => {
562
+ el.disabled = true;
563
+ });
564
 
565
+ // Simulate AI working with more realistic delay
 
 
 
566
  setTimeout(() => {
567
+ // Generate 3 random template suggestions (1-6)
568
+ const suggestedTemplates = [];
569
+ while(suggestedTemplates.length < 3) {
570
+ const randomTemplate = Math.floor(Math.random() * 6) + 1;
571
+ if (!suggestedTemplates.includes(randomTemplate)) {
572
+ suggestedTemplates.push(randomTemplate);
573
+ }
574
+ }
575
+
576
+ // Show only suggested templates
577
+ document.querySelectorAll('.carousel-item').forEach(item => {
578
+ const templateNum = item.querySelector('.select-template').getAttribute('data-template');
579
+ item.style.display = suggestedTemplates.includes(parseInt(templateNum)) ? 'block' : 'none';
580
+ });
581
+
582
+ aiMessage.textContent = "I've created these beautiful designs based on your preferences. Which one speaks to you?";
583
 
584
  // Show success state
585
  submitText.textContent = 'View Designs';
586
  loadingSpinner.classList.add('hidden');
587
+ form.querySelectorAll('input, select, textarea').forEach(el => {
588
+ el.disabled = false;
589
+ });
590
 
591
+ // Show templates carousel with smooth scroll
592
  document.getElementById('templatesCarousel').classList.remove('hidden');
593
+ document.getElementById('templatesCarousel').scrollIntoView({ behavior: 'smooth' });
594
 
595
  // Update template previews with form data
596
  updateTemplatePreviews();
597
+ }, 2000 + Math.random() * 2000); // Random delay between 2-4 seconds
598
  });
599
 
600
  // Update preview as user types
 
604
  });
605
 
606
  function updatePreview() {
607
+ // Get form values with validation
608
+ const names = document.getElementById('coupleNames').value.trim() || 'Sarah & Michael';
609
  const dateInput = document.getElementById('weddingDate').value;
610
+ const venue = document.getElementById('venue').value.trim() || 'The Grand Ballroom, New York';
611
  const time = document.getElementById('time').value || '16:30';
612
+ const message = document.getElementById('message').value.trim();
613
+ const theme = document.getElementById('theme').value;
614
+ const color = document.getElementById('colors').value;
615
+
616
+ // Validate date is in future
617
+ if (dateInput) {
618
+ const today = new Date();
619
+ const selectedDate = new Date(dateInput);
620
+ if (selectedDate < today) {
621
+ document.getElementById('weddingDate').classList.add('border-red-500');
622
+ aiMessage.textContent = "Please select a future date for your wedding.";
623
+ return false;
624
+ } else {
625
+ document.getElementById('weddingDate').classList.remove('border-red-500');
626
+ }
627
+ }
628
 
629
  // Format date
630
  let formattedDate = 'Saturday, June 10th, 2023';
 
705
  });
706
  });
707
 
708
+ // Download functionality
709
+ function downloadInvitation() {
710
+ const cardPreview = document.getElementById('cardPreview');
711
+ html2canvas(cardPreview).then(canvas => {
712
+ const link = document.createElement('a');
713
+ link.download = 'wedding-invitation.png';
714
+ link.href = canvas.toDataURL('image/png');
715
+ link.click();
716
+ });
717
+ }
718
+
719
  // Initialize with default values
720
  updatePreview();
721
 
722
+ // Check for previously selected template
723
+ const savedTemplate = localStorage.getItem('selectedTemplate');
724
+ if (savedTemplate) {
725
+ document.getElementById('cardPreview').classList.add(`template-${savedTemplate}`);
726
+ }
727
+
728
  // Carousel navigation
729
  document.querySelector('.carousel-prev').addEventListener('click', () => {
730
  document.querySelector('.carousel-inner').scrollBy({ left: -300, behavior: 'smooth' });
 
734
  document.querySelector('.carousel-inner').scrollBy({ left: 300, behavior: 'smooth' });
735
  });
736
 
737
+ // Template selection with preview update
738
  document.querySelectorAll('.select-template').forEach(button => {
739
  button.addEventListener('click', function() {
740
  const templateNum = this.getAttribute('data-template');
741
+ const cardPreview = document.getElementById('cardPreview');
742
+
743
+ // Remove all template classes
744
+ cardPreview.classList.remove(
745
+ 'template-1', 'template-2', 'template-3',
746
+ 'template-4', 'template-5', 'template-6'
747
+ );
748
+
749
+ // Add selected template class
750
+ cardPreview.classList.add(`template-${templateNum}`);
751
+
752
+ // Update AI message
753
+ aiMessage.textContent = `Great choice! You've selected Design ${templateNum}. Ready to download or customize further?`;
754
+
755
+ // Show download button
756
+ submitText.textContent = 'Download Invitation';
757
+ document.getElementById('templatesCarousel').classList.add('hidden');
758
+
759
+ // Store selected template
760
+ localStorage.setItem('selectedTemplate', templateNum);
761
  });
762
  });
763
 
 
776
  }
777
 
778
  // Update all template previews
779
+ for (let i = 1; i <= 6; i++) {
780
  document.getElementById(`template${i}Names`).textContent = names;
781
  document.getElementById(`template${i}Date`).textContent = formattedDate;
782
  document.getElementById(`template${i}Venue`).textContent = venue;