-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaces-selection.html
executable file
·112 lines (91 loc) · 3.62 KB
/
places-selection.html
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Places in Jaipur</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/navbar_css.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Places in <span id="place_name_title"></span></a>
</div>
</div>
</nav>
<script>
document.getElementById('place_name_title').innerHTML = localStorage.getItem("destination");
</script>
<!-- <img class="width-match-parent" src="img/travel-nurse.jpg"> -->
<br>
<div class="container">
<div id="places-list">
</div>
<div class="container-fluid right-aligned">
<button class="btn btn-default" id="button-done">Done!</button>
</div>
</div>
<script>
var all_places;
// localStorage.setItem("destination", "Jaipur");
var fileName = localStorage.getItem("destination") + '.json';
console.log(fileName);
json = $.getJSON('json/' + fileName, function(json){
console.log(json);
all_places = json ;
for(var i in json){
$('#places-list').append(
'<div class="panel panel-default"><img class="width-match-parent" src="' +
json[i]['icon']+
'"> <div class="container-fluid"><h4 class="heading-inline">'+
json[i]['name']+
'</h4> <input type="checkbox" class="right-aligned" name="checkbox-place"></div> </div> </div>'
);
}
});
$('#button-done').click(function(){
var checkboxes = document.getElementsByName('checkbox-place');
var checkedObjects = [];
for(var i=0 ; i<checkboxes.length; i++){
if(checkboxes[i].checked){
console.log(all_places[i]);
console.log('' + all_places[i]['icon']);
$.ajax({
url: 'backend/place_add.php',
type: 'post',
dataType: 'json',
data: JSON.parse('{"group_id":"'+ localStorage.getItem("group_id")+'","summary":"'+all_places[i]['summary']+'","photo_url":"'+all_places[i]['icon']+'","place_name":"'+all_places[i]['name']+'","is_visited":"0"}'),
success: function(data) {
console.log(data);
console.log(data[i]);
}
});
}
}
window.location="booking.html";
});
// https://maps.googleapis.com/maps/api/place/textsearch/json?query=jaipur+point+of+interest&language=en&key=AIzaSyDnNewxVy8XnZtKV4ur54IPo3KNXJwCj8o
// var places_all;
// $.get('https://maps.googleapis.com/maps/api/place/textsearch/json?query=jaipur+point+of+interest&language=en&key=AIzaSyDnNewxVy8XnZtKV4ur54IPo3KNXJwCj8o',
// function(data, status){
// var json = JSON.parse(data);
// console.log('Req: ' + json);
// places_all = json;
// console.log(json);
// });
// url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=jaipur+point+of+interest&language=en&key=AIzaSyDnNewxVy8XnZtKV4ur54IPo3KNXJwCj8o";
// document.body.appendChild((function() {
// var newScript = document.createElement("script");
// newScript.type = "text/javascript";
// newScript.src = url;
// return newScript;
// })());
// function parseResults(data) {
// alert(data);
//}
</script>
</body>
</html>