All pastes #468119 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-02 22:13 UTC
rendered paste body
// ==UserScript==
// @name           Kemtah Timecards
// @description    Make the timecard interface more user-friendly.
// @author         Steven Klassen <steven.klassen@hp.com>
// @include        https://www.kemtah.com/mykemtah/*
// ==/UserScript==

// Add a link to go to the previous week.
if (document.title == 'Kemtah Template Worksheet') {
	dd = document.getElementById('ddlWeek')
	newElement = document.createElement('strong')
	dd.parentNode.insertBefore(newElement, dd.nextSibling);
	newElement.innerHTML = '&nbsp;&nbsp; [ <a href="javascript:dd = document.getElementById(\'ddlWeek\'); dd.options.selectedIndex = dd.options.selectedIndex - 1; __doPostBack(\'ddlWeek\',\'\');">Previous Week</a> ]';
}

// Update the approve button to send the time in immediately.
if (document.title == 'Kemtah Approve Time Entries') {
	var apprElement;
	apprElement = document.getElementById('lbApprove1');
	apprElement.href = "javascript:__doPostBack('lbApprove2','')";
}

// Some adjustments to the Time History Summary form.
if (document.title == 'Time History Summary') {
	document.getElementById('ddlJob').selectedIndex = 1;
	document.getElementById('ddlPastWeeks').selectedIndex = 0;
	document.getElementById('ddlStatus').selectedIndex = 1
	document.getElementById('rlsIsSecondaryApprover_0').checked = true;

	// If it's Monday, I want last week's entries.
	today = new Date();
	if (today.getDay() == 1) {
		StartOfLastWeekMS = today.getTime() - ( 24*60*60*1000*(today.getDay()+6));
		StartOfLastWeek = new Date(StartOfLastWeekMS);
		DateFmt = StartOfLastWeek.getMonth()+1 + '/' + StartOfLastWeek.getDate() + '/' + StartOfLastWeek.getFullYear();
		document.getElementById('txtDate').value = DateFmt;
	}
}