Refactor table cell colouring code to avoid code-repetition
(issue
@@ -230,10 +230,18 @@ define([
document.getElementById("results").innerHTML = xhr.response;
JQ("#tabs").tabs();
JQ('html, body').animate({scrollTop: $("#tabs").offset().top}, 1000);
- JQ('table tr td:first-child').filter(function() { return $(this).text().indexOf("ERROR") === 0; }).parent().css("color", "#C22");
- JQ('table tr td:first-child').filter(function() { return $(this).text().indexOf("WARNING") === 0; }).parent().css("color", "#22C");
- JQ('table tr td:first-child').filter(function() { return $(this).text().indexOf("SKIP") === 0; }).parent().css("color", "#AA4");
- JQ('table tr td:first-child').filter(function() { return $(this).text().indexOf("INFO") === 0; }).parent().css("color", "#AAF");
+
+ var msg_colouring = {
+ "ERROR": "#C22",
+ "WARNING": "#22C",
+ "SKIP": "#AA4",
+ "INFO": "#AAF"
+ };
+ for (var log_type in msg_colouring){
+ JQ('table tr td:first-child').filter(function() {
+ return $(this).text().indexOf(log_type) === 0;
+ }).parent().css("color", msg_colouring[log_type]);
+ }
console.info('Received:', xhr.responseType, xhr.response.byteLength, 'Bytes');
//blob = new Blob([xhr.response], {type: "application/zip"});
