/
radiator.html
137 lines (127 loc) · 3.3 KB
/
radiator.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Build Radiator</title>
</head>
<body bgcolor="black">
<script src="jquery.js"></script>
<script src="jquery.sound.js"></script>
<script src="jquery.blink.js"></script>
<script>
function Radiator(url, status_id, info_id, failure_sound_file, delay, timeout)
{
this.delay = delay;
this.url = url;
this.status_id = status_id;
this.info_id = info_id;
this.failure_sound_file = failure_sound_file;
this.timeout = timeout;
function color_for(data)
{
if (data.result == "SUCCESS") return "green";
if (data.result == null) return "orange";
return "red";
};
this.populate_error = function()
{
$(this.status_id).css("color", "red");
$(this.status_id).css("background-color", "black");
$(this.status_id).html("Connection lost. Rescheduling...");
$(this.info_id).html("");
setTimeout(function(radiator)
{
return function() { radiator.update();};
}(this), this.delay);
};
this.populate = function(data)
{
color = color_for(data)
$(this.status_id).css("background-color", color);
$(this.status_id).css("color", "white");
culprits = "";
for (culprit in data.culprits)
{
culprits = culprits.concat(data.culprits[culprit].fullName + ". ");
}
$(this.status_id).html(data.fullDisplayName);
if (color == "red" && color != this.last_status)
{
$(this.info_id).html(culprits);
$(this.status_id).blink(
{
maxBlinks: 10,
onBlink: function(){},
blinkPeriod: 700,
onMaxBlinks: function(){}
});
// $.fn.soundPlay({url: this.failure_sound_file, playerId: 'embed_player', command: 'play'});
}
else if (color == "red" && color == this.last_status)
{
$(this.info_id).html(culprits);
}
else
{
$(this.info_id).html('');
}
this.last_status = color;
setTimeout(function(radiator)
{
return function() { radiator.update();};
}(this), this.delay);
};
this.update = function()
{
$.ajax({
url: this.url + 'lastBuild/api/json?jsonp=?',
data: null,
timeout: this.timeout,
success: function(radiator)
{
return function(data)
{
radiator.populate(data);
};
}(this),
error: function(radiator)
{
return function(request,status,errorThrown)
{
radiator.populate_error();
};
}(this),
dataType: "jsonp"
});
};
this.init = function()
{
that = this;
$(this.status_id).css({"color": "white", "fontSize": 110, "height": 350, "width": 1200});
$(this.info_id).css({"color": "white", "fontSize": 45, "height": 120, "width": 1200});
that.update();
};
};
$(document).ready(function()
{
new Radiator('http://server/job/job_name1/', '#project_status1', "#culprits_1", '1.mp3', 5000, 2000).init();
new Radiator('http://server/job/job_name2/', '#project_status2', "#culprits_2", '1.mp3', 5000, 2000).init();
});
</script>
<table>
<tr>
<td>
<div id="project_status1" align="center">Loading</div>
<div id="culprits_1" align="center">Loading</div>
</td>
</tr>
<tr>
<td>
<div id="project_status2" align="center">Loading</div>
<div id="culprits_2" align="center">Loading</div>
</td>
</tr>
</table>
<span id="sound_file_name" style="display:none"> </span>
</body>
</html>