Spaces:
Running
Running
Download script.js from Madhu2191/audience-architect: direct link, hf CLI and curl.
- Browser
- Download file 3.23 kB
-
https://huggingface.co/spaces/Madhu2191/audience-architect/resolve/main/script.js
- Command line
-
hf download hf://spaces/Madhu2191/audience-architect/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Madhu2191/audience-architect/resolve/main/script.js
3.23 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize variables | |
| let currentSection = 0; | |
| const sections = document.querySelectorAll('.section'); | |
| const prevBtn = document.getElementById('prevBtn'); | |
| const nextBtn = document.getElementById('nextBtn'); | |
| const submitBtn = document.getElementById('submitBtn'); | |
| const progressBar = document.getElementById('progressBar'); | |
| // Show first section | |
| showSection(currentSection); | |
| // Next button click handler | |
| nextBtn.addEventListener('click', function() { | |
| if (currentSection < sections.length - 1) { | |
| currentSection++; | |
| showSection(currentSection); | |
| updateProgressBar(); | |
| } | |
| }); | |
| // Previous button click handler | |
| prevBtn.addEventListener('click', function() { | |
| if (currentSection > 0) { | |
| currentSection--; | |
| showSection(currentSection); | |
| updateProgressBar(); | |
| } | |
| }); | |
| // Function to show current section and hide others | |
| function showSection(index) { | |
| sections.forEach((section, i) => { | |
| if (i === index) { | |
| section.style.display = 'block'; | |
| section.classList.add('fade-in'); | |
| } else { | |
| section.style.display = 'none'; | |
| } | |
| }); | |
| // Update button visibility | |
| if (index === 0) { | |
| prevBtn.classList.add('hidden'); | |
| } else { | |
| prevBtn.classList.remove('hidden'); | |
| } | |
| if (index === sections.length - 1) { | |
| nextBtn.classList.add('hidden'); | |
| submitBtn.classList.remove('hidden'); | |
| } else { | |
| nextBtn.classList.remove('hidden'); | |
| submitBtn.classList.add('hidden'); | |
| } | |
| } | |
| // Update progress bar | |
| function updateProgressBar() { | |
| const progress = ((currentSection + 1) / sections.length) * 100; | |
| progressBar.style.width = `${progress}%`; | |
| } | |
| // Form submission | |
| document.getElementById('audienceForm').addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // Collect form data | |
| const formData = new FormData(this); | |
| const data = {}; | |
| formData.forEach((value, key) => { | |
| if (!data[key]) { | |
| data[key] = []; | |
| } | |
| data[key].push(value); | |
| }); | |
| // Here you would typically send the data to a server | |
| console.log('Collected data:', data); | |
| // Show success message (in a real app, you would redirect or show results) | |
| alert('Your audience criteria has been saved successfully!'); | |
| }); | |
| // Add toggle effect for checkboxes | |
| const checkboxes = document.querySelectorAll('input[type="checkbox"]'); | |
| checkboxes.forEach(checkbox => { | |
| checkbox.addEventListener('change', function() { | |
| const label = this.nextElementSibling; | |
| if (this.checked) { | |
| label.classList.add('font-medium', 'text-emerald-800'); | |
| } else { | |
| label.classList.remove('font-medium', 'text-emerald-800'); | |
| } | |
| }); | |
| }); | |
| }); |