File size: 5,371 Bytes
00c522e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// 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();
});