In using FogBugz, I noticed that most of the users didn't like seeing the full history of everywhere a bug had been in its storied life. For particularly old bugs, there might be a full page of "Assigned to Peter", "Assigned to Paul", "Assigned to Mary", "Milestone changed to 1.2.3" et cetera. Since people managing the bugs usually needed to see these 'empty edits' and the people fixing bugs only rarely did, I use BugMonkey to hide the 'empty edits'. I use a session cookie to remember the setting.
Also, I very rarely need to see the full header of an email. We use email as a method for our support staff to submit information about cases. As such, their email should look more like an edit and less like something else. I've reformatted the email so that the header is togglable (default to off) and the emails look more like edits. If the email is an Out of Office Autoreply, hide it.
This will also provide color coding for incoming vs. outgoing emails, so the email chain can be easily scanned for information.
Script:
name: Hide empty edits and tidy up
description: Hides edits with no text, optionally hides email headers, colors incoming and outgoing emails
author: alficles, FogBugz 8 compatibility edits by Quentin Schroeder
version: 1.0.0.0
js:
// Cookie functions (mostly) stolen from some blog on the net.
function createCookie(name, value, days)
{
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var ca = document.cookie.split(';');
var nameEQ = name + "=";
for(var i=0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function eraseCookie(name)
{
createCookie(name, "", -1);
}
$("div.emailHeader").parent().prepend("<div class=\"emailHeaderToggle\">Toggle Email Header</div>");
$("div.emailHeader").each(function(i) {
var whoEle = $(this).find("div.emailHeaderValue:first");
var actEle = whoEle.parents("div.bugevent").find("span.action");
var who = whoEle.text();
var act = actEle.text();
var nameReg = /"([^"]*)"/;
if (!(/^Replied/.exec(act))) {
if (nameReg.test(whoEle.text())) {
actEle.append(" by "+nameReg.exec(who)[1]);
}
else {
actEle.append(" by "+whoEle.html());
}
}
});
$("div.emailHeaderToggle").click(function() {
var emailHeader = $(this).parent().find("div.emailHeader");
var old_val = emailHeader.css("display");
if (old_val == "block") { emailHeader.css("display","none"); }
else { emailHeader.css("display","block"); }
});
var emptyCount = 0;
$(".bugevent").each(function() {
var bodyEle = $(this).find(".body");
var bodyTxt = bodyEle.text();
if (/^[ \t\n]*$/.exec(bodyTxt)) {
$(this).addClass("emptyBody");
emptyCount += 1;
}
});
$(".email .emailHeader .emailHeaderValue").each(function() {
if (/^Out of Office AutoReply/i.exec($(this).text())) {
$(this).parents(".bugevent").addClass("emptyBody");
emptyCount += 1;
}
});
if (emptyCount > 0) {
$("#BugEvents").prepend("<div id=\"EmptyBodyToggle\">Show/Hide Empty Edits ("+emptyCount+")</div>");
}
$("#EmptyBodyToggle").click(function() {
var old_val = $(".emptyBody").css("display");
if (old_val == "block")
{
$(".emptyBody").css("display","none");
createCookie("showEmpty","false");
} else {
$(".emptyBody").css("display","block");
createCookie("showEmpty","true");
}
});
if (readCookie("showEmpty") == "true") {
$(".emptyBody").css("display","block");
}
$(".email").each(function() {
var actions = this.getElementsByClassName('action');
if (actions.length > 0)
if (/Replied/.exec(actions[0].innerText)) {
$(this).children('.body').addClass("outgoing");
}
else { // outgoing message
$(this).children('.body').addClass("incoming");
}
});
css:
div.emailBody {
padding: 0px;
background-color: inherit;
}
div.email {
border: none;
}
div.incoming {
background-color: #E0F5E0 !important; // green
}
div.outgoing {
background-color: #EBF5FF !important; // blue
}
div.emailHeader {
display: none;
border: 1px solid #ADABA8;
margin-bottom: 10px;
margin-top: 5px;
}
div.editable div.emailHeader {
display: block;
}
div.emailHeaderToggle {
font-size: 70%;
font-style: italic;
color: #888;
padding: 2px;
cursor: pointer;
}
div.emailHeaderToggle:hover {
text-decoration: underline;
color: #000;
}
#EmptyBodyToggle {
font-style: italic;
color: #888;
padding-bottom: 7px;
cursor: pointer;
}
#EmptyBodyToggle:hover {
text-decoration: underline;
color: #000;
}
.emptyBody {
display: none;
padding-left: 5px;
margin-left: 5px;
border-left: 3px solid #d6d6d6;
}