Skip to content

Instantly share code, notes, and snippets.

@jasonwyatt
Created November 28, 2011 16:58
Show Gist options
  • Save jasonwyatt/1401087 to your computer and use it in GitHub Desktop.
Save jasonwyatt/1401087 to your computer and use it in GitHub Desktop.
TransLoc Trac Beautifier
// ==UserScript==
// @name TL Trac Beautifier
// @namespace https://dev.transloc.com
// @description Makes Trac look much better.
// @include https://dev.transloc.com/*
// ==/UserScript==
var $;
// Add jQuery
(function(){
if (typeof unsafeWindow.jQuery == 'undefined') {
var GM_Head = document.getElementsByTagName('head')[0] || document.documentElement,
GM_JQ = document.createElement('script');
GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
GM_JQ.type = 'text/javascript';
GM_JQ.async = true;
GM_Head.insertBefore(GM_JQ, GM_Head.firstChild);
}
GM_wait();
})();
// Check if jQuery's loaded
function GM_wait() {
if (typeof unsafeWindow.jQuery == 'undefined') {
window.setTimeout(GM_wait, 100);
} else {
$ = unsafeWindow.jQuery.noConflict(true);
letsJQuery();
}
}
// All your GM code must be inside this function
function letsJQuery() {
$('body').css({
width: 1024,
margin: '15px auto'
});
// -----------------------------------------------------
// For the Tickets
// -----------------------------------------------------
var changes = {
fontSize: 14,
verticalAlign: 'middle'
};
var items= ['table.listing tbody', 'table.listing th', 'table.listing td'];
for(var i = 0, len = items.length; i < len; i++){
$(items[i]).css(changes);
}
$('table .type').css({
textAlign: 'center'
}).each(function(){
// Go through and replace the text with an icon
var types = {
'task': '<img src="http://hacks.jwf.us/pretty_trac/icons/page_white_text.png" alt="Task Icon" title="Task" />',
'defect': '<img src="http://hacks.jwf.us/pretty_trac/icons/bug.png" alt="Bug Icon" title="Defect / Bug" />',
'enhancement': '<img src="http://hacks.jwf.us/pretty_trac/icons/star.png" alt="Enhancement Icon" title="Enhancement / New Feature" />'
};
var $this = $(this),
content = $this.text();
content = /(task)|(defect)|(enhancement)/i.exec(content);
if(content && content.length > 0){
$this.html(types[content[0]]);
}
});
// Individual ticket view
$('#content.ticket').css({
width: '100%'
});
$('#content #ticket').css({
border: 'none',
backgroundColor: '#FFF',
padding: 0
});
$('#ticket .description h3').css({
borderBottom: '1px solid black',
color: '#000',
fontWeight: 'bold'
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment