forked from ghtorrent/ghtorrent.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
leanprogress.html
143 lines (113 loc) · 3.9 KB
/
leanprogress.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
layout: page
title: Lean Request Results
group: navigation
---
<script>
if (!Array.prototype.last){
Array.prototype.last = function(){
return this[this.length - 1];
};
};
Function.prototype.extractComment = function() {
var startComment = "/*!";
var endComment = "*/";
var str = this.toString();
var start = str.indexOf(startComment);
var end = str.lastIndexOf(endComment);
return str.slice(start + startComment.length, -(str.length - end));
};
String.prototype.format = function() {
var newStr = this, i = 0;
while (/%s/.test(newStr))
newStr = newStr.replace("%s", arguments[i++])
return newStr;
}
var accTmpl = function() { /*!
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<i data-toggle="tooltip" title="%s" data-placement="top" class="fa fa-%s"></i>
<a data-toggle="collapse" data-parent="#accordion" href="#%s">
%s
</a>
</h4>
</div>
<div id="%s" class="panel-collapse collapse">
<div class="panel-body">
%s
</div>
</div>
</div>*/}.extractComment();
function param(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
$(document).ready(function() {
var req_id = param('id');
if (req_id == null || req_id.length != 40) {
$("#progress").text("No request specified or invalid request id");
return;
}
$.ajax({
url: "http://ghtorrent.org/lean/requests/" + req_id,
success: results,
error: function(xhr, status, exception) {
$("#progress").text("Invalid request id");
}
});
function results(data, status, xhr) {
function idGen() {
return (Math.random() + 1).toString(36).substr(2, 5);
}
var toAppend = Object.keys(data).reduce(function(acc, project, x, y) {
var id = idGen();
var content = data[project].items.reduce(function(acc, item, x, y) {
var itemFmt = '<li><i class="fa-li fa fa-%s"></i>%s: %s</li>';
var d = new Date(item.created_at * 1000);
var ts = "%s/%s/%s %s:%s:%s".format(d.getFullYear(), d.getMonth() + 1,
d.getDay(), d.getHours(), d.getMinutes(), d.getSeconds());
var icon = "";
if (item.status == "ok"){
icon = "check-square";
} else {
icon = "frown-o warncolor";
}
return (acc + itemFmt.format(icon, ts, item.item));
}, '<ul class="fa-ul">');
content = content + "</ul>";
if (data[project].req_status.status == "finished") {
statusIcon = "check-circle";
} else if (data[project].req_status.status == "working") {
statusIcon = "cogs";
} else if (data[project].req_status.status == "stopped") {
statusIcon = "stop";
} else if (data[project].req_status.status == "error") {
statusIcon = "frown-o warncolor";
} else {
statusIcon = "question-circle";
}
var tooltip = "status: %s, last update: %s";
var updts = new Date(data[project].req_status.created_at * 1000);
var upd = "%s/%s/%s %s:%s:%s".format(updts.getFullYear(),
updts.getMonth() + 1, updts.getDay(), updts.getHours(),
updts.getMinutes(), updts.getSeconds());
tooltip = tooltip.format(data[project].req_status.status, upd);
return (acc + accTmpl.format(tooltip, statusIcon, id, project, id, content));
}, "");
$("#accordion").append(toAppend);
$("#expander").show();
$('.fa').tooltip();
}
$("#expander").click(function() {
$('.panel-collapse').collapse({'toggle': true, 'parent': '#accordion'});
});
});
</script>
<a class="btn btn-primary" id="expander" style="display:none"><i class="fa fa-expand fa-fw"></i>Expand all</a>
<div class="panel-group" id="accordion">
<style type = "text/css" scoped>
.warncolor {color:red;}
</style>
</div>
<div id="#progress"></div>