Last active
August 29, 2015 14:19
-
-
Save philwolstenholme/bebd63911db7011a7a1b to your computer and use it in GitHub Desktop.
Extended Jira timestamps
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 Extended Jira timestamps | |
// @namespace https://wolstenhol.me | |
// @version 0.1 | |
// @author Phil Wolstenholme | |
// @match https://jira.ctidigital.com/* | |
// @grant none | |
// @downloadURL https://gist.githubusercontent.com/philwolstenholme/bebd63911db7011a7a1b/raw/ce8bde9d87d97377789e4d123f66461eed52848b/gistfile1.js | |
// @updateURL https://gist.githubusercontent.com/philwolstenholme/bebd63911db7011a7a1b/raw/ce8bde9d87d97377789e4d123f66461eed52848b/gistfile1.js | |
// ==/UserScript== | |
(function ($) { | |
function alterTimestamps() { | |
var now = new Date(); | |
$("time.livestamp").each(function( index ) { | |
var timestamp = new Date($(this).attr('datetime')); | |
var differenceMilliseconds = (now - timestamp ); | |
var differenceHours = Math.round((differenceMilliseconds % 86400000) / 3600000); | |
var differenceMinutes = Math.round(((differenceMilliseconds % 86400000) % 3600000) / 60000); | |
$(this).parent().attr('title', differenceHours + ' hour(s), ' + differenceMinutes + ' minute(s) ago'); | |
}); | |
} | |
(function triggerAlterations() { | |
alterTimestamps(); | |
alternationInterval = setInterval(alterTimestamps, 5000); | |
})(); | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment