-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
65 lines (62 loc) · 2.37 KB
/
demo.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
<!doctype html>
<html>
<head>
<title>RTable demo</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap-theme.min.css">
</head>
<body>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.6/react-with-addons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.6/react-dom.min.js"></script>
<script src="dist/rtable.js"></script>
<div class="container">
<h1><a href="https://github.com/Kos/rtable">RTable</a> demo</h1>
<p>Uses Github API as the example data source.</p>
<div id="react-container"</div>
</div>
<script>
var GithubCommits = new RTable.AjaxDataSource({
baseUrl: 'https://api.github.com/repos/tomchristie/django-rest-framework/commits?per_page=10',
onResponse: function(response) {
return {
count: null,
next: response.getUrlParamFromLinkHeader('page', 'next'),
previous: response.getUrlParamFromLinkHeader('page', 'prev'),
results: response.json
};
}
});
function pre(str) {
return React.createElement('pre', { style: { 'whiteSpace': 'pre-wrap' }}, str);
}
function img(src, width) {
return React.createElement("img", { src: src, width: width });
}
ReactDOM.render(
React.createElement(RTable, {
dataSource: GithubCommits,
columns: [
{name: "author_avatar", label: "", get: function(commit) { return commit.author ? img(commit.author.avatar_url, 48) : ''; }},
{name: "author", label: "Author", get: function(commit) { return commit.commit.author.name; }},
{name: "sha", label: "#"},
{name: "msg", label: "Message", get: function(commit) { return pre(commit.commit.message); }},
],
filters: [
{'label': 'Path', 'name': 'path'},
{'label': 'Version', 'name': 'sha', 'choices': [
'master',
'gh-pages',
'3.3.2',
'3.3.1',
'3.3.0',
'3.2.5',
'3.2.3',
]},
]
}),
document.getElementById('react-container')
);
</script>
</body>
</html>