forked from k33g/gh3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-repository.html
74 lines (57 loc) · 1.69 KB
/
03-repository.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
<!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 k33g = new Gh3.User("k33g")
, repoTitle = $("h1")
, branchTitle = $("h2")
, branchProperties = $("ul");
//get some repositories of k33g
var k33gRepositories = new Gh3.Repositories(k33g);
k33gRepositories.fetch({page:5, per_page:5, direction : "desc"},"next", function (err, res) {
if(err) {
throw "outch ..."
}
console.log("Repositories", k33gRepositories);
});
//get one repository
var k33gBlog = new Gh3.Repository("k33g.github.com", k33g);
k33gBlog.fetch(function (err, res) {
if(err) {
console.log("Error", err.message, res.status)
throw err
}
console.log("Repository : ", k33gBlog);
repoTitle.html(k33gBlog.full_name);
k33gBlog.fetchBranches(function (err, res) {
if(err) {
console.log("Error", err.message, res.status)
throw err
}
console.log("Array of branches : ", k33gBlog.getBranches());
k33gBlog.eachBranch(function (branch) {
console.log(branch.name);
})
//and :
var master = k33gBlog.getBranchByName("master");
branchTitle.html(master.name + " (" + master.sha + ") properties :");
_.each(_.keys(master), function (prop) {
branchProperties.append(
$('<li>').append(prop+" : "+master[prop])
);
});
})
});
</script>
</body>
</html>