-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgithub.js
More file actions
47 lines (40 loc) · 1.7 KB
/
github.js
File metadata and controls
47 lines (40 loc) · 1.7 KB
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
var dale = window.dale, teishi = window.teishi, lith = window.lith, c = window.c, B = window.B;
var type = teishi.type, clog = teishi.clog, style = lith.css.style;
B.mrespond ([
['initialize', [], function (x) {
B.mount ('body', view);
B.call (x, 'refresh', []);
}],
['refresh', [], function (x) {
var SUGGESTIONS = 3;
dale.go (dale.times (SUGGESTIONS, 0), function (index) {
B.call (x, 'retrieve', 'suggestion', index);
});
}],
['retrieve', 'suggestion', function (x, index) {
B.call (x, 'set', ['suggestions', index], {}); // Immediately clear the suggestion.
var randomOffset = Math.floor (Math.random () * 500);
c.ajax ('get', 'https://api.github.com/users?since=' + randomOffset, {}, '', function (error, rs) {
if (error) return console.log ('There was an error', error.responseText);
B.call (x, 'set', ['suggestions', index], rs.body [0]);
});
}],
]);
var view = function () {
return B.view (['suggestions'], function (suggestions) {
return ['div', {class: 'container'}, [
['div', {class: 'header'}, [
['h2', 'Who to follow'],
['a', {href: '#', onclick: B.ev ('refresh', [])}, 'Refresh']
]],
['ul', {class: 'suggestions'}, dale.go (suggestions, function (suggestion, index) {
return ['li', {class: 'suggestion'}, [
['img', {src: suggestion.avatar_url}],
['a', {href: suggestion.html_url, target: '_blank', class: 'username'}, suggestion.login],
['a', {href: '#', class: 'close', onclick: B.ev ('retrieve', 'suggestion', index)}, 'X'],
]];
})],
]];
});
}
B.call ('initialize', []);