-
Notifications
You must be signed in to change notification settings - Fork 1
/
pulls.html
106 lines (102 loc) · 2.62 KB
/
pulls.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SciTools pull requests</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<style>
div#cartopy {
float: right;
}
table td {
padding: 0.5em;
}
table td.number {
width: 40px;
}
table td.user {
padding: 0em 3em;
}
img.avatar {
width: 32px;
height: 32px;
}
</style>
</head>
<body>
<h1>SciTools pull requests</h1>
<script>
function render_user(user) {
result = '-';
if (user) {
result = [
$('<img class="avatar" src="' + user.avatar_url + '">'),
' ' + user.login
];
}
return result
}
function show_pulls(pulls) {
if (pulls.length > 0) {
var name = pulls[0].head.repo.name;
var len = pulls.length;
var target = $('#' + name + ' table');
for(var i=0; i < len; i++) {
var pull = pulls[i];
row = $('<tr/>')
row.append('<td class="number"><a href="' + pull.url + '">#' + pull.number + '</a></td>');
cell = $('<td class="user"></td>');
cell.append(render_user(pull.user));
row.append(cell);
cell = $('<td class="user"></td>');
cell.append(render_user(pull.assignee));
row.append(cell);
target.append(row);
}
}
}
$.ajax({
type: 'GET',
url: 'https://api.github.com/repos/SciTools/iris/pulls?callback=foo',
jsonpCallback: 'foo',
contentType: 'application/json',
dataType: 'jsonp',
}).done(function(response) {
show_pulls(response.data);
}).fail(function(request, status, error) {
alert(JSON.stringify(request) + status + error);
});
$.ajax({
type: 'GET',
url: 'https://api.github.com/repos/SciTools/cartopy/pulls?callback=foo',
jsonpCallback: 'foo',
contentType: 'application/json',
dataType: 'jsonp',
}).done(function(response) {
show_pulls(response.data);
}).fail(function(request, status, error) {
alert(JSON.stringify(request) + status + error);
});
</script>
<div id="cartopy">
<h2>Cartopy</h2>
<table>
<tr>
<th>#</th>
<th>Submitted by</th>
<th>Assigned to</th>
</tr>
</table>
</div>
<div id="iris">
<h2>Iris</h2>
<table>
<tr>
<th>#</th>
<th>Submitted by</th>
<th>Assigned to</th>
</tr>
</table>
</div>
</body>
</html>