Permalink
Browse files

start colouring responses

  • Loading branch information...
1 parent 39a9b5a commit 5ff8411fbcdf856c71852d60946f78c5118ce960 @mnot committed Mar 28, 2011
Showing with 16 additions and 1 deletion.
  1. +16 −1 lib/asset/htracr-data.js
View
@@ -8,6 +8,17 @@ if (! htracr) {
var htracr = {};
}
+htracr.res_colours = {
+ 'text/html': "green",
+ 'text/css': "purple",
+ 'image/gif': "blue",
+ 'image/jpeg': "blue",
+ 'image/png': "blue",
+ 'application/json': "yellow",
+ 'application/xml': "yellow",
+ 'application/x-javascript': "yellow"
+}
+
// An item of interest that will be rendered.
htracr.item = function (data) {
@@ -214,24 +225,28 @@ htracr.http_msg = function(data) {
};
var adj_y;
+ var colour;
switch (self.kind) {
case "req":
adj_y = - (htracr.ui.conn_size / 2) - (htracr.ui.msg_size / 2);
di.save('referer', self.data.headers.Referer, self);
var url = "http://" + self.data.headers.Host + self.data.url;
di.save('request_uri', url, self, true);
+ colour = "red";
break;
case "res":
adj_y = (htracr.ui.conn_size / 2) + (htracr.ui.msg_size / 2);
di.save('location', self.data.headers.Location, self, true);
+ var ct = (self.data.headers['Content-Type'] || "").split(";", 1)[0];
+ colour = htracr.res_colours[ct] || 'red';
break;
default:
console.log("Unknown message type: " + this.kind);
break;
}
var msg_e = di.h_line(self.start, self.end, adj_y, {
- "stroke": "red",
+ "stroke": colour,
"stroke-linecap": "round",
"stroke-width": "" + htracr.ui.msg_size,
"opacity": ".6"

0 comments on commit 5ff8411

Please sign in to comment.