Last active
December 19, 2017 19:14
-
-
Save ChrisMBarr/e237199d99d4284c0f30 to your computer and use it in GitHub Desktop.
GreenShades - Display PTO as Days!
This file contains hidden or 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
<script> | |
$(() => { | |
//run initially | |
appendDays(); | |
//run again on any page update | |
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(appendDays); | |
}); | |
function appendDays() { | |
$(".section-header:contains('Current Balances')") | |
.parent() | |
.find(".dxgvTable_Greenshades .dxgvDataRow_Greenshades td") | |
.each((i, cell) => { | |
const $cell = $(cell); | |
const txt = $cell.text(); | |
const hours = parseFloat(txt); | |
if (/^\d+\.\d+$/.test(txt) && !isNaN(hours) && hours > 0) { | |
const days = hours / 8; | |
const label = days === 1 ? 'day' : 'days'; | |
//Limit to 2 decimal places, unless they are zeros | |
const displayDays = days.toFixed(2).replace(/0+$/,'').replace(/\.$/,''); | |
$cell.append(` <small class='text-muted'>(${displayDays} ${label})</small>`); | |
} | |
}); | |
} | |
</script> |
This file contains hidden or 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
^https*://(.*?)greenemployee.com/EmployeeTimeOffRequests.aspx |
Thanks, saves my brain from working so damned hard (j/k it really doesn't)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! Thanks, Chris.