Skip to content

Commit

Permalink
Color-code output rows.
Browse files Browse the repository at this point in the history
  • Loading branch information
listen2 committed Jul 11, 2012
1 parent b11f4c4 commit d9fefda
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions flair-check.js
Expand Up @@ -148,6 +148,18 @@ flairs = {



function get_color(d) {
thresh = 0.3
if (d > thresh) {
d = Math.floor((1 - (d - thresh)/(1 - thresh)) * 255);
return "ff" + ("00" + d.toString(16)).slice(-2) + ("00" + d.toString(16)).slice(-2);
} else if (d < thresh) {
d = Math.floor(d/thresh * 255);
return ("00" + d.toString(16)).slice(-2) + "ff" + ("00" + d.toString(16)).slice(-2);
} else {
return "ffffff";
}
}



Expand All @@ -164,11 +176,10 @@ function go() {
s = "<table>";
for (x in r) {
if (r[x][1] !== 0) {
s += "<tr><td>" + r[x][1] + "</td><td>" + r[x][0] + "</td><td>" + r[x][2] + "</td></tr>";
s += "<tr style='background:#" + get_color(r[x][1]) + "'><td>" + r[x][1].toFixed(2) + "</td><td>" + r[x][0] + "</td><td>" + r[x][2] + "</td></tr>";
}
}
s += "</table>";
out.innerHTML = s;
//document.write(dice_coefficient("abc", "abd"));
}

0 comments on commit d9fefda

Please sign in to comment.