Created
March 27, 2009 20:31
-
-
Save tghw/86879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Set Working On | |
// @namespace tghw | |
// @description Adds a Working On button to FogBugz's list page | |
// @include *fogbugz.com/* | |
// ==/UserScript== | |
// Change this to true for FogBugz6 | |
var IS_FOGBUGZ_6 = false; | |
// Icons | |
var HG = "http://media.hicks-wright.net/img/hourglass.png"; | |
var FHG = "http://media.hicks-wright.net/img/fullhourglass.png"; | |
// This is where we'll store the old function | |
var oldChangeIxWorkingOn = null; | |
// This is the new changeIxWorkingOn, which sets icons properly | |
function newChangeIxWorkingOn(ix) | |
{ | |
$('img[src='+FHG+']').attr('src', HG); | |
oldChangeIxWorkingOn(ix); | |
$('tr[ix='+ix+']').find('.swo img').attr('src', FHG); | |
} | |
function main() | |
{ | |
oldChangeIxWorkingOn = unsafeWindow.changeIxWorkingOn; | |
unsafeWindow.changeIxWorkingOn = newChangeIxWorkingOn; | |
$('table#bugGrid th.col_0').each(function(){ | |
$(this).clone().insertAfter(this); | |
}); | |
$('table#bugGrid td.col_0').each(function(){ | |
var ix = $(this).parent().attr('ix'); | |
var wo = $('<TD>'); | |
wo.addClass('swo'); | |
wo.html('<div><span><img width="16" height="16" class="catIcon" title="Set Working On to ' + ix + '" src="' + HG + '"/></span></div>'); | |
wo.find('div').click(function(){unsafeWindow.changeIxWorkingOn(ix);return false;}); | |
wo.css('cursor', 'pointer'); | |
wo.insertAfter(this); | |
}); | |
// If we're working on something, set the icon appropriately | |
var m = $('#Menu_Working_On').text().match(/\d+/);; | |
if(m) | |
{ | |
var ixOld = m[0]; | |
$('tr[ix='+ixOld+']').find('.swo img').attr('src', FHG); | |
} | |
} | |
// Add jQuery | |
if(IS_FOGBUGZ_6) | |
{ | |
var GM_JQ = document.createElement('script'); | |
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js'; | |
GM_JQ.type = 'text/javascript'; | |
document.getElementsByTagName('head')[0].appendChild(GM_JQ); | |
} | |
// Check if jQuery's loaded | |
function GM_wait() { | |
if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); } | |
else { $ = unsafeWindow.jQuery; main(); } | |
} | |
GM_wait(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment