Created
May 15, 2010 00:40
-
-
Save alissonsales/401877 to your computer and use it in GitHub Desktop.
Humanize Jira Timesheet
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
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/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() { | |
$.each($('td.workedDay, td.workedDay b'), function (e) { | |
var time = parseFloat($(this).html()), | |
hours = parseInt(time), | |
minutes = time - hours, | |
str = '', | |
o = $(this); | |
if (!isNaN(time) && time > 0) { | |
var minutes = Math.round(minutes * 60); | |
if (hours && minutes) | |
str = hours + 'h and ' + minutes + 'm'; | |
else if (hours) | |
str = hours + 'h'; | |
else | |
str = minutes + 'm'; | |
o.html(str); | |
} else if (!isNaN(time)) { | |
o.html(''); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment