-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCardPage.js
96 lines (75 loc) · 2.83 KB
/
CardPage.js
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
const bookNowButton = document.getElementById('book-now');
console.log()
const SubmitBookingFormBtn = document.getElementById("SubmitBookingForm");
SubmitBookingFormBtn.addEventListener("click", (e) => {
e.preventDefault()
let obj = {}
obj.Name = document.getElementById("name").value;
obj.Email = document.getElementById("email").value;
obj.DateOfTravel = document.getElementById("date").value;
obj.Type = document.getElementById("type").value;
obj.Contact = document.getElementById("contactNumber").value;
obj.NoOFTraveller = document.getElementById("numGuests").value;
localStorage.setItem("BookingDetails",JSON.stringify(obj));
const users = JSON.parse(localStorage.getItem(("BookingDetails")));
console.log(users);
window.location.href = './mybooking/mybooking.html';
})
document.addEventListener('DOMContentLoaded', function() {
const urlParams = new URLSearchParams(window.location.search);
const locationId = urlParams.get('id');
if(locationId){
let data = fetchLocationDetails(locationId);
console.log(data);
}
else
{
console.error('Location ID not found in URL parameters.');
}
});
var price,mainLocation;
var data1;
function fetchLocationDetails(locationId){
const locationDetailsUrl = `https://mock-final-copy-api.onrender.com/locations/${locationId}`;
fetch(locationDetailsUrl)
.then(response =>{
if(!response.ok){
throw new Error('HTTP error! Status: ${response.status}');
}
return response.json();
})
.then(data =>{
// data1 = data;
let imageDiv = document.getElementById("imageDiv")
let img = document.createElement("img");
img.setAttribute("src",data.image);
// img.innerHTML = `src="${data.image}" alt="Hello"
// `
img.classList.add("imageInsideDiv");
imageDiv.append(img);
// console.log(img);
mainLocation = data.location;
price = data.price;
document.getElementById('location').textContent = data.location;
document.getElementById('cost-hotel').textContent = `Price: $${data.price}`;
document.getElementById('location-details').textContent = data.description;
return data;
})
.catch(error => {
console.error('Error fetching location details:', error);
});
}
document.addEventListener('DOMContentLoaded', function () {
const logoButton = document.getElementById('Alogo');
logoButton.addEventListener('click', function () {
window.location.href = "./index.html";
});
});
document.addEventListener("DOMContentLoaded", function () {
let logo = document.querySelector(".Rlogo");
if (logo) {
logo.addEventListener("click", function () {
window.location.href = "index.html";
});
}
});