// --- API KEYS AND CONFIG --- const TRAVELPAYOUTS_MARKER = '634425'; const AMADEUS_API_KEY = 'wnxdD8f2YGFwGBNqA7hXafKbIL4gsojf'; // 🔒 IMPORTANT: The Amadeus API Secret should NOT be stored here in production. // See the security note at the end of this guide. const AMADEUS_API_SECRET = 'NafcUGE85nx0RPVO'; let amadeusAccessToken = null; // --- 1. GOOGLE PLACES AUTOCOMPLETE --- function initAutocomplete() { const autocompleteOptions = { types: ['(cities)', 'airport'] }; // Hero Search new google.maps.places.Autocomplete(document.getElementById('from-input'), autocompleteOptions); new google.maps.places.Autocomplete(document.getElementById('to-input'), autocompleteOptions); // Tracker Search new google.maps.places.Autocomplete(document.getElementById('tracker-from-input'), autocompleteOptions); new google.maps.places.Autocomplete(document.getElementById('tracker-to-input'), autocompleteOptions); // Predictor Search new google.maps.places.Autocomplete(document.getElementById('predictor-from-input'), autocompleteOptions); new google.maps.places.Autocomplete(document.getElementById('predictor-to-input'), autocompleteOptions); // Other Searches new google.maps.places.Autocomplete(document.getElementById('hotel-location-input'), { types: ['(cities)'] }); new google.maps.places.Autocomplete(document.getElementById('hostel-location-input'), { types: ['(cities)'] }); new google.maps.places.Autocomplete(document.getElementById('car-pickup-location-input'), { types: ['(cities)', 'airport'] }); } // --- 2. AMADEUS API FLIGHT LOGIC --- async function getAmadeusToken() { // Note: This is a client-side token request for demonstration. // In production, this should be handled server-side to protect your API Secret. if (amadeusAccessToken) return amadeusAccessToken; try { const response = await fetch('https://test.api.amadeus.com/v1/security/oauth2/token', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: `grant_type=client_credentials&client_id=${AMADEUS_API_KEY}&client_secret=${AMADEUS_API_SECRET}` }); const data = await response.json(); amadeusAccessToken = data.access_token; setTimeout(() => { amadeusAccessToken = null; }, (data.expires_in - 300) * 1000); return amadeusAccessToken; } catch (error) { console.error("Amadeus Auth Error:", error); return null; } } async function getIataCode(place) { // This is a simplified function. A real implementation would use Google's Geocoding API // or a dedicated IATA code lookup service to convert the place name to a code. // For now, we will return a placeholder or extract from input if possible. console.warn("getIataCode is a placeholder. You need to implement a real IATA lookup."); return "LHR"; // Placeholder } // --- 3. DYNAMIC SEARCH FUNCTIONS --- async function searchDeals() { // This function will now power the main hero search showAudienceTab('all-travel', document.getElementById('all-travel-btn')); const fromInput = document.getElementById('from-input').value; const toInput = document.getElementById('to-input').value; const dateInput = document.getElementById('date-input').value; const dealsGrid = document.getElementById('deals-grid'); if (!fromInput || !toInput || !dateInput) { alert("Please provide an origin, destination, and departure date."); return; } dealsGrid.innerHTML = '

✈️ Searching for flights...

'; // In a real application, you would convert user-friendly names to IATA codes here. const originIata = await getIataCode(fromInput); const destinationIata = await getIataCode(toInput); const token = await getAmadeusToken(); if (!token) { dealsGrid.innerHTML = '

Could not connect to flight service. Please try again later.

'; return; } try { const url = `https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=${originIata}&destinationLocationCode=${destinationIata}&departureDate=${dateInput}&adults=1&nonStop=false&max=6`; const response = await fetch(url, { headers: { 'Authorization': `Bearer ${token}` }}); if (!response.ok) throw new Error(`API Error: ${response.statusText}`); const data = await response.json(); if (data.data.length === 0) { dealsGrid.innerHTML = '

No flights found for this route. Please try another search.

'; return; } // Generate dynamic Travelpayout affiliate links const aviasalesLink = `https://www.travelpayouts.com/click?shmarker=${TRAVELPAYOUTS_MARKER}&promo_id=4047&origin_iata=${originIata}&destination_iata=${destinationIata}&trip_class=0&adults=1&with_request=true`; grid.innerHTML = data.data.map(deal => `

${deal.itineraries[0].segments[0].departure.iataCode} → ${deal.itineraries[0].segments.slice(-1)[0].arrival.iataCode}

${deal.itineraries[0].segments.length - 1} stop(s) via ${deal.validatingAirlineCodes[0]}

$${deal.price.total}

