File size: 8,270 Bytes
8ed236b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// Smooth scroll to section
function scrollToSection(sectionId) {
    const section = document.getElementById(sectionId);
    if (section) {
        section.scrollIntoView({ behavior: 'smooth' });
    }
}

// Interactive World Map
const locationData = {
    'Paris, France': {
        description: 'The City of Light captivated us with its romantic ambiance, world-class museums, and exquisite cuisine. From the Eiffel Tower to the charming streets of Montmartre, Paris never fails to enchant.',
        date: 'Visited: March 2023',
        highlights: ['Louvre Museum', 'Eiffel Tower', 'Seine River Cruise']
    },
    'Bali, Indonesia': {
        description: 'Bali offered a perfect blend of spiritual temples, terraced rice paddies, and pristine beaches. The warm hospitality and rich culture made this island paradise unforgettable.',
        date: 'Visited: January 2023',
        highlights: ['Tanah Lot Temple', 'Ubud Rice Terraces', 'Seminyak Beach']
    },
    'Tokyo, Japan': {
        description: 'Tokyo is a city of contrasts where ancient traditions meet cutting-edge technology. From serene temples to neon-lit streets, every corner tells a different story.',
        date: 'Visited: May 2023',
        highlights: ['Senso-ji Temple', 'Shibuya Crossing', 'Mount Fuji Day Trip']
    },
    'New York, USA': {
        description: 'The city that never sleeps delivered on its promise of endless energy and iconic experiences. Broadway shows, world museums, and diverse neighborhoods made this trip memorable.',
        date: 'Visited: December 2022',
        highlights: ['Times Square', 'Central Park', 'Brooklyn Bridge']
    },
    'Reykjavik, Iceland': {
        description: 'Iceland\'s dramatic landscapes and the magical Northern Lights left us speechless. From geothermal hot springs to glacier hikes, adventure awaited at every turn.',
        date: 'Visited: September 2022',
        highlights: ['Northern Lights', 'Blue Lagoon', 'Golden Circle Tour']
    },
    'Serengeti, Tanzania': {
        description: 'Witnessing the Great Migration and coming face to face with the Big Five was a life-changing experience. The vast savanna and abundant wildlife created memories that last forever.',
        date: 'Visited: July 2022',
        highlights: ['Great Migration', 'Ngorongoro Crater', 'Hot Air Balloon Safari']
    }
};

// Initialize map interactions
document.addEventListener('DOMContentLoaded', function() {
    const locationMarkers = document.querySelectorAll('.location-marker');
    const locationInfo = document.getElementById('locationInfo');
    
    locationMarkers.forEach(marker => {
        marker.addEventListener('click', function() {
            const location = this.getAttribute('data-location');
            const data = locationData[location];
            
            if (data) {
                locationInfo.querySelector('h3').textContent = location;
                locationInfo.querySelector('p').innerHTML = `
                    ${data.description}<br><br>
                    <strong>${data.date}</strong><br>
                    <span class="text-sm">Highlights: ${data.highlights.join(', ')}</span>
                `;
                locationInfo.classList.remove('hidden');
                
                // Scroll to info if needed
                locationInfo.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
            }
        });
    });
});

// Newsletter subscription
document.getElementById('subscriptionForm').addEventListener('submit', function(e) {
    e.preventDefault();
    
    const emailInput = document.getElementById('emailInput');
    const messageDiv = document.getElementById('subscriptionMessage');
    
    // Simulate subscription process
    const submitButton = this.querySelector('button[type="submit"]');
    const originalText = submitButton.textContent;
    submitButton.innerHTML = '<span class="loading"></span> Subscribing...';
    submitButton.disabled = true;
    
    setTimeout(() => {
        // Show success message
        messageDiv.classList.remove('hidden');
        
        // Reset form
        emailInput.value = '';
        submitButton.textContent = originalText;
        submitButton.disabled = false;
        
        // Hide message after 5 seconds
        setTimeout(() => {
            messageDiv.classList.add('hidden');
        }, 5000);
        
        // In a real app, you would send the email to your backend
        console.log('Subscribed email:', emailInput.value);
    }, 1500);
});

// Intersection Observer for fade-in animations
const observerOptions = {
    threshold: 0.1,
    rootMargin: '0px 0px -50px 0px'
};

const observer = new IntersectionObserver(function(entries) {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            entry.target.classList.add('is-visible');
        }
    });
}, observerOptions);

// Observe all sections with fade-in class
document.addEventListener('DOMContentLoaded', function() {
    const fadeSections = document.querySelectorAll('section');
    fadeSections.forEach(section => {
        section.classList.add('fade-in-section');
        observer.observe(section);
    });
});

// Add parallax effect to hero section
window.addEventListener('scroll', function() {
    const scrolled = window.pageYOffset;
    const heroImage = document.querySelector('.hero-image');
    if (heroImage) {
        heroImage.style.transform = `translateY(${scrolled * 0.5}px)`;
    }
});

// Mobile menu toggle (if needed)
function toggleMobileMenu() {
    const mobileMenu = document.getElementById('mobileMenu');
    if (mobileMenu) {
        mobileMenu.classList.toggle('hidden');
    }
}

// Lazy loading for images
document.addEventListener('DOMContentLoaded', function() {
    const images = document.querySelectorAll('img[data-src]');
    
    const imageObserver = new IntersectionObserver((entries, observer) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                const img = entry.target;
                img.src = img.dataset.src;
                img.classList.remove('lazy');
                imageObserver.unobserve(img);
            }
        });
    });
    
    images.forEach(img => imageObserver.observe(img));
});

// Add year to footer
function updateYear() {
    const yearElements = document.querySelectorAll('.current-year');
    const currentYear = new Date().getFullYear();
    yearElements.forEach(element => {
        element.textContent = currentYear;
    });
}

document.addEventListener('DOMContentLoaded', updateYear);

// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
    anchor.addEventListener('click', function (e) {
        e.preventDefault();
        const target = document.querySelector(this.getAttribute('href'));
        if (target) {
            target.scrollIntoView({
                behavior: 'smooth',
                block: 'start'
            });
        }
    });
});

// Search functionality (placeholder)
function searchStories(query) {
    console.log('Searching for:', query);
    // Implement search logic here
}

// Filter stories by category
function filterByCategory(category) {
    const stories = document.querySelectorAll('[data-category]');
    stories.forEach(story => {
        if (category === 'all' || story.dataset.category === category) {
            story.style.display = 'block';
        } else {
            story.style.display = 'none';
        }
    });
}

// Add to favorites
function addToFavorites(storyId) {
    let favorites = JSON.parse(localStorage.getItem('favorites') || '[]');
    if (!favorites.includes(storyId)) {
        favorites.push(storyId);
        localStorage.setItem('favorites', JSON.stringify(favorites));
        console.log('Added to favorites:', storyId);
    }
}

// Dark mode toggle (if implementing)
function toggleDarkMode() {
    document.body.classList.toggle('dark-mode');
    localStorage.setItem('darkMode', document.body.classList.contains('dark-mode'));
}

// Load dark mode preference
document.addEventListener('DOMContentLoaded', function() {
    const darkMode = localStorage.getItem('darkMode') === 'true';
    if (darkMode) {
        document.body.classList.add('dark-mode');
    }
});