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
@ChrisMBarr
Copy link
Author

ChrisMBarr commented Nov 5, 2014

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.)

@testness
Copy link

Nice! Thanks, Chris.

@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