forked from 1301yashraj/fleet-lock-616
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecondGoa.js
95 lines (74 loc) · 2.95 KB
/
secondGoa.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
let websiteData=JSON.parse(localStorage.getItem("data_city"))
console.log(websiteData)
let mapOnPage=document.querySelector("#gmap_canvas")
mapOnPage.src=`https://maps.google.com/maps?q=${websiteData[0].city}${websiteData[0].country}&t=&z=13&ie=UTF8&iwloc=&output=embed`
let container=document.querySelector("#dataContainer")
let total=document.querySelector("#total")
total.innerText=`Total Result ${websiteData.length}0`
function sort(){
let val=document.querySelector("#SortByPrice");
if(val.value=="Relevance"){
displayData(websiteData)
console.log(val.value)
}else if(val.value=="Low To High"){
websiteData.sort(function(a,b){
return a.costpernight-b.costpernight;
})
console.log(val.value)
container.innerHTML=null;
displayData(websiteData)
}else{
websiteData.sort(function(a,b){
return b.costpernight-a.costpernight;
})
console.log(val.value)
container.innerHTML=null;
displayData(websiteData)
}
}
for(let i=0;i<5;i++){
displayData(websiteData)
}
function displayData(data){
data.forEach(function(elem){
let div=document.createElement("div")
let div1=document.createElement("div")
let a=document.createElement("a")
let div2=document.createElement("div")
div.setAttribute("id","cont")
div2.setAttribute("id","cont2")
a.onclick=function(){
saveInLocal(elem)
a.href="#"
}
let image=document.createElement("img")
image.src=elem.img_url;
let ref=document.createElement("p")
ref.innerText=`Ref Id #${elem.refid}`
ref.style.color="grey"
let type=document.createElement("p")
type.innerText=`${elem.type_of_property} Stay`
type.style.color="blue"
let city=document.createElement("p")
city.innerText=`${elem.city}, ${elem.country}`
let title=document.createElement("p")
title.innerText=elem.title
let additional=document.createElement("p")
additional.innerText=`${elem.type_of_property}| AC| ${elem.bathroom}Bath| ${elem.bedroom}Bed| `
additional.style.color="blue"
let price=document.createElement("p")
price.innerText=`₹${elem.costpernight} per night`
div2.append(ref,title,type,city,additional,price)
div1.append(image)
div.append(div1,div2)
a.append(div)
container.append(a)
})
}
function saveInLocal(elem){
let bookdata=[];
bookdata.push(elem)
localStorage.setItem("book",JSON.stringify(bookdata))
window.location.href="booking_TU.html"
console.log(bookdata)
}