-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary.php
More file actions
135 lines (113 loc) · 3.17 KB
/
Copy pathlibrary.php
File metadata and controls
135 lines (113 loc) · 3.17 KB
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
<?php
session_start();
include 'connection.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Places Library</title>
<style>
body {
background: #333;
}
header {
height: 50px;
background: #ddd;
}
header nav {
margin: auto;
}
header nav ul {
text-decoration: none;
padding-top: 13px;
text-align: center;
}
header nav ul li {
display: inline;
width: 30px;
padding: 5px;
background:rgb(0, 153, 255);
border-radius: 4px;
}
header nav ul li:hover {
cursor: pointer;
background: #aaa;
color: #fff;
}
header nav ul li a {
text-decoration: none;
color: #222;
}
.content {
width: 60%;
margin: auto;
background: #ddd;
}
.items {
height: 50px;
border: 2px solid #ccc;
margin-bottom: 20px;
background: #fff;
}
.items:hover {
background: rgb(18, 22, 33);
color: #fff;
cursor: pointer;
}
</style>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="home.php">Home</a></li>
<li><a href="#">Saved Places</a></li>
</ul>
</nav>
</header>
<div class="main-wrapper">
<div class="content"></div>
</div>
<script>
var data = new Array();
function getData() {
var i = 0;
var xhttp = new XMLHttpRequest;
xhttp.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200) {
data = JSON.parse(this.responseText);
while(i != data.length) {
var list = data[i];
drawToDOM(list);
i++;
}
}
};
xhttp.open('GET', 'getAllPlaces.php', true);
xhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xhttp.send();
}
function drawToDOM(list) {
var content = document.getElementsByClassName('content')[0];
var items = document.createElement('div');
items.classList.add('items');
var placeDetails = document.createElement('div');
var googleDetails = 'Place: '+list.place + ',' + list.address;
var placeText = document.createTextNode(googleDetails);
placeDetails.appendChild(placeText);
items.appendChild(placeDetails);
var userDetails = document.createElement('div');
var userRatingText = document.createTextNode('Rating: '+list.rating+' ');
var userReviewText = document.createTextNode('Review: '+list.review);
userDetails.appendChild(userRatingText);
userDetails.appendChild(userReviewText);
items.appendChild(userDetails);
content.appendChild(items);
}
getData();
</script>
</body>
</html>