-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
91 lines (78 loc) · 2.48 KB
/
main.js
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
require.config({
'paths': {
jquery: "lib/jquery.min",
underscore: "lib/underscore-min",
backbone: "lib/backbone-min",
marionette: 'lib/backbone.marionette',
github: 'marionette.github',
base64: 'lib/base64'
},
shim: {
jquery: {
exports: 'jQuery'
},
underscore: {
exports: '_'
},
github: {
deps: ['underscore', 'base64', 'backbone', 'jquery', 'marionette'],
exports: 'Github'
},
backbone: {
deps: ['jquery', 'underscore'],
exports: 'Backbone'
},
marionette: {
deps: ['backbone'],
exports: 'Marionette'
},
}
});
require(['github', 'marionette', 'widgets/repositories'], function (Github, Marionette, Repos) {
var MyApp = new Marionette.Application();
MyApp.addRegions({
repos: "#repos",
branches: "#branches"
});
var github = new Github({username: 'umlsynco', token: '60ff53bafae6051c7f3f1efee38abfe8f8385741'});
var user = github.getUser('umlsynco');
user.fetch();
user.on("sync", function (x, y, z) {
});
var repos = user.getRepositories();
MyApp.addInitializer(function (options) {
// do useful stuff here
var myView = new Repos({
collection: repos
});
MyApp.repos.show(myView);
repos.on("sync", function() {
myView.render();
});
repos.fetch({add:true, remove: false, merge: false});
/*
repos.on("add", function (repo) {
var default_branch = repo.get("default_branch");
var branches = repo.getBranches();
branches.on("sync", function () {
var branch = branches.getBranch(default_branch);
if (branch) {
branch.on("sync", function () {
var tree = branch.getTree();
tree.fetch({success: function (data) {
// alert("HANDLE SUCCESS !!!");
}}); // Fetch root level
tree.on("add", function (model) {
// tree.loadSubTree(model);
});
github.commit(branch, tree, "message");
});
branch.fetch();
}
});
branches.fetch();
});
*/
}); // APP INITIALIZER
MyApp.start();
});