forked from macc704/kf6apijs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
80 lines (74 loc) · 2.18 KB
/
test.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
<html>
<head>
<script src="jquery.js"></script>
<script src="kf6api.js"></script>
<script>
function loginPressed() {
var serverURL = $('#serverURL').val();
kf6.setBaseURL(serverURL);
var uname = $('#uname').val();
var password = $('#password').val();
kf6.login(uname, password, function() {
getCommunities();
}, function(data) {
alert('login failed: ' + data.status);
});
}
function getCommunities() {
kf6.getCommunities(function(data) {
$('#communities').html('');
data.forEach(function(each) {
var li = '';
li += '<li>';
li += each._community.title;
li += '<input type="button" value="get" onclick="communityPressed(\'' + each.communityId + '\')">';
li += '</li>';
$('#communities').append(li);
});
})
}
function communityPressed(communityId) {
kf6.setCommunity(communityId);
var query = {
pagesize: 1000
};
kf6.getObjects(query, function(data) {
$('#notes').html('<tr><th>Title</th><th>Body</th></tr>');
data.forEach(function(each) {
var tr = '';
tr += '<tr>';
tr += '<td>' + each.title + '</td>';
tr += '<td>' + each.data.body + '</td>';
tr += '</tr>';
$('#notes').append(tr);
});
});
}
</script>
</head>
<body>
<!-- login console -->
<ul>
<li>serverURL:
<input id="serverURL" type="textfield" value="http://localhost:9000/">
</li>
<li>user:
<input id="uname" type="textfield" value="yoshiaki.matsuzawa@gmail.com">
</li>
<li>password:
<input id="password" type="textfield">
</li>
<li>
<input type="button" value="Login" onclick="loginPressed()">
</li>
</ul>
<!-- communities -->
<h1>communities:</h1>
<ul id="communities">
</ul>
<!-- notes -->
<h1>notes:</h1>
<table border="1" id="notes">
</table>
</body>
</html>