forked from twitter/opensource-website
-
Notifications
You must be signed in to change notification settings - Fork 5
/
eKnight.js
executable file
·106 lines (79 loc) · 2.92 KB
/
eKnight.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
App.filter('trust', function($sce) {
return function(text) {
return $sce.trustAsHtml(text);
};
});
/**
*
* @param {type} param1
* @param {type} param2
*/
App.controller('eKnightCtrl', function($scope, HebUtill, issuesLoader, $window, commentsHandler, pieChartService, arrayUtill, $http, $routeParams) {
$scope.relativizePath = $window.CONFIG.relativizePath;
$scope.pieChartService = pieChartService;
$scope.selectedLabels = new Array();
$scope.stateControls = {
showIssuesWithComments: true,
showIssuesWithOutComments: true
};
$scope.eKnight = _.filter(eKnightsData, function(eKnight) {
return eKnight.slug === $routeParams.eKnight;
});
if ($scope.eKnight.length !== 0){// TODO: 404
}
$scope.eKnight = $scope.eKnight[0];
document.title = $scope.eKnight.name;
issuesLoader.load($scope.eKnight.repositories, function(data, labels) {
$scope.issues = data;
$scope.labels = labels;
$scope.updateState = function() {
//debugger;$scope.stateControls = $scope.stateControls;
$scope.$apply();
};
$scope.setSelectedLabels = function() {
var name = this.lbl.name;
if (_.contains($scope.selectedLabels, name))
$scope.selectedLabels = _.without($scope.selectedLabels, name);
else
$scope.selectedLabels.push(name);
return false;
};
$scope.isChecked = function(name) {
if (_.contains($scope.selectedLabels, name))
return 'fa-check';
return false;
};
$scope.loadComments = function(evt, issue) {
$scope.readMore(evt, issue);
var http_request = $http({
method: 'GET',
url: issue.comments_url
});
http_request.success(function(data, status, headers, config) {
var comments_list = new Array();
function loadComments(i) {
if (i === - 1){
commentsHandler.treatComments(comments_list);
// window.console.clear();
// window.console.log(JSON.stringify(comments_list));
issue.comments_list = comments_list;
return;
}
var comment_request = $http({
method: 'GET',
url: data[i].url
});
comment_request.success(function(comment, status, headers, config) {
comments_list.push(comment);
i --;
loadComments(i);
});
}
loadComments(data.length - 1);
});
};
$scope.readMore = function(evt, issue) {
issue.textLimit = 1000000;
};
});
});