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 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 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 |
Nice! Thanks, Chris.
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
What Is This?
Use this if you use GreenShades with your company. This will read the data on the PTO (Paid Time Off) page in hours, and convert them into days. This helps you better understand how many days you can take off, because looking at this in terms of hours is harder to understand.
How to Install
Step 1: Use Chrome & Install the Personalized Web Options extention.
Step 2 Go into the extension options and create a new rule.
Step 3 Add the text above into the corresponding "Match URL" and "Add HTML" fields.
(NOTE: The script that does the magic here in enclosed in
<script>
tags and must be placed in the HTML field, and not into the script field of the extension! This allows it to have access to the HTML nodes that it needs.)