-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
62 lines (47 loc) · 1.8 KB
/
main.js
File metadata and controls
62 lines (47 loc) · 1.8 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var github_url = 'https://api.github.com/orgs/EXIT-kr'
$(document).ready(function(){
$.ajax({
url: github_url + '/events',
type: 'GET',
crossDomain: true,
success: function (data) {
var m = moment();
console.log(m);
for(var i = 0; i < 20; i++){
var event = data[i];
console.log(event);
var actor = event.actor;
var repo = event.repo;
var type = event.type;
var date = event.created_at;
var payload = event.payload;
console.log(repo.name);
// 오늘로부터 며칠이 지났는지 알 수 있는 함수
// Moment.js를 이용한다.
console.log( moment().diff(moment(date), "days") + "day");
var msg = $('#github_msg').text('');
switch (type) {
case "CreateEvent":
msg.append($('<i/>').attr('class', 'xi-branch xi-x'))
msg.append($('<a/>').attr('href', actor.url).text(actor.login));
if(payload.ref_type == "branch"){
msg.append(' created branch ' + payload.ref + ' at ');
msg.append($('<a/>').attr('href', repo.url).text(repo.name))
}
else if(payload.ref_type == "repository"){
msg.append(' created repository ' );
msg.append($('<a/>').attr('href', repo.url).text(repo.name))
}
break;
case "PushEvent":
msg.append($('<i/>').attr('class', 'xi-log xi-x'))
msg.append($('<a/>').attr('href', actor.url).text(actor.login));
msg.append(' pushed to ' + payload.ref + ' at ');
msg.append($('<a/>').attr('href', repo.url).text(repo.name))
break;
default:
}
}
}
})
});