Spaces:
Running
Running
Download script.js from Dabelu/skyhawk-fpv-drones: direct link, hf CLI and curl.
- Browser
- Download file 5.37 kB
-
https://huggingface.co/spaces/Dabelu/skyhawk-fpv-drones/resolve/main/script.js
- Command line
-
hf download hf://spaces/Dabelu/skyhawk-fpv-drones/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Dabelu/skyhawk-fpv-drones/resolve/main/script.js
5.37 kB
| // Drone Product Class | |
| class Drone { | |
| constructor(id, name, category, price, specs, features) { | |
| this.id = id; | |
| this.name = name; | |
| this.category = category; | |
| this.price = price; | |
| this.specs = specs; | |
| this.features = features; | |
| } | |
| displaySpecs() { | |
| return ` | |
| <div class="mb-6"> | |
| <h4 class="font-bold text-lg mb-3">Technical Specifications</h4> | |
| <ul class="space-y-2"> | |
| ${this.specs.map(spec => `<li class="flex justify-between border-b border-gray-700 pb-2"><span class="text-gray-400">${spec.label}:</span> <span>${spec.value}</span></li>`).join('')} | |
| </ul> | |
| </div> | |
| `; | |
| } | |
| displayFeatures() { | |
| return ` | |
| <div> | |
| <h4 class="font-bold text-lg mb-3">Key Features</h4> | |
| <ul class="space-y-2"> | |
| ${this.features.map(feature => `<li class="flex items-start"><i data-feather="check-circle" class="text-green-500 mr-2 mt-1 flex-shrink-0"></i> ${feature}</li>`).join('')} | |
| </ul> | |
| </div> | |
| `; | |
| } | |
| } | |
| // Drone Collection Class | |
| class DroneCollection { | |
| constructor() { | |
| this.drones = []; | |
| } | |
| addDrone(drone) { | |
| this.drones.push(drone); | |
| } | |
| getDronesByCategory(category) { | |
| return this.drones.filter(drone => drone.category === category); | |
| } | |
| getDroneById(id) { | |
| return this.drones.find(drone => drone.id === id); | |
| } | |
| } | |
| // Contact Form Handler | |
| class ContactForm { | |
| constructor(formId) { | |
| this.form = document.getElementById(formId); | |
| this.init(); | |
| } | |
| init() { | |
| if (this.form) { | |
| this.form.addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| this.handleSubmit(); | |
| }); | |
| } | |
| } | |
| handleSubmit() { | |
| const formData = new FormData(this.form); | |
| const data = Object.fromEntries(formData); | |
| // In a real application, you would send this data to a server | |
| console.log('Form submitted:', data); | |
| // Show success message | |
| this.showMessage('Thank you! Our team will contact you shortly.', 'success'); | |
| this.form.reset(); | |
| } | |
| showMessage(message, type) { | |
| // Create message element | |
| const messageEl = document.createElement('div'); | |
| messageEl.className = `fixed top-4 right-4 p-4 rounded-lg shadow-lg z-50 ${ | |
| type === 'success' ? 'bg-green-600' : 'bg-red-600' | |
| }`; | |
| messageEl.textContent = message; | |
| // Add to DOM | |
| document.body.appendChild(messageEl); | |
| // Remove after 3 seconds | |
| setTimeout(() => { | |
| messageEl.remove(); | |
| }, 3000); | |
| } | |
| } | |
| // Initialize when DOM is loaded | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Initialize contact form | |
| const contactForm = new ContactForm('contactForm'); | |
| // Initialize drone collection | |
| const droneCollection = new DroneCollection(); | |
| // Add sample drones | |
| droneCollection.addDrone(new Drone( | |
| 1, | |
| 'SkyHawk Civilian X1', | |
| 'civilian', | |
| 899, | |
| [ | |
| { label: 'Flight Time', value: '30 minutes' }, | |
| { label: 'Camera', value: '4K HDR' }, | |
| { label: 'Range', value: '5 km' }, | |
| { label: 'Weight', value: '500g' } | |
| ], | |
| [ | |
| 'GPS Positioning', | |
| 'Headless Mode', | |
| 'One-Key Return', | |
| 'Gesture Control' | |
| ] | |
| )); | |
| droneCollection.addDrone(new Drone( | |
| 2, | |
| 'SkyHawk Pro Surveyor', | |
| 'commercial', | |
| 3499, | |
| [ | |
| { label: 'Flight Time', value: '45 minutes' }, | |
| { label: 'Camera', value: '1-inch 20MP' }, | |
| { label: 'Range', value: '15 km' }, | |
| { label: 'Accuracy', value: '2 cm' } | |
| ], | |
| [ | |
| 'RTK Positioning', | |
| 'Photogrammetry Software', | |
| 'Obstacle Avoidance', | |
| 'Data Encryption' | |
| ] | |
| )); | |
| droneCollection.addDrone(new Drone( | |
| 3, | |
| 'AgriHawk Crop Master', | |
| 'agricultural', | |
| 5999, | |
| [ | |
| { label: 'Flight Time', value: '60 minutes' }, | |
| { label: 'Spray Capacity', value: '16L' }, | |
| { label: 'Coverage', value: '20 acres/hour' }, | |
| { label: 'Sensors', value: 'Multispectral + RGB' } | |
| ], | |
| [ | |
| 'AI Crop Analysis', | |
| 'Variable Rate Application', | |
| 'Weather Monitoring', | |
| 'Automated Flight Paths' | |
| ] | |
| )); | |
| droneCollection.addDrone(new Drone( | |
| 4, | |
| 'Tactical Recon X7', | |
| 'military', | |
| 24999, | |
| [ | |
| { label: 'Flight Time', value: '90 minutes' }, | |
| { label: 'Stealth Mode', value: 'Yes' }, | |
| { label: 'Range', value: '50 km' }, | |
| { label: 'Payload', value: '5 kg' } | |
| ], | |
| [ | |
| 'Military-Grade Encryption', | |
| 'Night Vision Capability', | |
| 'Anti-Jamming System', | |
| 'Self-Destruct Mechanism' | |
| ] | |
| )); | |
| // Store collection in window object for global access | |
| window.droneCollection = droneCollection; | |
| // Initialize Feather Icons | |
| feather.replace(); | |
| }); |