Skip to content

Instantly share code, notes, and snippets.

@ChrisMBarr
Last active December 19, 2017 19:14
Show Gist options
  • Save ChrisMBarr/e237199d99d4284c0f30 to your computer and use it in GitHub Desktop.
Save ChrisMBarr/e237199d99d4284c0f30 to your computer and use it in GitHub Desktop.
GreenShades - Display PTO as Days!
<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>
^https*://(.*?)greenemployee.com/EmployeeTimeOffRequests.aspx
@MahaRichie
Copy link

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