forked from k33g/gh3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13-nesteddir.html
69 lines (48 loc) · 1.77 KB
/
13-nesteddir.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
<!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("TypeUnsafe")
, repoTitle = $("h1")
, branchTitle = $("h2")
, dirContents = $("ul");
var k33gBlog = new Gh3.Repository("m33ki", k33g);
k33gBlog.fetch(function (err, res) {
if(err) { throw "outch ..." }
repoTitle.html(k33gBlog.full_name);
k33gBlog.fetchBranches(function (err, res) {
if(err) { throw "outch ..." }
var master = k33gBlog.getBranchByName("master");
branchTitle.html(master.name + " (" + master.sha + ") :");
master.fetchContents(function (err, res) {
if(err) { throw "outch ..." }
var dir = master.getDirByName('console');
dir.fetchContents(function (err, res) {
if(err) { throw "outch ..." }
console.log("Items where type is directory :", dir.getContents().filter(function(item){ return item.type == "dir"}));
var srcConsole = dir.getContents().filter(function(item){ return item.type == "dir"})[0];
srcConsole.fetchContents(function (err, res) {
console.log("Contents of nested directory 'console' :", srcConsole.getContents());
});
dir.reverseContents();
dir.eachContent(function (content) {
console.log(content.name, content.type, content.size);
dirContents.append('<li>'+content.name+" type : "+content.type+" size : "+content.size);
});
});
});
})
});
</script>
</body>
</html>