-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix-kronos.js
71 lines (66 loc) · 2.1 KB
/
fix-kronos.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
60
61
62
63
64
65
66
67
68
69
70
71
// stub out function to prevent tons of errors
if (typeof(routeEvent) == 'undefined') {
function routeEvent(event) {
}
}
(function() {
var abbrevs = {
BRE: 'Bereavement',
JYE: 'Jury Duty',
PES: 'flexPTO (exempt)',
PNS: 'flexPTO Scheduled (non-exempt)',
PNU: 'flexPTO Unscheduled (non-exempt)',
PLE: 'Paid Parental Leave (exempt)',
PLN: 'Paid Parental Leave (non-exempt)',
SES: 'Grandfathered Sick (exempt)',
SNS: 'Grandfathered Sick Scheduled (non-exempt)',
SNU: 'Grandfathered Sick Unscheduled (non-exempt)',
};
function replaceAbbrev(element, abbrev) {
if (typeof(abbrev) == 'undefined') {
abbrev = element.innerHTML;
}
var text = abbrevs[abbrev];
if (text) {
element.innerHTML = text;
}
}
// expand acronyms for PTO types
var table = document.querySelector('table.Tabular.Timecard');
if (table) {
// replace select option text
var trs = table.querySelectorAll('tbody tr');
for (var i = 0; i < trs.length; i++) {
var tr = trs[i];
var payCodeDiv = tr.querySelector('td.Paycode div');
if (!payCodeDiv) {
continue;
}
var payCodeSelect = payCodeDiv.querySelector('select');
if (payCodeSelect) {
var payCodeOptions = payCodeSelect.querySelectorAll('option');
for (var j = 0; j < payCodeOptions.length; j++) {
replaceAbbrev(payCodeOptions[j]);
}
(function(tr, payCodeSelect) {
// find the accompanying amount input and auto-set to 8.0 on select change
var amountInput = tr.querySelector('td.Amount input');
if (amountInput) {
payCodeSelect.addEventListener('change', function(evt) {
if (amountInput.value === '') {
amountInput.value = '8.0';
amountInput.onchange()
}
});
}
})(tr, payCodeSelect);
} else {
// this is probably a previous timecard
var md = payCodeDiv.innerHTML.match(/^ ([A-Z]{3}) $/);
if (md) {
replaceAbbrev(payCodeDiv, md[1]);
}
}
}
}
})();