[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1
From: |
skwashd |
Subject: |
[Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1 |
Date: |
Thu, 5 May 2005 02:56:00 +0200 |
Update of old/ccs/js
Added Files:
Branch: MAIN
formchek.js
calendar.js
Log Message:
cvs clean up
====================================================
Index: formchek.js
var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var whitespace = " \t\n\r";
var decimalPointDelimiter = "."
var phoneNumberDelimiters = "()- ";
var validUSPhoneChars = digits + phoneNumberDelimiters;
var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";
var SSNDelimiters = "- ";
var validSSNChars = digits + SSNDelimiters;
var digitsInSocialSecurityNumber = 9;
var digitsInUSPhoneNumber = 10;
var ZIPCodeDelimiters = "-";
var ZIPCodeDelimeter = "-"
var validZIPCodeChars = digits + ZIPCodeDelimiters
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9
var creditCardDelimiters = " "
var mPrefix = "You did not enter a value into the "
var mSuffix = " field. This is a required field. Please enter it now."
var sUSLastName = "Last Name"
var sUSFirstName = "First Name"
var sWorldLastName = "Family Name"
var sWorldFirstName = "Given Name"
var sTitle = "Title"
var sCompanyName = "Company Name"
var sUSAddress = "Street Address"
var sWorldAddress = "Address"
var sCity = "City"
var sStateCode = "State Code"
var sWorldState = "State, Province, or Prefecture"
var sCountry = "Country"
var sZIPCode = "ZIP Code"
var sWorldPostalCode = "Postal Code"
var sPhone = "Phone Number"
var sFax = "Fax Number"
var sDateOfBirth = "Date of Birth"
var sExpirationDate = "Expiration Date"
var sEmail = "Email"
var sSSN = "Social Security Number"
var sCreditCardNumber = "Credit Card Number"
var sOtherInfo = "Other Information"
var iStateCode = "This field must be a valid two character U.S. state
abbreviation (like CA for California). Please reenter it now."
var iZIPCode = "This field must be a 5 or 9 digit U.S. ZIP Code (like 94043).
Please reenter it now."
var iUSPhone = "This field must be a 10 digit U.S. phone number (like 415 555
1212). Please reenter it now."
var iWorldPhone = "This field must be a valid international phone number.
Please reenter it now."
var iSSN = "This field must be a 9 digit U.S. social security number (like 123
45 6789). Please reenter it now."
var iEmail = "This field must be a valid email address (like address@hidden).
Please reenter it now."
var iCreditCardPrefix = "This is not a valid "
var iCreditCardSuffix = " credit card number. (Click the link on this form to
see a list of sample numbers.) Please reenter it now."
var iDay = "This field must be a day number between 1 and 31. Please reenter
it now."
var iMonth = "This field must be a month number between 1 and 12. Please
reenter it now."
var iYear = "This field must be a 2 or 4 digit year number. Please reenter it
now."
var iDatePrefix = "The Day, Month, and Year for "
var iDateSuffix = " do not form a valid date. Please reenter them now."
var pEntryPrompt = "Please enter a "
var pStateCode = "2 character code (like CA)."
var pZIPCode = "5 or 9 digit U.S. ZIP Code (like 94043)."
var pUSPhone = "10 digit U.S. phone number (like 415 555 1212)."
var pWorldPhone = "international phone number."
var pSSN = "9 digit U.S. social security number (like 123 45 6789)."
var pEmail = "valid email address (like address@hidden)."
var pCreditCard = "valid credit card number."
var pDay = "day number between 1 and 31."
var pMonth = "month number between 1 and 12."
var pYear = "2 or 4 digit year number."
var defaultEmptyOK = false
function makeArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 0
}
return this
}
var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29; // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;
var USStateCodeDelimiter = "|";
var USStateCodes =
"AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY|AE|AA|AE|AE|AP"
function isEmpty(s)
{ return ((s == null) || (s.length == 0))
}
function isWhitespace (s)
{ var i;
if (isEmpty(s)) return true;
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (whitespace.indexOf(c) == -1) return false;
}
return true;
}
function stripCharsInBag (s, bag)
{ var i;
var returnString = "";
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function stripCharsNotInBag (s, bag)
{ var i;
var returnString = "";
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (bag.indexOf(c) != -1) returnString += c;
}
return returnString;
}
function stripWhitespace (s)
{ return stripCharsInBag (s, whitespace)
}
function charInString (c, s)
{ for (i = 0; i < s.length; i++)
{ if (s.charAt(i) == c) return true;
}
return false
}
function stripInitialWhitespace (s)
{ var i = 0;
while ((i < s.length) && charInString (s.charAt(i), whitespace))
i++;
return s.substring (i, s.length);
}
function isLetter (c)
{ return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}
function isDigit (c)
{ return ((c >= "0") && (c <= "9"))
}
function isLetterOrDigit (c)
{ return (isLetter(c) || isDigit(c))
}
function isInteger (s)
{ var i;
if (isEmpty(s))
if (isInteger.arguments.length == 1) return defaultEmptyOK;
else return (isInteger.arguments[1] == true);
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (!isDigit(c)) return false;
}
return true;
}
function isSignedInteger (s)
{ if (isEmpty(s))
if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
else return (isSignedInteger.arguments[1] == true);
else {
var startPos = 0;
var secondArg = defaultEmptyOK;
if (isSignedInteger.arguments.length > 1)
secondArg = isSignedInteger.arguments[1];
if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
startPos = 1;
return (isInteger(s.substring(startPos, s.length), secondArg))
}
}
function isPositiveInteger (s)
{ var secondArg = defaultEmptyOK;
if (isPositiveInteger.arguments.length > 1)
secondArg = isPositiveInteger.arguments[1];
return (isSignedInteger(s, secondArg)
&& ( (isEmpty(s) && secondArg) || (parseInt (s) > 0) ) );
}
function isNonnegativeInteger (s)
{ var secondArg = defaultEmptyOK;
if (isNonnegativeInteger.arguments.length > 1)
secondArg = isNonnegativeInteger.arguments[1];
return (isSignedInteger(s, secondArg)
&& ( (isEmpty(s) && secondArg) || (parseInt (s) >= 0) ) );
}
function isNegativeInteger (s)
{ var secondArg = defaultEmptyOK;
if (isNegativeInteger.arguments.length > 1)
secondArg = isNegativeInteger.arguments[1];
return (isSignedInteger(s, secondArg)
&& ( (isEmpty(s) && secondArg) || (parseInt (s) < 0) ) );
}
function isNonpositiveInteger (s)
{ var secondArg = defaultEmptyOK;
if (isNonpositiveInteger.arguments.length > 1)
secondArg = isNonpositiveInteger.arguments[1];
return (isSignedInteger(s, secondArg)
&& ( (isEmpty(s) && secondArg) || (parseInt (s) <= 0) ) );
}
function isFloat (s)
{ var i;
var seenDecimalPoint = false;
if (isEmpty(s))
if (isFloat.arguments.length == 1) return defaultEmptyOK;
else return (isFloat.arguments[1] == true);
if (s == decimalPointDelimiter) return false;
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint
= true;
else if (!isDigit(c)) return false;
}
return true;
}
function isSignedFloat (s)
{ if (isEmpty(s))
if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
else return (isSignedFloat.arguments[1] == true);
else {
var startPos = 0;
var secondArg = defaultEmptyOK;
if (isSignedFloat.arguments.length > 1)
secondArg = isSignedFloat.arguments[1];
if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
startPos = 1;
return (isFloat(s.substring(startPos, s.length), secondArg))
}
}
function isAlphabetic (s)
{ var i;
if (isEmpty(s))
if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
else return (isAlphabetic.arguments[1] == true);
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (!isLetter(c))
return false;
}
return true;
}
function isAlphanumeric (s)
{ var i;
if (isEmpty(s))
if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
else return (isAlphanumeric.arguments[1] == true);
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (! (isLetter(c) || isDigit(c) ) )
return false;
}
return true;
}
function reformat (s)
{ var arg;
var sPos = 0;
var resultString = "";
for (var i = 1; i < reformat.arguments.length; i++) {
arg = reformat.arguments[i];
if (i % 2 == 1) resultString += arg;
else {
resultString += s.substring(sPos, sPos + arg);
sPos += arg;
}
}
return resultString;
}
function isSSN (s)
{ if (isEmpty(s))
if (isSSN.arguments.length == 1) return defaultEmptyOK;
else return (isSSN.arguments[1] == true);
return (isInteger(s) && s.length == digitsInSocialSecurityNumber)
}
function isUSPhoneNumber (s)
{ if (isEmpty(s))
if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
else return (isUSPhoneNumber.arguments[1] == true);
return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}
function isInternationalPhoneNumber (s)
{ if (isEmpty(s))
if (isInternationalPhoneNumber.arguments.length == 1) return
defaultEmptyOK;
else return (isInternationalPhoneNumber.arguments[1] == true);
return (isPositiveInteger(s))
}
function isZIPCode (s)
{ if (isEmpty(s))
if (isZIPCode.arguments.length == 1) return defaultEmptyOK;
else return (isZIPCode.arguments[1] == true);
return (isInteger(s) &&
((s.length == digitsInZIPCode1) ||
(s.length == digitsInZIPCode2)))
}
function isStateCode(s)
{ if (isEmpty(s))
if (isStateCode.arguments.length == 1) return defaultEmptyOK;
else return (isStateCode.arguments[1] == true);
return ( (USStateCodes.indexOf(s) != -1) &&
(s.indexOf(USStateCodeDelimiter) == -1) )
}
function isEmail (s)
{ if (isEmpty(s))
if (isEmail.arguments.length == 1) return defaultEmptyOK;
else return (isEmail.arguments[1] == true);
if (isWhitespace(s)) return false;
var i = 1;
var sLength = s.length;
while ((i < sLength) && (s.charAt(i) != "@"))
{ i++
}
if ((i >= sLength) || (s.charAt(i) != "@")) return false;
else i += 2;
while ((i < sLength) && (s.charAt(i) != "."))
{ i++
}
if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
else return true;
}
function isYear (s)
{ if (isEmpty(s))
if (isYear.arguments.length == 1) return defaultEmptyOK;
else return (isYear.arguments[1] == true);
if (!isNonnegativeInteger(s)) return false;
return (s.length == 4);
}
function isIntegerInRange (s, a, b)
{ if (isEmpty(s))
if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
else return (isIntegerInRange.arguments[1] == true);
if (!isInteger(s, false)) return false;
var num = parseInt(s,10);
return ((num >= a) && (num <= b));
}
function isMonth (s)
{ if (isEmpty(s))
if (isMonth.arguments.length == 1) return defaultEmptyOK;
else return (isMonth.arguments[1] == true);
return isIntegerInRange (s, 1, 12);
}
function isDay (s)
{ if (isEmpty(s))
if (isDay.arguments.length == 1) return defaultEmptyOK;
else return (isDay.arguments[1] == true);
return isIntegerInRange (s, 1, 31);
}
function daysInFebruary (year)
{ // February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return ( ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) )
) ? 29 : 28 );
}
function isDate (year, month, day)
{ // catch invalid years (not 2- or 4-digit) and invalid months and days.
if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false)))
return false;
// Explicitly change type to integer to make code work in both
// JavaScript 1.1 and JavaScript 1.2.
var intYear = parseInt(year);
var intMonth = parseInt(month);
var intDay = parseInt(day);
// catch invalid days, except for February
if (intDay > daysInMonth[intMonth]) return false;
if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;
return true;
}
function prompt (s)
{ window.status = s
}
function promptEntry (s)
{ window.status = pEntryPrompt + s
}
function warnEmpty (theField, s)
{ theField.focus()
alert(mPrefix + s + mSuffix)
return false
}
function warnInvalid (theField, s)
{ theField.focus()
theField.select()
alert(s)
return false
}
function checkString (theField, s, emptyOK)
{ // Next line is needed on NN3 to avoid "undefined is not a number" error
// in equality comparison below.
if (checkString.arguments.length == 2) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
if (isWhitespace(theField.value))
return warnEmpty (theField, s);
else return true;
}
function checkStateCode (theField, emptyOK)
{ if (checkStateCode.arguments.length == 1) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
else
{ theField.value = theField.value.toUpperCase();
if (!isStateCode(theField.value, false))
return warnInvalid (theField, iStateCode);
else return true;
}
}
function reformatZIPCode (ZIPString)
{ if (ZIPString.length == 5) return ZIPString;
else return (reformat (ZIPString, "", 5, "-", 4));
}
// see comments of function isInteger.
function checkZIPCode (theField, emptyOK)
{ if (checkZIPCode.arguments.length == 1) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
else
{ var normalizedZIP = stripCharsInBag(theField.value, ZIPCodeDelimiters)
if (!isZIPCode(normalizedZIP, false))
return warnInvalid (theField, iZIPCode);
else
{ // if you don't want to insert a hyphen, comment next line out
theField.value = reformatZIPCode(normalizedZIP)
return true;
}
}
}
function reformatUSPhone (USPhone)
{ return (reformat (USPhone, "(", 3, ") ", 3, "-", 4))
}
function checkUSPhone (theField, emptyOK)
{ if (checkUSPhone.arguments.length == 1) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
else
{ var normalizedPhone = stripCharsInBag(theField.value,
phoneNumberDelimiters)
if (!isUSPhoneNumber(normalizedPhone, false))
return warnInvalid (theField, iUSPhone);
else
{ // if you don't want to reformat as (123) 456-789, comment next line
out
theField.value = reformatUSPhone(normalizedPhone)
return true;
}
}
}
function checkInternationalPhone (theField, emptyOK)
{ if (checkInternationalPhone.arguments.length == 1) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
else
{ if (!isInternationalPhoneNumber(theField.value, false))
return warnInvalid (theField, iWorldPhone);
else return true;
}
}
function checkEmail (theField, emptyOK)
{ if (checkEmail.arguments.length == 1) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
else if (!isEmail(theField.value, false))
return warnInvalid (theField, iEmail);
else return true;
}
function reformatSSN (SSN)
{ return (reformat (SSN, "", 3, "-", 2, "-", 4))
}
function checkSSN (theField, emptyOK)
{ if (checkSSN.arguments.length == 1) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
else
{ var normalizedSSN = stripCharsInBag(theField.value, SSNDelimiters)
if (!isSSN(normalizedSSN, false))
return warnInvalid (theField, iSSN);
else
{ // if you don't want to reformats as 123-456-7890, comment next line
out
theField.value = reformatSSN(normalizedSSN)
return true;
}
}
}
function checkYear (theField, emptyOK)
{ if (checkYear.arguments.length == 1) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
if (!isYear(theField.value, false))
return warnInvalid (theField, iYear);
else return true;
}
function checkMonth (theField, emptyOK)
{ if (checkMonth.arguments.length == 1) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
if (!isMonth(theField.value, false))
return warnInvalid (theField, iMonth);
else return true;
}
function checkDay (theField, emptyOK)
{ if (checkDay.arguments.length == 1) emptyOK = defaultEmptyOK;
if ((emptyOK == true) && (isEmpty(theField.value))) return true;
if (!isDay(theField.value, false))
return warnInvalid (theField, iDay);
else return true;
}
function checkDate (yearField, monthField, dayField, labelString, OKtoOmitDay)
{ // Next line is needed on NN3 to avoid "undefined is not a number" error
if (checkDate.arguments.length == 4) OKtoOmitDay = false;
if (!isYear(yearField.value)) return warnInvalid (yearField, iYear);
if (!isMonth(monthField.value)) return warnInvalid (monthField, iMonth);
if ( (OKtoOmitDay == true) && isEmpty(dayField.value) ) return true;
else if (!isDay(dayField.value))
return warnInvalid (dayField, iDay);
if (isDate (yearField.value, monthField.value, dayField.value))
return true;
alert (iDatePrefix + labelString + iDateSuffix)
return false
}
function getRadioButtonValue (radio)
{ for (var i = 0; i < radio.length; i++)
{ if (radio[i].checked) { break }
}
return radio[i].value
}
function checkCreditCard (radio, theField)
{ var cardType = getRadioButtonValue (radio)
var normalizedCCN = stripCharsInBag(theField.value, creditCardDelimiters)
if (!isCardMatch(cardType, normalizedCCN))
return warnInvalid (theField, iCreditCardPrefix + cardType +
iCreditCardSuffix);
else
{ theField.value = normalizedCCN
return true
}
}
function isCreditCard(st) {
// Encoding only works on cards with less than 19 digits
if (st.length > 19)
return (false);
sum = 0; mul = 1; l = st.length;
for (i = 0; i < l; i++) {
digit = st.substring(l-i-1,l-i);
tproduct = parseInt(digit ,10)*mul;
if (tproduct >= 10)
sum += (tproduct % 10) + 1;
else
sum += tproduct;
if (mul == 1)
mul++;
else
mul--;
}
if ((sum % 10) == 0)
return (true);
else
return (false);
} // END FUNCTION isCreditCard()
function isVisa(cc)
{
if (((cc.length == 16) || (cc.length == 13)) &&
(cc.substring(0,1) == 4))
return isCreditCard(cc);
return false;
} // END FUNCTION isVisa()
function isMasterCard(cc)
{
firstdig = cc.substring(0,1);
seconddig = cc.substring(1,2);
if ((cc.length == 16) && (firstdig == 5) &&
((seconddig >= 1) && (seconddig <= 5)))
return isCreditCard(cc);
return false;
} // END FUNCTION isMasterCard()
function isAmericanExpress(cc)
{
firstdig = cc.substring(0,1);
seconddig = cc.substring(1,2);
if ((cc.length == 15) && (firstdig == 3) &&
((seconddig == 4) || (seconddig == 7)))
return isCreditCard(cc);
return false;
} // END FUNCTION isAmericanExpress()
function isDinersClub(cc)
{
firstdig = cc.substring(0,1);
seconddig = cc.substring(1,2);
if ((cc.length == 14) && (firstdig == 3) &&
((seconddig == 0) || (seconddig == 6) || (seconddig == 8)))
return isCreditCard(cc);
return false;
}
function isCarteBlanche(cc)
{
return isDinersClub(cc);
}
function isDiscover(cc)
{
first4digs = cc.substring(0,4);
if ((cc.length == 16) && (first4digs == "6011"))
return isCreditCard(cc);
return false;
} // END FUNCTION isDiscover()
function isEnRoute(cc)
{
first4digs = cc.substring(0,4);
if ((cc.length == 15) &&
((first4digs == "2014") ||
(first4digs == "2149")))
return isCreditCard(cc);
return false;
}
function isJCB(cc)
{
first4digs = cc.substring(0,4);
if ((cc.length == 16) &&
((first4digs == "3088") ||
(first4digs == "3096") ||
(first4digs == "3112") ||
(first4digs == "3158") ||
(first4digs == "3337") ||
(first4digs == "3528")))
return isCreditCard(cc);
return false;
} // END FUNCTION isJCB()
function isAnyCard(cc)
{
if (!isCreditCard(cc))
return false;
if (!isMasterCard(cc) && !isVisa(cc) && !isAmericanExpress(cc) &&
!isDinersClub(cc) &&
!isDiscover(cc) && !isEnRoute(cc) && !isJCB(cc)) {
return false;
}
return true;
} // END FUNCTION isAnyCard()
function isCardMatch (cardType, cardNumber)
{
cardType = cardType.toUpperCase();
var doesMatch = true;
if ((cardType == "VISA") && (!isVisa(cardNumber)))
doesMatch = false;
if ((cardType == "MASTERCARD") && (!isMasterCard(cardNumber)))
doesMatch = false;
if ( ( (cardType == "AMERICANEXPRESS") || (cardType == "AMEX") )
&& (!isAmericanExpress(cardNumber))) doesMatch = false;
if ((cardType == "DISCOVER") && (!isDiscover(cardNumber)))
doesMatch = false;
if ((cardType == "JCB") && (!isJCB(cardNumber)))
doesMatch = false;
if ((cardType == "DINERS") && (!isDinersClub(cardNumber)))
doesMatch = false;
if ((cardType == "CARTEBLANCHE") && (!isCarteBlanche(cardNumber)))
doesMatch = false;
if ((cardType == "ENROUTE") && (!isEnRoute(cardNumber)))
doesMatch = false;
return doesMatch;
} // END FUNCTION CardMatch()
function IsCC (st) {
return isCreditCard(st);
}
function IsVisa (cc) {
return isVisa(cc);
}
function IsVISA (cc) {
return isVisa(cc);
}
function IsMasterCard (cc) {
return isMasterCard(cc);
}
function IsMastercard (cc) {
return isMasterCard(cc);
}
function IsMC (cc) {
return isMasterCard(cc);
}
function IsAmericanExpress (cc) {
return isAmericanExpress(cc);
}
function IsAmEx (cc) {
return isAmericanExpress(cc);
}
function IsDinersClub (cc) {
return isDinersClub(cc);
}
function IsDC (cc) {
return isDinersClub(cc);
}
function IsDiners (cc) {
return isDinersClub(cc);
}
function IsCarteBlanche (cc) {
return isCarteBlanche(cc);
}
function IsCB (cc) {
return isCarteBlanche(cc);
}
function IsDiscover (cc) {
return isDiscover(cc);
}
function IsEnRoute (cc) {
return isEnRoute(cc);
}
function IsenRoute (cc) {
return isEnRoute(cc);
}
function IsJCB (cc) {
return isJCB(cc);
}
function IsAnyCard(cc) {
return isAnyCard(cc);
}
function IsCardMatch (cardType, cardNumber) {
return isCardMatch (cardType, cardNumber);
}
====================================================
Index: calendar.js
//
// JavaScript Calendar Component
// Author: Robert W. Husted (address@hidden)
// Date: 8/22/1999
// Modified Date: 06/25/2000
// Modified By: Michael L. Dean
// Notes: Made DCL-specific adjustments to support date formatting.
// Modified Date: 11/30/1999
// Modified By: Robert W. Husted
// Notes: Added frameset support (changed reference for "newWin" to
"top.newWin")
// Also changed Spanish "March" from "Marcha" to "Marzo"
// Fixed JavaScript Date Anomaly affecting days > 28
//
//
//
// Usage: Add the following lines of code to your page to enable the Calendar
// component.
//
//
// // THIS LINE LOADS THE JS LIBRARY FOR THE CALENDAR COMPONENT
//
// <SCRIPT LANGUAGE="JavaScript" SRC="calendar.js"></SCRIPT>
//
//
//
// // THIS LINE IS USED IN CONJUNCTION WITH A FORM FIELD (myDateField)
IN A FORM (myForm).
// // Replace "myForm" and "myDateField" WITH THE NAME OF YOUR FORM AND
INPUT FIELD RESPECTIVELY
// // WINDOW OPTIONS SET THE WIDTH, HEIGHT, AND X/Y POSITION OF THE
CALENDAR WINDOW
// // WITH TITLEBAR ON, ALL OTHER OPTIONS (TOOLBARS, ETC) ARE DISABLED
BY DEFAULT
//
// <A HREF="javascript:doNothing()"
onClick="setDateField(document.myForm.myDateField);top.newWin =
window.open('calendar.html','cal','dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes')">
// <IMG SRC="calendar.gif" BORDER=0></A><font size=1>Popup
Calendar</font>
//
//
//
// Required Files:
//
// calendar.js - contains all JavaScript functions to make the
calendar work
//
// calendar.html - frameset document (not required if you call the
showCalendar()
// function. However, calling showCalendar() directly
causes
// the Java Virtual Machine (JVM) to start which slows
down the
// loading of the calendar.)
//
//
// Files Generally Included:
//
// calendar.gif - image that looks like a little calendar
//
// yourPage.html - page that contains a form and a date field which
implements
// the calendar component
//
// BEGIN USER-EDITABLE SECTION
-----------------------------------------------------
// SPECIFY DATE FORMAT RETURNED BY THIS CALENDAR
// (THIS IS ALSO THE DATE FORMAT RECOGNIZED BY THIS CALENDAR)
// DATE FORMAT OPTIONS:
//
// dd = 1 or 2-digit Day
// DD = 2-digit Day
// mm = 1 or 2-digit Month
// MM = 2-digit Month
// yy = 2-digit Year
// YY = 4-digit Year
// yyyy = 4-digit Year
// month = Month name in lowercase letters
// Month = Month name in initial caps
// MONTH = Month name in captital letters
// mon = 3-letter month abbreviation in lowercase letters
// Mon = 3-letter month abbreviation in initial caps
// MON = 3-letter month abbreviation in uppercase letters
// weekday = name of week in lowercase letters
// Weekday = name of week in initial caps
// WEEKDAY = name of week in uppercase letters
// wkdy = 3-letter weekday abbreviation in lowercase letters
// Wkdy = 3-letter weekday abbreviation in initial caps
// WKDY = 3-letter weekday abbreviation in uppercase letters
//
// Examples:
//
// calDateFormat = "mm/dd/yy";
// calDateFormat = "Weekday, Month dd, yyyy";
// calDateFormat = "wkdy, mon dd, yyyy";
// calDateFormat = "DD.MM.YY"; // FORMAT UNSUPPORTED BY JAVASCRIPT --
REQUIRES CUSTOM PARSING
//
//calDateFormat = "MM/DD/yyyy";
// CALENDAR COLORS
topBackground = "white"; // BG COLOR OF THE TOP FRAME
bottomBackground = "white"; // BG COLOR OF THE BOTTOM FRAME
tableBGColor = "black"; // BG COLOR OF THE BOTTOM FRAME'S TABLE
cellColor = "lightgrey"; // TABLE CELL BG COLOR OF THE DATE CELLS IN
THE BOTTOM FRAME
headingCellColor = "white"; // TABLE CELL BG COLOR OF THE WEEKDAY
ABBREVIATIONS
headingTextColor = "black"; // TEXT COLOR OF THE WEEKDAY ABBREVIATIONS
dateColor = "blue"; // TEXT COLOR OF THE LISTED DATES (1-28+)
focusColor = "#ff0000"; // TEXT COLOR OF THE SELECTED DATE (OR
CURRENT DATE)
hoverColor = "darkred"; // TEXT COLOR OF A LINK WHEN YOU HOVER OVER
IT
fontStyle = "12pt arial, helvetica"; // TEXT STYLE FOR DATES
headingFontStyle = "bold 12pt arial, helvetica"; // TEXT STYLE FOR WEEKDAY
ABBREVIATIONS
// FORMATTING PREFERENCES
bottomBorder = false; // TRUE/FALSE (WHETHER TO DISPLAY
BOTTOM CALENDAR BORDER)
tableBorder = 0; // SIZE OF CALENDAR TABLE BORDER
(BOTTOM FRAME) 0=none
dateDelimeterIsDot = false; // If dot is used for
delimeter, this will track custom handling
// END USER-EDITABLE SECTION
-------------------------------------------------------
// DETERMINE BROWSER BRAND
var isNav = false;
var isIE = false;
// ASSUME IT'S EITHER NETSCAPE OR MSIE
if (navigator.appName == "Netscape") {
isNav = true;
}
else {
isIE = true;
}
// GET CURRENTLY SELECTED LANGUAGE
selectedLanguage = navigator.language;
// PRE-BUILD PORTIONS OF THE CALENDAR WHEN THIS JS LIBRARY LOADS INTO THE
BROWSER
buildCalParts();
// CALENDAR FUNCTIONS BEGIN HERE
---------------------------------------------------
// SET THE INITIAL VALUE OF THE GLOBAL DATE FIELD
function setDateField(dateField) {
// ASSIGN THE INCOMING FIELD OBJECT TO A GLOBAL VARIABLE
calDateField = dateField;
// GET THE VALUE OF THE INCOMING FIELD
inDate = dateField.value;
if (inDate.indexOf(".") != -1)
inDate = jsReplace(inDate, ".", "/");
// SET calDate TO THE DATE IN THE INCOMING FIELD OR DEFAULT TO TODAY'S DATE
setInitialDate();
// THE CALENDAR FRAMESET DOCUMENTS ARE CREATED BY JAVASCRIPT FUNCTIONS
calDocTop = buildTopCalFrame();
calDocBottom = buildBottomCalFrame();
}
// SET THE INITIAL CALENDAR DATE TO TODAY OR TO THE EXISTING VALUE IN dateField
function setInitialDate() {
// CREATE A NEW DATE OBJECT (WILL GENERALLY PARSE CORRECT DATE EXCEPT WHEN
"." IS USED AS A DELIMITER)
// (THIS ROUTINE DOES *NOT* CATCH ALL DATE FORMATS, IF YOU NEED TO PARSE A
CUSTOM DATE FORMAT, DO IT HERE)
if (inDate.length > 0)
calDate = new Date(inDate.substr(calDateFormat.indexOf("yyyy"),
4),
inDate.substr(calDateFormat.indexOf("MM"), 2) -
1,
inDate.substr(calDateFormat.indexOf("DD"), 2),
0, 0, 0, 0);
else
calDate = new Date();
// IF THE INCOMING DATE IS INVALID, USE THE CURRENT DATE
if (isNaN(calDate)) {
// ADD CUSTOM DATE PARSING HERE
// IF IT FAILS, SIMPLY CREATE A NEW DATE OBJECT WHICH DEFAULTS TO THE
CURRENT DATE
calDate = new Date();
}
// KEEP TRACK OF THE CURRENT DAY VALUE
calDay = calDate.getDate();
// SET DAY VALUE TO 1... TO AVOID JAVASCRIPT DATE CALCULATION ANOMALIES
// (IF THE MONTH CHANGES TO FEB AND THE DAY IS 30, THE MONTH WOULD CHANGE
TO MARCH
// AND THE DAY WOULD CHANGE TO 2. SETTING THE DAY TO 1 WILL PREVENT THAT)
calDate.setDate(1);
}
// POPUP A WINDOW WITH THE CALENDAR IN IT
function showCalendar(dateField) {
// SET INITIAL VALUE OF THE DATE FIELD AND CREATE TOP AND BOTTOM FRAMES
setDateField(dateField);
// USE THE JAVASCRIPT-GENERATED DOCUMENTS (calDocTop, calDocBottom) IN THE
FRAMESET
calDocFrameset =
"<HTML><HEAD><TITLE>JavaScript Calendar</TITLE></HEAD>\n" +
"<FRAMESET ROWS='70,*' FRAMEBORDER='0'>\n" +
" <FRAME NAME='topCalFrame'
SRC='javascript:parent.opener.calDocTop' SCROLLING='no'>\n" +
" <FRAME NAME='bottomCalFrame'
SRC='javascript:parent.opener.calDocBottom' SCROLLING='no'>\n" +
"</FRAMESET>\n";
// DISPLAY THE CALENDAR IN A NEW POPUP WINDOW
top.newWin = window.open("javascript:parent.opener.calDocFrameset",
"calWin", winPrefs);
top.newWin.focus();
}
// CREATE THE TOP CALENDAR FRAME
function buildTopCalFrame() {
// CREATE THE TOP FRAME OF THE CALENDAR
var calDoc =
"<HTML>" +
"<HEAD>" +
"</HEAD>" +
"<BODY BGCOLOR='" + topBackground + "'>" +
"<FORM NAME='calControl' onSubmit='return false;'>" +
"<CENTER>" +
"<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0>" +
"<TR><TD COLSPAN=7>" +
"<CENTER>" +
getMonthSelect() +
"<INPUT NAME='year' VALUE='" + calDate.getFullYear() +
"'TYPE=TEXT SIZE=4 MAXLENGTH=4 onChange='parent.opener.setYear()'>" +
"</CENTER>" +
"</TD>" +
"</TR>" +
"<TR>" +
"<TD COLSPAN=7>" +
"<INPUT " +
"TYPE=BUTTON NAME='previousYear' VALUE='<<'
onClick='parent.opener.setPreviousYear()'><INPUT " +
"TYPE=BUTTON NAME='previousMonth' VALUE=' < '
onClick='parent.opener.setPreviousMonth()'><INPUT " +
"TYPE=BUTTON NAME='today' VALUE='Today'
onClick='parent.opener.setToday()'><INPUT " +
"TYPE=BUTTON NAME='nextMonth' VALUE=' > '
onClick='parent.opener.setNextMonth()'><INPUT " +
"TYPE=BUTTON NAME='nextYear' VALUE='>>'
onClick='parent.opener.setNextYear()'>" +
"</TD>" +
"</TR>" +
"</TABLE>" +
"</CENTER>" +
"</FORM>" +
"</BODY>" +
"</HTML>";
return calDoc;
}
// CREATE THE BOTTOM CALENDAR FRAME
// (THE MONTHLY CALENDAR)
function buildBottomCalFrame() {
// START CALENDAR DOCUMENT
var calDoc = calendarBegin;
// GET MONTH, AND YEAR FROM GLOBAL CALENDAR DATE
month = calDate.getMonth();
year = calDate.getFullYear();
// GET GLOBALLY-TRACKED DAY VALUE (PREVENTS JAVASCRIPT DATE ANOMALIES)
day = calDay;
var i = 0;
// DETERMINE THE NUMBER OF DAYS IN THE CURRENT MONTH
var days = getDaysInMonth();
// IF GLOBAL DAY VALUE IS > THAN DAYS IN MONTH, HIGHLIGHT LAST DAY IN MONTH
if (day > days) {
day = days;
}
// DETERMINE WHAT DAY OF THE WEEK THE CALENDAR STARTS ON
var firstOfMonth = new Date (year, month, 1);
// GET THE DAY OF THE WEEK THE FIRST DAY OF THE MONTH FALLS ON
var startingPos = firstOfMonth.getDay();
days += startingPos;
// KEEP TRACK OF THE COLUMNS, START A NEW ROW AFTER EVERY 7 COLUMNS
var columnCount = 0;
// MAKE BEGINNING NON-DATE CELLS BLANK
for (i = 0; i < startingPos; i++) {
calDoc += blankCell;
columnCount++;
}
// SET VALUES FOR DAYS OF THE MONTH
var currentDay = 0;
var dayType = "weekday";
// DATE CELLS CONTAIN A NUMBER
for (i = startingPos; i < days; i++) {
var paddingChar = " ";
// ADJUST SPACING SO THAT ALL LINKS HAVE RELATIVELY EQUAL WIDTHS
if (i-startingPos+1 < 10) {
padding = " ";
}
else {
padding = " ";
}
// GET THE DAY CURRENTLY BEING WRITTEN
currentDay = i-startingPos+1;
// SET THE TYPE OF DAY, THE focusDay GENERALLY APPEARS AS A DIFFERENT
COLOR
if (currentDay == day) {
dayType = "focusDay";
}
else {
dayType = "weekDay";
}
// ADD THE DAY TO THE CALENDAR STRING
calDoc += "<TD align=center bgcolor='" + cellColor + "'>" +
"<a class='" + dayType + "'
href='javascript:parent.opener.returnDate(" +
currentDay + ")'>" + padding + currentDay + paddingChar
+ "</a></TD>";
columnCount++;
// START A NEW ROW WHEN NECESSARY
if (columnCount % 7 == 0) {
calDoc += "</TR><TR>";
}
}
// MAKE REMAINING NON-DATE CELLS BLANK
for (i=days; i<42; i++) {
calDoc += blankCell;
columnCount++;
// START A NEW ROW WHEN NECESSARY
if (columnCount % 7 == 0) {
calDoc += "</TR>";
if (i<41) {
calDoc += "<TR>";
}
}
}
// FINISH THE NEW CALENDAR PAGE
calDoc += calendarEnd;
// RETURN THE COMPLETED CALENDAR PAGE
return calDoc;
}
// WRITE THE MONTHLY CALENDAR TO THE BOTTOM CALENDAR FRAME
function writeCalendar() {
// CREATE THE NEW CALENDAR FOR THE SELECTED MONTH & YEAR
calDocBottom = buildBottomCalFrame();
// WRITE THE NEW CALENDAR TO THE BOTTOM FRAME
top.newWin.frames['bottomCalFrame'].document.open();
top.newWin.frames['bottomCalFrame'].document.write(calDocBottom);
top.newWin.frames['bottomCalFrame'].document.close();
}
// SET THE CALENDAR TO TODAY'S DATE AND DISPLAY THE NEW CALENDAR
function setToday() {
// SET GLOBAL DATE TO TODAY'S DATE
calDate = new Date();
// SET DAY MONTH AND YEAR TO TODAY'S DATE
var month = calDate.getMonth();
var year = calDate.getFullYear();
// SET MONTH IN DROP-DOWN LIST
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex =
month;
// SET YEAR VALUE
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
// DISPLAY THE NEW CALENDAR
writeCalendar();
}
// SET THE GLOBAL DATE TO THE NEWLY ENTERED YEAR AND REDRAW THE CALENDAR
function setYear() {
// GET THE NEW YEAR VALUE
var year =
top.newWin.frames['topCalFrame'].document.calControl.year.value;
// IF IT'S A FOUR-DIGIT YEAR THEN CHANGE THE CALENDAR
if (isFourDigitYear(year)) {
calDate.setFullYear(year);
writeCalendar();
}
else {
// HIGHLIGHT THE YEAR IF THE YEAR IS NOT FOUR DIGITS IN LENGTH
top.newWin.frames['topCalFrame'].document.calControl.year.focus();
top.newWin.frames['topCalFrame'].document.calControl.year.select();
}
}
// SET THE GLOBAL DATE TO THE SELECTED MONTH AND REDRAW THE CALENDAR
function setCurrentMonth() {
// GET THE NEWLY SELECTED MONTH AND CHANGE THE CALENDAR ACCORDINGLY
var month =
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
calDate.setMonth(month);
writeCalendar();
}
// SET THE GLOBAL DATE TO THE PREVIOUS YEAR AND REDRAW THE CALENDAR
function setPreviousYear() {
var year =
top.newWin.frames['topCalFrame'].document.calControl.year.value;
if (isFourDigitYear(year) && year > 1000) {
year--;
calDate.setFullYear(year);
top.newWin.frames['topCalFrame'].document.calControl.year.value
= year;
writeCalendar();
}
}
// SET THE GLOBAL DATE TO THE PREVIOUS MONTH AND REDRAW THE CALENDAR
function setPreviousMonth() {
var year =
top.newWin.frames['topCalFrame'].document.calControl.year.value;
if (isFourDigitYear(year)) {
var month =
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
// IF MONTH IS JANUARY, SET MONTH TO DECEMBER AND DECREMENT THE YEAR
if (month == 0) {
month = 11;
if (year > 1000) {
year--;
calDate.setFullYear(year);
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
}
}
else {
month--;
}
calDate.setMonth(month);
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex =
month;
writeCalendar();
}
}
// SET THE GLOBAL DATE TO THE NEXT MONTH AND REDRAW THE CALENDAR
function setNextMonth() {
var year =
top.newWin.frames['topCalFrame'].document.calControl.year.value;
if (isFourDigitYear(year)) {
var month =
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
// IF MONTH IS DECEMBER, SET MONTH TO JANUARY AND INCREMENT THE YEAR
if (month == 11) {
month = 0;
year++;
calDate.setFullYear(year);
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
}
else {
month++;
}
calDate.setMonth(month);
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex =
month;
writeCalendar();
}
}
// SET THE GLOBAL DATE TO THE NEXT YEAR AND REDRAW THE CALENDAR
function setNextYear() {
var year =
top.newWin.frames['topCalFrame'].document.calControl.year.value;
if (isFourDigitYear(year)) {
year++;
calDate.setFullYear(year);
top.newWin.frames['topCalFrame'].document.calControl.year.value
= year;
writeCalendar();
}
}
// GET NUMBER OF DAYS IN MONTH
function getDaysInMonth() {
var days;
var month = calDate.getMonth()+1;
var year = calDate.getFullYear();
// RETURN 31 DAYS
if (month==1 || month==3 || month==5 || month==7 || month==8 ||
month==10 || month==12) {
days=31;
}
// RETURN 30 DAYS
else if (month==4 || month==6 || month==9 || month==11) {
days=30;
}
// RETURN 29 DAYS
else if (month==2) {
if (isLeapYear(year)) {
days=29;
}
// RETURN 28 DAYS
else {
days=28;
}
}
return (days);
}
// CHECK TO SEE IF YEAR IS A LEAP YEAR
function isLeapYear (Year) {
if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
return (true);
}
else {
return (false);
}
}
// ENSURE THAT THE YEAR IS FOUR DIGITS IN LENGTH
function isFourDigitYear(year) {
if (year.length != 4) {
top.newWin.frames['topCalFrame'].document.calControl.year.value
= calDate.getFullYear();
top.newWin.frames['topCalFrame'].document.calControl.year.select();
top.newWin.frames['topCalFrame'].document.calControl.year.focus();
}
else {
return true;
}
}
// BUILD THE MONTH SELECT LIST
function getMonthSelect() {
// BROWSER LANGUAGE CHECK DONE PREVIOUSLY (navigator.language())
// FIRST TWO CHARACTERS OF LANGUAGE STRING SPECIFIES THE LANGUAGE
// (THE LAST THREE OPTIONAL CHARACTERS SPECIFY THE LANGUAGE SUBTYPE)
// SET THE NAMES OF THE MONTH TO THE PROPER LANGUAGE (DEFAULT TO ENGLISH)
// IF FRENCH
if (selectedLanguage == "fr") {
monthArray = new Array('Janvier', 'Février', 'Mars', 'Avril',
'Mai', 'Juin',
'Juillet', 'Aout', 'Septembre', 'Octobre',
'Novembre', 'Décembre');
}
// IF GERMAN
else if (selectedLanguage == "de") {
monthArray = new Array('Januar', 'Februar', 'März',
'April', 'Mai', 'Juni',
'Juli', 'August', 'September',
'Oktober', 'November', 'Dezember');
}
// IF SPANISH
else if (selectedLanguage == "es") {
monthArray = new Array('Enero', 'Febrero',
'Marzo', 'Abril', 'Mayo', 'Junio',
'Julio', 'Agosto',
'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');
}
// DEFAULT TO ENGLISH
else {
monthArray = new Array('January', 'February',
'March', 'April', 'May', 'June',
'July', 'August', 'September',
'October', 'November', 'December');
}
// DETERMINE MONTH TO SET AS DEFAULT
var activeMonth = calDate.getMonth();
// START HTML SELECT LIST ELEMENT
monthSelect = "<SELECT NAME='month'
onChange='parent.opener.setCurrentMonth()'>";
// LOOP THROUGH MONTH ARRAY
for (i in monthArray) {
// SHOW THE CORRECT MONTH IN THE SELECT LIST
if (i == activeMonth) {
monthSelect += "<OPTION SELECTED>" + monthArray[i] +
"\n";
}
else {
monthSelect += "<OPTION>" + monthArray[i] + "\n";
}
}
monthSelect += "</SELECT>";
// RETURN A STRING VALUE WHICH CONTAINS A SELECT LIST OF ALL 12 MONTHS
return monthSelect;
}
// SET DAYS OF THE WEEK DEPENDING ON LANGUAGE
function createWeekdayList() {
// IF FRENCH
if (selectedLanguage == "fr") {
weekdayList = new Array('Dimanche', 'Lundi', 'Mardi',
'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
weekdayArray = new Array('Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve',
'Sa');
}
// IF GERMAN
else if (selectedLanguage == "de") {
weekdayList = new Array('Sonntag', 'Montag',
'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag');
weekdayArray = new Array('So', 'Mo', 'Di', 'Mi', 'Do',
'Fr', 'Sa');
}
// IF SPANISH
else if (selectedLanguage == "es") {
weekdayList = new Array('Domingo', 'Lunes',
'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado')
weekdayArray = new Array('Do', 'Lu', 'Ma',
'Mi', 'Ju', 'Vi', 'Sa');
}
else {
weekdayList = new Array('Sunday', 'Monday',
'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
weekdayArray = new
Array('Su','Mo','Tu','We','Th','Fr','Sa');
}
// START HTML TO HOLD WEEKDAY NAMES IN TABLE FORMAT
var weekdays = "<TR BGCOLOR='" + headingCellColor + "'>";
// LOOP THROUGH WEEKDAY ARRAY
for (i in weekdayArray) {
weekdays += "<TD class='heading' align=center>" +
weekdayArray[i] + "</TD>";
}
weekdays += "</TR>";
// RETURN TABLE ROW OF WEEKDAY ABBREVIATIONS TO DISPLAY ABOVE THE CALENDAR
return weekdays;
}
// PRE-BUILD PORTIONS OF THE CALENDAR (FOR PERFORMANCE REASONS)
function buildCalParts() {
// GENERATE WEEKDAY HEADERS FOR THE CALENDAR
weekdays = createWeekdayList();
// BUILD THE BLANK CELL ROWS
blankCell = "<TD align=center bgcolor='" + cellColor +
"'> </TD>";
// BUILD THE TOP PORTION OF THE CALENDAR PAGE USING CSS TO CONTROL SOME
DISPLAY ELEMENTS
calendarBegin =
"<HTML>" +
"<HEAD>" +
// STYLESHEET DEFINES APPEARANCE OF CALENDAR
"<STYLE type='text/css'>" +
"<!--" +
"TD.heading { text-decoration: none; color:" + headingTextColor
+ "; font: " + headingFontStyle + "; }" +
"A.focusDay:link { color: " + focusColor + "; text-decoration:
none; font: " + fontStyle + "; }" +
"A.focusDay:hover { color: " + focusColor + "; text-decoration:
none; font: " + fontStyle + "; }" +
"A.weekday:link { color: " + dateColor + "; text-decoration:
none; font: " + fontStyle + "; }" +
"A.weekday:hover { color: " + hoverColor + "; font: " +
fontStyle + "; }" +
"-->" +
"</STYLE>" +
"</HEAD>" +
"<BODY BGCOLOR='" + bottomBackground + "'" +
"<CENTER>";
// NAVIGATOR NEEDS A TABLE CONTAINER TO DISPLAY THE TABLE OUTLINES
PROPERLY
if (isNav) {
calendarBegin +=
"<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=" +
tableBorder + " ALIGN=CENTER BGCOLOR='" + tableBGColor + "'><TR><TD>";
}
// BUILD WEEKDAY HEADINGS
calendarBegin +=
"<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=" + tableBorder + "
ALIGN=CENTER BGCOLOR='" + tableBGColor + "'>" +
weekdays +
"<TR>";
// BUILD THE BOTTOM PORTION OF THE CALENDAR PAGE
calendarEnd = "";
// WHETHER OR NOT TO DISPLAY A THICK LINE BELOW THE CALENDAR
if (bottomBorder) {
calendarEnd += "<TR></TR>";
}
// NAVIGATOR NEEDS A TABLE CONTAINER TO DISPLAY THE BORDERS PROPERLY
if (isNav) {
calendarEnd += "</TD></TR></TABLE>";
}
// END THE TABLE AND HTML DOCUMENT
calendarEnd +=
"</TABLE>" +
"</CENTER>" +
"</BODY>" +
"</HTML>";
}
// REPLACE ALL INSTANCES OF find WITH replace
// inString: the string you want to convert
// find: the value to search for
// replace: the value to substitute
//
// usage: jsReplace(inString, find, replace);
// example: jsReplace("To be or not to be", "be", "ski");
// result: "To ski or not to ski"
//
function jsReplace(inString, find, replace) {
var outString = "";
if (!inString) {
return "";
}
// REPLACE ALL INSTANCES OF find WITH replace
if (inString.indexOf(find) != -1) {
// SEPARATE THE STRING INTO AN ARRAY OF STRINGS USING THE VALUE IN find
t = inString.split(find);
// JOIN ALL ELEMENTS OF THE ARRAY, SEPARATED BY THE VALUE IN replace
return (t.join(replace));
}
else {
return inString;
}
}
// JAVASCRIPT FUNCTION -- DOES NOTHING (USED FOR THE HREF IN THE CALENDAR CALL)
function doNothing() {
}
// ENSURE THAT VALUE IS TWO DIGITS IN LENGTH
function makeTwoDigit(inValue) {
var numVal = parseInt(inValue, 10);
// VALUE IS LESS THAN TWO DIGITS IN LENGTH
if (numVal < 10) {
// ADD A LEADING ZERO TO THE VALUE AND RETURN IT
return("0" + numVal);
}
else {
return numVal;
}
}
// SET FIELD VALUE TO THE DATE SELECTED AND CLOSE THE CALENDAR WINDOW
function returnDate(inDay)
{
// inDay = THE DAY THE USER CLICKED ON
calDate.setDate(inDay);
// SET THE DATE RETURNED TO THE USER
var day = calDate.getDate();
var month = calDate.getMonth()+1;
var year = calDate.getFullYear();
var monthString = monthArray[calDate.getMonth()];
var monthAbbrev = monthString.substring(0,3);
var weekday = weekdayList[calDate.getDay()];
var weekdayAbbrev = weekday.substring(0,3);
outDate = calDateFormat;
// RETURN TWO DIGIT DAY
if (calDateFormat.indexOf("DD") != -1) {
day = makeTwoDigit(day);
outDate = jsReplace(outDate, "DD", day);
}
// RETURN ONE OR TWO DIGIT DAY
else if (calDateFormat.indexOf("dd") != -1) {
outDate = jsReplace(outDate, "dd", day);
}
// RETURN TWO DIGIT MONTH
if (calDateFormat.indexOf("MM") != -1) {
month = makeTwoDigit(month);
outDate = jsReplace(outDate, "MM", month);
}
// RETURN ONE OR TWO DIGIT MONTH
else if (calDateFormat.indexOf("mm") != -1) {
outDate = jsReplace(outDate, "mm", month);
}
// RETURN FOUR-DIGIT YEAR
if (calDateFormat.indexOf("yyyy") != -1) {
outDate = jsReplace(outDate, "yyyy", year);
}
// RETURN TWO-DIGIT YEAR
else if (calDateFormat.indexOf("yy") != -1) {
var yearString = "" + year;
var yearString = yearString.substring(2,4);
outDate = jsReplace(outDate, "yy", yearString);
}
// RETURN FOUR-DIGIT YEAR
else if (calDateFormat.indexOf("YY") != -1) {
outDate = jsReplace(outDate, "YY", year);
}
// RETURN DAY OF MONTH (Initial Caps)
if (calDateFormat.indexOf("Month") != -1) {
outDate = jsReplace(outDate, "Month", monthString);
}
// RETURN DAY OF MONTH (lowercase letters)
else if (calDateFormat.indexOf("month") != -1) {
outDate = jsReplace(outDate, "month",
monthString.toLowerCase());
}
// RETURN DAY OF MONTH (UPPERCASE LETTERS)
else if (calDateFormat.indexOf("MONTH") != -1) {
outDate = jsReplace(outDate, "MONTH",
monthString.toUpperCase());
}
// RETURN DAY OF MONTH 3-DAY ABBREVIATION (Initial Caps)
if (calDateFormat.indexOf("Mon") != -1) {
outDate = jsReplace(outDate, "Mon", monthAbbrev);
}
// RETURN DAY OF MONTH 3-DAY ABBREVIATION (lowercase letters)
else if (calDateFormat.indexOf("mon") != -1) {
outDate = jsReplace(outDate, "mon",
monthAbbrev.toLowerCase());
}
// RETURN DAY OF MONTH 3-DAY ABBREVIATION (UPPERCASE LETTERS)
else if (calDateFormat.indexOf("MON") != -1) {
outDate = jsReplace(outDate, "MON",
monthAbbrev.toUpperCase());
}
// RETURN WEEKDAY (Initial Caps)
if (calDateFormat.indexOf("Weekday") != -1) {
outDate = jsReplace(outDate, "Weekday", weekday);
}
// RETURN WEEKDAY (lowercase letters)
else if (calDateFormat.indexOf("weekday") != -1) {
outDate = jsReplace(outDate, "weekday",
weekday.toLowerCase());
}
// RETURN WEEKDAY (UPPERCASE LETTERS)
else if (calDateFormat.indexOf("WEEKDAY") != -1) {
outDate = jsReplace(outDate, "WEEKDAY",
weekday.toUpperCase());
}
// RETURN WEEKDAY 3-DAY ABBREVIATION (Initial Caps)
if (calDateFormat.indexOf("Wkdy") != -1) {
outDate = jsReplace(outDate, "Wkdy", weekdayAbbrev);
}
// RETURN WEEKDAY 3-DAY ABBREVIATION (lowercase letters)
else if (calDateFormat.indexOf("wkdy") != -1) {
outDate = jsReplace(outDate, "wkdy",
weekdayAbbrev.toLowerCase());
}
// RETURN WEEKDAY 3-DAY ABBREVIATION (UPPERCASE LETTERS)
else if (calDateFormat.indexOf("WKDY") != -1) {
outDate = jsReplace(outDate, "WKDY",
weekdayAbbrev.toUpperCase());
}
// SET THE VALUE OF THE FIELD THAT WAS PASSED TO THE CALENDAR
calDateField.value = outDate;
// GIVE FOCUS BACK TO THE DATE FIELD
calDateField.focus();
// CLOSE THE CALENDAR WINDOW
top.newWin.close()
}
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/04
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1,
skwashd <=
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- [Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1, skwashd, 2005/05/05
- Prev by Date:
[Phpgroupware-cvs] old/ccs personnel.php, 1.1 admin.php, 1.1 index.php, 1.1 departments.php, 1.1 calendar.html, 1.1
- Next by Date:
[Phpgroupware-cvs] old/img/setup tables_current.inc.php, 1.1 default_records.inc.php, 1.1 phpgw_en.lang, 1.1 phpgw_fi.lang, 1.1 setup.inc.php, 1.1 phpgw_pl.lang, 1.1 phpgw_fr.lang, 1.1
- Previous by thread:
[Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1
- Next by thread:
[Phpgroupware-cvs] old/ccs/js formchek.js,1.1 calendar.js,1.1
- Index(es):