-
Notifications
You must be signed in to change notification settings - Fork 0
/
dragonpool.html
138 lines (127 loc) · 2.83 KB
/
dragonpool.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js">
</script>
<link type="text/css" rel="stylesheet"
href="http://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css"/>
<div data-role="header" data-position="fixed">
</div>
</head>
<script>
//load function is called when the page opens, it retrieves the posts in a ul format
function load()
{
$.ajax({
type: "GET",
url: 'http://localhost:8080/posts',
contentType: "application/json; charset=utf-8",
success: function(msg) {
$('#current').html(msg);
},
error: function(msg) {
alert("Error");
}
});
}
function filter(from)
{
$.ajax({
type: "GET",
url: 'http://localhost:8080/filter?from=' + city,
contentType: "application/json; charset=utf-8",
success: function(msg) {
$('#current').html(msg);
},
error: function(msg) {
alert("Error");
}
});
}
function getCities()
{
$.ajax({
type: "GET",
url: 'http://localhost:8080/citylist',
contentType: "application/json; charset=utf-8",
success: function(msg) {
$('#current').html(msg);
},
error: function(msg) {
alert("Error");
}
});
}
function addAccount()
{
var account = {
'username': username,
'password': password,
'email': email,
'firstname': firstname,
'lastname': lastname,
'phone': phone
};
$.ajax({
type: "POST",
url: 'http://localhost:8080/addaccount',
headers: {"Access-Control-Allow-Origin": "*"},
data: account,
dataType: 'text',
contentType: "application/json; charset=utf-8",
success: function(msg) {
alert("Account added!");
},
error: function(msg) {
alert("Error");
}
});
}
function addPost()
{
var post = {
'account_id': id,
'from_loc': from,
'to_loc': to,
'type': type,
'date': date,
'descrption': desc,
'num_riders': num_riders,
};
$.ajax({
type: "POST",
url: 'http://localhost:8080/addpost',
headers: {"Access-Control-Allow-Origin": "*"},
data: post,
dataType: 'text',
contentType: "application/json; charset=utf-8",
success: function(msg) {
alert("Post added!");
},
error: function(msg) {
alert("Error");
}
});
}
function deletePost()
{
var postid = 0;
$.ajax({
type: "GET",
url: 'http://localhost:8080/deletepost&postid=' + postid,
contentType: "application/json; charset=utf-8",
success: function(msg) {
alert("Post deleted!");
},
error: function(msg) {
alert("Error");
}
});
}
</script>
<body onload="load()">
<div align="center" id="current">
</div>
</body>
</html>