View Deal →
`).join(''); } catch (error) { console.error("Flight Search Error:", error); dealsGrid.innerHTML = '

An error occurred while searching for flights.

'; } } function searchHotels() { const location = document.getElementById('hotel-location-input').value; if (!location) { alert("Please enter a city or hotel name."); return; } const url = `https://search.hotellook.com/?marker=${TRAVELPAYOUTS_MARKER}&destination=${encodeURIComponent(location)}&language=en`; window.open(url, '_blank'); } function searchHostels() { const location = document.getElementById('hostel-location-input').value; if (!location) { alert("Please enter a city."); return; } // Hotellook is also used for hostels const url = `https://search.hotellook.com/?marker=${TRAVELPAYOUTS_MARKER}&destination=${encodeURIComponent(location)}&language=en`; window.open(url, '_blank'); } function searchCars() { const location = document.getElementById('car-pickup-location-input').value; if (!location) { alert("Please enter a pick-up location."); return; } // Using EconomyBookings.com link from Travelpayout const url = `https://www.travelpayouts.com/click?shmarker=${TRAVELPAYOUTS_MARKER}&promo_id=1415&source_type=link&type=click&trs=201555`; window.open(url, '_blank'); // Note: For a better user experience, you'd find a way to pass the 'location' to the partner site. } function setPriceAlert() { const from = document.getElementById('tracker-from-input').value; const to = document.getElementById('tracker-to-input').value; if (!from || !to) { alert("Please enter an origin and destination for the price alert."); return; } alert(`Price alert for ${from} to ${to} has been set! (This is a demo).`); // Here you would integrate with Amadeus's Flight Price Analysis API or a similar service. } function getPricePrediction() { const from = document.getElementById('predictor-from-input').value; const to = document.getElementById('predictor-to-input').value; const date = document.getElementById('predictor-date-input').value; const container = document.getElementById('prediction-result-container'); if (!from || !to || !date) { alert("Please enter all fields for a prediction."); return; } container.innerHTML = `

🔮 Analyzing historical data for ${from} to ${to}...

`; // This is where you would call your historical data API (e.g., Tefaa or Amadeus). // For this demo, we'll simulate a result. setTimeout(() => { const shouldBuy = Math.random() > 0.5; const confidence = Math.floor(Math.random() * (95 - 75 + 1) + 75); if (shouldBuy) { container.innerHTML = `

Good time to Buy!

Our analysis of historical data suggests prices are lower than average. We are ${confidence}% confident in this prediction.

`; } else { container.innerHTML = `

Consider Waiting.

Prices are currently higher than usual for this route. It may be better to track prices. We are ${confidence}% confident in this prediction.

`; } }, 2000); }

Sarah’s Family Essentials

Sarah’s Recommended Family Travel Gear – Endless Travel Plans
Portrait of Sarah Chen-Anderson

Sarah’s Stress-Free Family Gear

As a mom who has traveled with toddlers, teens, and grandparents, I know that the right gear can be the difference between a stressful trip and a magical one. Every item on this list has been personally tested and approved by my family to make your journey smoother, safer, and more fun for everyone.

On The Go & Transportation

Lightweight Travel Stroller

Lightweight Travel Stroller

A must-have for navigating airports and city streets. Look for one that’s easy to fold with one hand and fits in an overhead bin.

Check Price on Amazon
Kids' Travel Backpack

Kids’ Travel Backpack

Giving your child their own backpack for snacks and toys is a game-changer for their sense of independence and your own bag space.

Check Price on Amazon
Portable Car Seat

FAA-Approved Car Seat / Vest

For safety in rental cars and on the plane. A lightweight, FAA-approved car seat or travel vest is essential for peace of mind.

Check Price on Amazon
Family Sized Toiletry Bag

Hanging Toiletry Bag

Keeping everyone’s toiletries organized in one place is key. A hanging bag saves precious counter space in small hotel bathrooms.

Check Price on Amazon

Entertainment & Activities

Kids' Tablet with Case

Kids’ Tablet & Durable Case

Load it up with downloaded movies, shows, and games before you leave. A durable, kid-proof case is absolutely mandatory.

Check Price on Amazon
Headphone Splitter

Headphone Splitter

Allows two kids to watch the same movie on one device, preventing countless arguments. A simple, cheap, and brilliant invention.

Check Price on Amazon
Travel Games

Magnetic Travel Games

Compact, screen-free entertainment for restaurants or long waits. Magnetic pieces mean you won’t lose them under the airplane seat.

Check Price on Amazon
Kids' Journal

Travel Journal for Kids

A great way to engage older kids. Encourage them to draw what they see, write about their favorite foods, and collect ticket stubs.

Check Price on Amazon

Health & Safety

First-Aid Kit

Family First-Aid Kit

A pre-made kit with everything you need for scrapes, stings, and minor illnesses. Look for one with kid-friendly supplies.

Check Price on Amazon
Hand Sanitizer

Travel-Size Hand Sanitizer

A must for keeping little hands clean on the go. Get a multipack of clip-on bottles to attach to everyone’s bag.

Check Price on Amazon
Sunscreen

Kid-Friendly Mineral Sunscreen

Protect sensitive skin from the sun. A mineral-based (zinc oxide) stick is easy to apply on faces and won’t spill in your bag.

Check Price on Amazon
Portable White Noise Machine

Portable White Noise Machine

Helps babies and toddlers sleep in unfamiliar hotel rooms or noisy environments. A true sleep-saver for the whole family.

Check Price on Amazon

Get the Best Travel Deals & Tips

Join our free newsletter for expert advice, exclusive deals, and travel inspiration delivered straight to your inbox.

EndlessTravel

Your expert guides to smarter travel.

Newsletter

Get the best deals and tips. Subscribe now.

Affiliate Disclosure: This site contains affiliate links, which means we may receive a commission if you click a link and purchase something that we have recommended. While clicking these links won’t cost you any extra money, they will help us keep this site up and running! Thank you for your support!

© 2024 Endless Travel Plans. All Rights Reserved.