forked from Samsung/restful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.html
77 lines (68 loc) · 2.77 KB
/
profile.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>User/Profile</title>
<link rel="stylesheet" type="text/css" href="/restful/css/style.css"/>
<script type="text/javascript" src="/restful/js/restful.js"></script>
<script type="text/javascript">
// window.onload
window.onload = function() {
var endpoint = "/restful/api/user/profile";
ajaxCall('GET', endpoint, null, null, function(data) {
var status = data.status;
if (status == 'OK') {
success(data);
}
}, function(data) {
fail(data);
}
);
};
// Success function
function success(data) {
var html = "";
if (data.response != null) {
var user = data.response;
html += "userid : " + user.name + "<br/>";
html += "username : " + user.username + "<br/>";
html += "role : " + user.role + "<br/>";
}
html += "<div style=\"text-align:center;\"><input type=\"button\" value=\"Sign Out\" onClick=\"signout()\"></div>";
document.getElementById('user').innerHTML = html;
}
// Fail function
function fail(data) {
var html = data.response;
document.getElementById('user').innerHTML = html;
}
// Sign Out
function signout() {
var url = "/restful/api/user/signout";
ajaxCall('GET', url, null, null, function(data) {
var status = data.status;
if (status == 'OK') {
location.reload(true);
}
},
function(data) {
alert(data.response);
}
);
}
</script>
</head>
<body>
<p>Profile</p>
<table style="width: 200px;">
<tr>
<td colspan="3"><div id="user"></div></td>
</tr>
<tr>
<td align="left"><a href="signin.html">Sign In</a></td>
<td align="center"><a href="signup.html">Sign Up</a></td>
<td align="right"><a href="update.html">Setting</a></td>
</tr>
</table>
</body>
</html>