This repository has been archived by the owner on Apr 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
81 lines (67 loc) · 1.66 KB
/
example.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
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>UI Sortable</title>
<script src='build/build.js'></script>
<style>
body {
padding: 80px;
font-family: 'Helvetica Neue';
font-weight: 200;
}
table {
border-spacing: 0;
}
table td {
padding: 4px 8px;
border-bottom: 1px solid #ddd;
}
table thead {
background: #eee;
}
.sortable-placeholder {
outline: 1px dashed #eee;
}
.sortable-placeholder td {
border-bottom: 1px solid #fff;
}
</style>
</head>
<body>
<h2>/r/aww</h2>
<table>
<thead>
<td>author</td>
<td>title</td>
</thead>
<tbody>
</tbody>
</table>
<script>
var jsonp = require('learnboost-jsonp');
var sortable = require('sortable-table');
var body = document.getElementsByTagName('tbody')[0];
jsonp('http://www.reddit.com/r/aww.json', { param: 'jsonp' }, done);
function done(_, res){
var all = res.data.children;
for (var i = 0; i < all.length; ++i) append(all[i].data);
sortable(body).bind();
}
function append(obj){
var tr = document.createElement('tr');
var td = document.createElement('td');
td.textContent = obj.author;
tr.appendChild(td);
td = document.createElement('td');
var a = document.createElement('a');
a.target = '_blank';
a.href = obj.url;
a.textContent = obj.title;
td.appendChild(a);
tr.appendChild(td);
body.appendChild(tr);
}
</script>
</body>
</html>