This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
over-estimate.user.js
59 lines (49 loc) · 1.69 KB
/
over-estimate.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==UserScript==
// @name Tickets over estimate
// @namespace https://central.tri.be/
// @version 0.1.1
// @description Adds highlighting when a ticket has more hours clocked than the estimate
// @author Zach Tirrell
// @include /^https:\/\/central.tri.be\/(\/.*)*/
// @grant none
// ==/UserScript==
var central_over_estimate = {};
(function( $, my ) {
'use strict';
my.init = function() {
my.highlight_single();
my.highlight_table();
};
my.highlight_single = function() {
var $estimated = $( '.issue.details td.estimated-hours' );
var $spent = $( '.issue.details td.spent-time' );
var estimated = parseFloat( $estimated.html() );
if ( isNaN( estimated ) ) {
return;
}
var spent = parseFloat( $spent.find( 'a' ).html() );
if ( isNaN( spent ) || spent <= estimated ) {
return;
}
$spent.css( 'background-color', 'pink' );
$spent.find( 'a' ).css( 'font-weight', 'bold' );
};
my.highlight_table = function() {
$( '.list.issues .issue' ).each( function() {
var $estimated = $( this ).find( 'td.estimated_hours' );
var $spent = $( this ).find( 'td.spent_hours' );
var estimated = parseFloat( $estimated.html() );
if ( isNaN( estimated ) ) {
return;
}
var spent = parseFloat( $spent.html() );
if ( isNaN( spent ) || spent <= estimated ) {
return;
}
$spent.css( 'background-color', 'pink' );
} );
};
$( function() {
my.init();
} );
})( jQuery, central_over_estimate );