forked from k33g/gh3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path07-gists.html
94 lines (67 loc) · 2.06 KB
/
07-gists.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>gh3</title>
</head>
<body>
<h1></h1>
<h2></h2>
<ul></ul>
<script src="../vendors/jquery-2.1.0.min.js"></script>
<script src="../vendors/underscore-min.js"></script>
<script src="../gh3.js"></script>
<script>
var gistsList = $("ul");
var GistsOfK33g = new Gh3.Gists(new Gh3.User("k33g"));
GistsOfK33g.fetch({page:1, per_page:15}, "next", function (err, res) {
if(err) {
throw "outch ..."
}
console.log(GistsOfK33g.getGists());
GistsOfK33g.eachGist(function (gist) {
//console.log(gist.description, gist.id);
gistsList.append('<li>'+gist.description+" "+gist.id);
});
});
var AllGistsOfK33g = new Gh3.Gists(new Gh3.User("k33g"));
AllGistsOfK33g.fetch({page:1, per_page:500}, null, function (err, res) {
if(err) {
throw "outch ..."
}
//console.log("All gists : ", AllGistsOfK33g.getGists());
console.log("Filtered gists : ", AllGistsOfK33g.filter(function (gist) {
return gist.comments > 0;
}));
});
var oneGist = new Gh3.Gist({id:"2287018"});
oneGist.fetchContents(function (err, res) {
if(err) {
throw "outch ..."
}
console.log("oneGist : ", oneGist);
console.log("Files : ", oneGist.files);
console.log(oneGist.getFileByName("use.thing.js").content);
oneGist.eachFile(function (file) {
console.log(file.filename, file.language, file.type, file.size);
});
});
var anOtherGist = new Gh3.Gist({id:"1096826"});
anOtherGist.fetchContents(function (err, res) {
if(err) {
throw "outch ..."
}
console.log("anOtherGist : ", anOtherGist);
console.log("Files : ", anOtherGist.files);
anOtherGist.fetchComments(function (err, res) {
if(err) {
throw "outch ..."
}
anOtherGist.eachComment(function (comment) {
console.log(comment.body, "By ", comment.user.login);
});
});
});
</script>
</body>
</html>