generated from pystol/.github
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
278 lines (263 loc) · 9.79 KB
/
index.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<!--
*
* Copyright 2019 pystol.org - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author: Carlos Camacho <carloscamachoucv@gmail.com>
*
-->
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<!--
Basic information
-->
<title>Badgeboard - pystol.org</title>
<link rel="icon" href="assets/images/favicon.png">
<meta name="keywords" content="dashboard, badges, html, report, information radiator, pystol"/>
<meta name="description" content="Dashboard to show your badges information, clear and straight in your project monitor"/>
<meta name="subject" content="Badgeboard, your status badges as a CI dashboard">
<meta name="copyright"content="Pystol - badgeboard - www.pystol.org">
<meta name="language" content="EN">
<meta name="url" content="https://www.pystol.org/badgeboard">
<meta name="identifier-URL" content="https://www.pystol.org/badgeboard">
<!--
Includes
-->
<link rel="stylesheet" type="text/css" href="assets/css/demo.css">
<link rel="stylesheet" type="text/css" href="assets/css/custom.css">
<link rel="stylesheet" type="text/css" href="assets/css/jquery.gridster.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="assets/js/jquery.gridster.min.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/js/ntc.js"></script>
<script src="assets/data_source/badges_list.js"></script>
<link rel="stylesheet" type="text/css" href="http://dashingdemo.herokuapp.com/assets/application.css">
<link rel="stylesheet" type="text/css" href="assets/css/badgeboard.css">
</head>
<body data-gr-c-s-loaded="true">
<div id="container">
<div class="gridster ready" style="width: 1240px;">
<ul id='widgetBoard' style="height: 740px; position: relative;"></ul>
</div>
</div>
<script>
$(document).ready(function(){
var gridster = null;
gridster = $(".gridster ul").gridster({
widget_base_dimensions: ['auto', 140],
autogenerate_stylesheet: true,
min_cols: 1,
max_cols: 6,
widget_margins: [5, 5],
resize: {
enabled: true
}
}).data('gridster');
$('.gridster ul').css({'padding': '0'});
fillDashobard(gridster);
});
function procResponse(gridster,data,i){
if(data != null){
/*
Here we will process the badges as we need to
render the widget color based on the pixel data
from the badge SVG file.
*/
var serializedSVG = new XMLSerializer().serializeToString(data);
var base64Data = window.btoa(serializedSVG);
console.log("data:image/svg+xml;base64," + base64Data);
var img = new Image();
img.src = "data:image/svg+xml;base64," + base64Data;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
img.onload = function() {
ctx.drawImage(img, 0, 0);
img.style.display = 'none';
var x=i['measure'].x;
var y=i['measure'].y;
var data = ctx.getImageData(x, y, 1, 1).data;
var rgb = [ data[0], data[1], data[2] ];
var color_widget_type = "status-undefined";
for (var colo in i['colors']) {
/*
colo variable has the aray index to get the color based
on the rgb pixel data.
*/
if(String(rgb) === String(i['colors'][colo][1])){
color_widget_type = i['colors'][colo][0];
break;
}
}
if (color_widget_type === "status-undefined"){
/*
If this condition is met, it means that we were not able to
match exactly the measured color with the corresponding RGB
value in badges_list.js. In this case, we will try to make a
safe default check to verify common colors based on the RGB data.
*/
console.log('There is not a direct match between the measured color and the config');
r = rgb[0].toString(16);
g = rgb[1].toString(16);
b = rgb[2].toString(16);
if (r.length == 1)
r = "0" + r;
if (g.length == 1)
g = "0" + g;
if (b.length == 1)
b = "0" + b;
var n_match = ntc.name(String("#" + r + g + b));
switch (n_match[3]) {
case 'Red':
color_widget_type = "status-warning";
break;
case 'Orange':
color_widget_type = "widget-text";
break;
case 'Yellow':
color_widget_type = "status-danger";
break;
case 'Green':
color_widget_type = "status-good";
break;
case 'Blue':
color_widget_type = "widget-ocean";
break;
case 'Violet':
color_widget_type = "widget-meter";
break;
case 'Brown':
color_widget_type = "status-warning";
break;
case 'Black':
color_widget_type = "status-warning";
break;
case 'Grey':
color_widget_type = "status-undefined";
break;
case 'White':
color_widget_type = "widget-logo";
break;
}
}
var widget = "\
<li> \
<div class='widget "+color_widget_type+"'> \
<h1 class='title'>"+i['title']+"</h1> \
<a class='more-info' target='_blank' href='"+i['link']+"'> \
<p class='updated-at'>"+i['description']+"</p> \
</a> \
</div> \
</li> \
";
gridster.add_widget.apply(gridster, [widget, i['size'].x, i['size'].y, i['position'].x, i['position'].y]);
};
}else{
/*
Here we will process all the other types of widgets
like the logo, clock and text.
*/
var widget = '';
var expr = i['type'];
switch(expr){
case 'clock':
/* The clock widget goes here*/
var widget = "\
<li> \
<div class='widget "+i['color']+"'> \
<h1 class='title' id='datebox'</h1> \
<h3 id='timebox'></h3> \
<p class='updated-at' id='daybox'></p> \
</div> \
</li> \
";
gridster.add_widget.apply(gridster, [widget, i['size'].x, i['size'].y, i['position'].x, i['position'].y]);
GetClock();
setInterval(GetClock,1000);
break;
case 'picture':
/* The picture widget goes here*/
var widget = "\
<li> \
<div class='widget "+i['color']+"'> \
<img src="+i['src']+"> \
</div> \
</li> \
";
gridster.add_widget.apply(gridster, [widget, i['size'].x, i['size'].y, i['position'].x, i['position'].y]);
break;
case 'text':
/* The picture widget goes here*/
var widget = "\
<li> \
<div class='widget "+i['color']+"'> \
<h1 class='title'>"+i['title']+"</h1> \
<h3>"+i['subtitle']+"</h3> \
<p class='updated-at'>"+i['description']+"</p> \
</div> \
</li> \
";
gridster.add_widget.apply(gridster, [widget, i['size'].x, i['size'].y, i['position'].x, i['position'].y]);
break;
}
}
}
function retrieveData(i,gridster){
if(i['type'] === 'badge'){
$.ajax({
url: i['uri'],
type: 'GET',
success: function (data) {
procResponse(gridster,data,i);
},
error: function(data) {
console.log(data);
}
});
}else{
procResponse(gridster,null,i);
}
}
function fillDashobard(gridster) {
/*
badges is a json global variable defined in
badges_list.js
It is the data source with the information from
the badges we will like to create.
*/
for (var i in badges) {
retrieveData(badges[i],gridster);
}
}
function GetClock(){
tday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
tmonth=new Array("Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sept.","Oct.","Nov.","Dec.");
var d=new Date();
var nday=d.getDay(),nmonth=d.getMonth(),ndate=d.getDate(),nyear=d.getYear(),nhour=d.getHours(),nmin=d.getMinutes(),nsec=d.getSeconds(),ap;
if(nhour==0){ap=" AM";nhour=12;}
else if(nhour<12){ap=" AM";}
else if(nhour==12){ap=" PM";}
else if(nhour>12){ap=" PM";nhour-=12;}
if(nyear<1000) nyear+=1900;
if(nmin<=9) nmin="0"+nmin;
if(nsec<=9) nsec="0"+nsec;
document.getElementById('daybox').innerHTML=tday[nday];
document.getElementById('datebox').innerHTML=tmonth[nmonth]+" "+ndate+", "+nyear;
document.getElementById('timebox').innerHTML=nhour+":"+nmin+":"+nsec+ap+"";
}
</script>
<footer>
<p style="text-align:center;"><a href="https://github.com/pystol/badgeboard">Changes, fixes and improvements for badgeboard can be submitted via pull requests</a></p>
</footer>
</body>
</html>