-
Notifications
You must be signed in to change notification settings - Fork 1
/
mvstar.js
123 lines (107 loc) · 4.28 KB
/
mvstar.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*global angular */
(function (angular) {
"use strict";
var app = angular.module("mvstar", [], function ($interpolateProvider) {
$interpolateProvider.startSymbol("{[");
$interpolateProvider.endSymbol("]}");
});
// AngularJS: Creating A Service With $http
// http://www.benlesh.com/2013/02/angularjs-creating-service-with-http.html
app.factory("ghService", function ($http, $q) {
return {
getRepoInfo: function (data) {
var ghRepoUrl = "https://api.github.com/repos/",
url = ghRepoUrl + data.repo,
deferred = $q.defer();
data.params = data.params || {};
data.params.callback = "JSON_CALLBACK";
$http.jsonp(url, data)
.success(function (response) {
deferred.resolve(response.data);
}).error(function () {
deferred.reject();
});
return deferred.promise;
}
};
});
app.controller("mvstarCtrl", function ($scope, $q, $filter, ghService) {
var mvstarRepos = [
{repo: "arturadib/agility"},
{repo: "angular/angular.js"},
{repo: "jashkenas/backbone"},
{repo: "batmanjs/batman"},
{repo: "brokenseal/broke-client"},
{repo: "bitovi/canjs"},
{repo: "chaplinjs/chaplin"},
{repo: "cujojs/cujo"},
{repo: "wearefractal/dermis"},
{repo: "creynders/dijon"},
{repo: "dojo/dojo"},
{repo: "emberjs/ember.js"},
{repo: "epitome-mvc/Epitome"},
{repo: "jgallen23/fidel"},
{repo: "flightjs/flight"},
{repo: "marcuswestin/fun"},
{repo: "weepy/o_O"},
{repo: "bitovi/javascriptmvc"},
{repo: "jquery/jquery"},
{repo: "kmalakoff/knockback"},
{repo: "knockout/knockout"},
{repo: "petermichaux/maria"},
{repo: "marionettejs/backbone.marionette"},
{repo: "meteor/meteor"},
{repo: "montagejs/montage"},
{repo: "flams/olives"},
{repo: "polymer/polymer"},
{repo: "rhysbrettbowen/PlastronJS"},
{repo: "puremvc/puremvc-js-multicore-framework"},
{repo: "facebook/react"},
{repo: "Rich-Harris/Ractive"},
{repo: "rappid/rAppid.js"},
{repo: "jrburke/requirejs"},
{repo: "quirkey/sammy"},
{repo: "elabs/serenade.js"},
{repo: "somajs/somajs"},
{repo: "spine/spine"},
{repo: "hay/stapes"},
{repo: "walmartlabs/thorax"},
{repo: "troopjs/troopjs-core"},
{repo: "yui/yui3"}
],
cssRepos = [
{repo: "twbs/bootstrap"},
{repo: "sourcebitsllc/chocolatechip-ui"},
{repo: "zurb/foundation"},
{repo: "yui/pure"},
{repo: "jlukic/Semantic-UI"},
{repo: "topcoat/topcoat"}
],
ghCalls = [];
$scope.mvstarReposInfo = [];
$scope.cssReposInfo = [];
$scope.repoOrderBy = "name";
mvstarRepos.forEach(function (repo) {
var ghCall = ghService.getRepoInfo(repo);
ghCall.then(function (repoInfo) {
$scope.mvstarReposInfo.push(repoInfo);
});
ghCalls.push(ghCall);
});
cssRepos.forEach(function (repo) {
var ghCall = ghService.getRepoInfo(repo);
ghCall.then(function (repoInfo) {
$scope.cssReposInfo.push(repoInfo);
});
ghCalls.push(ghCall);
});
// called when ghCalls are completed: maybe to save the standings
$q.all(ghCalls).then(function () {
// var repos;
// repos = $filter("orderBy")($scope.mvstarReposInfo, "-watchers");
// repos.forEach(function (repo, index) {
// console.log(index + 1, repo.name);
// });
});
});
}(angular));