-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
54 lines (54 loc) · 1.59 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<title>badgeboard</title>
<base target="_blank"/>
</head>
<body>
<table id="table"></table>
<script>
var ajax = function(url, successCallback, failCallback) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.onreadystatechange = function() {
if (this.readyState === 4) {
if (this.status >= 200 && this.status < 400) {
successCallback(this.responseText);
} else {
failCallback();
}
}
};
request.send();
request = null;
};
var table = document.querySelector('#table');
var group = location.host.split('.')[0];
document.title = 'badgeboard for ' + group;
ajax('//api.github.com/users/' + group + '/repos', function(res) {
var data = JSON.parse(res);
data.forEach(function(item) {
if (!!~location.pathname.indexOf(item.name)) {
return;
}
var row = document.createElement('tr');
var line1 = document.createElement('td');
var name = document.createElement('a');
name.href = item.html_url;
name.innerText = item.name;
line1.appendChild(name);
row.appendChild(line1);
var line2 = document.createElement('td');
var badge = document.createElement('a');
badge.href = '//travis-ci.org/' + item.full_name;
badge.innerHTML = '<img src="//img.shields.io/travis/' + item.full_name + '.svg?style=flat-square" />';
line2.appendChild(badge);
row.appendChild(line2);
table.appendChild(row);
});
});
</script>
</body>
</html>