-
Notifications
You must be signed in to change notification settings - Fork 6
/
popup.html
124 lines (114 loc) · 3.98 KB
/
popup.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
<head>
<script>
var botRoot = "http://travis-ci.org/";
var botList;
var checkinResults;
var bots;
var failures;
function updateBotList(text) {
var results = (new RegExp('(.*)<\/body>', 'g')).exec(text);
if (!results || results.index < 0) {
console.log("Error: couldn't find bot JSON");
console.log(text);
return;
}
var data;
try {
data = JSON.parse(results[1]);
} catch (e) {
console.dir(e);
console.log(text);
return;
}
if (!data) {
throw new Error("JSON parse fail: " + results[1]);
}
botList = data[0];
checkinResults = data[1];
failures = botList.filter(function(bot) {
return (bot.color != "success");
});
displayFailures();
}
function displayFailures() {
bots.innerText = "";
if (failures.length == 0) {
var anchor = document.createElement("a");
anchor.addEventListener("click", showConsole);
anchor.className = "open";
anchor.innerText = "The tree is completely green.";
bots.appendChild(anchor);
bots.appendChild(document.createTextNode(" (no way!)"));
} else {
var anchor = document.createElement("a");
anchor.addEventListener("click", showFailures);
anchor.innerText = "failures:";
var div = document.createElement("div");
div.appendChild(anchor);
bots.appendChild(div);
failures.forEach(function(bot, i) {
var div = document.createElement("div");
div.className = "bot " + bot.color;
div.addEventListener("click", function() {
// Requires closure for each iteration to retain local value of |i|.
return function() { showBot(i); }
}());
div.innerText = bot.title;
bots.appendChild(div);
});
}
}
function showBot(botIndex) {
var bot = failures[botIndex];
var url = botRoot + "builds/last.json?builder=" + bot.name;
window.open(url);
window.event.stopPropagation();
}
function requestURL(url, callback) {
console.log("requestURL: " + url);
var xhr = new XMLHttpRequest();
try {
xhr.onreadystatechange = function(state) {
if (xhr.readyState == 4) {
var text = xhr.responseText;
//console.log(text);
callback(text);
}
}
xhr.onerror = function(error) {
console.log("xhr error: " + JSON.stringify(error));
console.dir(error);
}
xhr.open("GET", url, true);
xhr.send({});
} catch(e) {
console.log("exception: " + e);
}
}
window.onload = function() {
bots = document.getElementById("bots");
// XHR from onload winds up blocking the load, so we put it in a setTimeout.
window.setTimeout(requestURL, 0, "builds/last.json", updateBotList);
}
</script>
<style>
body{ font-family:sans-serif; font-size:0.8em; overflow:hidden; }
#links{ background-color:#efefef; border:1px solid #ccc; -webkit-border-radius:5px; margin-top:1px; white-space:nowrap; text-align:center; padding:3px; }
a{ text-decoration:underline; color:#444; }
a:hover{ color:#000; cursor:pointer; }
body.big .bot{ -webkit-transition:all .5s ease-out; margin:20px; }
.bot{ cursor:pointer; -webkit-border-radius:5px; margin-top:1px; white-space:nowrap; padding:3px; }
.bot:hover{ border:2px solid #000; padding:2px; }
.open{ color:green; }
.closed{ color:red; }
.running{ background-color:#fffc6c; border:1px solid #c5c56d; }
.notstarted{ border:1px solid #aaa; }
.failure{ background-color:#e98080; border:1px solid #a77272; }
.warnings{ background-color:#ffc343; border:1px solid #c29d46; }
.success{ background-color:#8fdf5f; border:1px solid #4f8530; }
.exception{ background-color:#e0b0ff; border:1px solid #aca0b3; }
</style>
</head>
<body class="big">
<div id="bots">Loading....</div>
</body>