// ********************
Begin Popup Calendar
// ********************
var popcaldstfld;
var temp;
var Popcalwin;
var divcal;
var iframetemp;
var currentdate;
var imgpath = "";
var divcalheight = 180;
var divcalwidth = 255;
// ******************************
Expected params:
[0] Window Name
[1] Destination Field
[2] Short Date Format
[3] Month Names
[4] Day Names
[5] Localized today string
[6] Localized close string
[7] Window Title
[8] The Week
// ******************************
function popupcal ()
{
Debugger Remove slashes to activate debugging in Visual Studio
var tmpdate = new Date ();
var tmpstring = "";
var tmpnum = 0;
var popcaldateval;
var dstwindowname = "";
Initialize the window to a empty object.
Popcalwin = new Object ();
Check for the right number of arguments
if (Arguments.length < 2)
{
Alert ("Popupcal (): Wrong number of arguments.");
return void (0);
}
Get the command line arguments-Localization is optional
Imgpath = popupcal.arguments[0];
Dstwindowname = Popupcal.arguments[0];
POPCALDSTFLD = popupcal.arguments[1];
temp = popupcal.arguments[1];
POPCALDSTFMT = popupcal.arguments[2]; Localized short Date Format String
Popcalmonths = popupcal.arguments[3]; Localized Month Names String
Popcaldays = popupcal.arguments[4]; Localized Day Names String
Popcaltoday = popupcal.arguments[5]; Localized Today string
Popcalclose = popupcal.arguments[6]; Localized close string
Popcaltitle = popupcal.arguments[7]; Window Title
Popcalfirstdayweek = popupcal.arguments[8]; A Week
Popcalfirstdayweek = 0;
Check destination field name
if (popcaldstfld!= "")
POPCALDSTFLD = document.getElementById (POPCALDSTFLD);
Default localized Short date format if not provided
if (popcaldstfmt = "")
POPCALDSTFMT = "YYYY-MM-DD";
Default localized months string if not provided
if (popcalmonths = "")
popcalmonths = "January,february,march,april,may,june,july,august,september,october,november,december";
Default localized months string if not provided
if (popcaldays = "")
{
Popcaldays = "Sun,mon,tue,wed,thu,fri,sat";
}
Else
{
Popcaldays = "Day, one, two, three, four, five, six";
}
Default localized today string if not provided
if (Popcaltoday = = "" | | typeof Popcaltoday = = "undefined")
Popcaltoday = "Today";
Default localized close string if not provided
if (Popcalclose = = "" | | typeof popcalclose = = "undefined")
Popcalclose = "Close";
Default window title if not provided
if (Popcaltitle = = "" | | typeof Popcaltitle = = "undefined")
Popcaltitle = "Calendar";
tmpstring = new String (popcaldstfld.value);
If tmpstring is empty (meaning, the field is empty)
Use todays date as the starting point
if (tmpstring = "")
Popcaldateval = new Date ()
Else
{
Make sure the century are included, if it isn ' t, add this
Century to the value of that is in the field
Tmpnum = Tmpstring.lastindexof ("/");
if ((tmpstring.length-tmpnum) = = 3)
{
tmpstring = tmpstring.substring (0, Tmpnum + 1) + "+" + tmpstring.substr (Tmpnum + 1);
Popcaldateval = new Date (tmpstring);
}
Else
{
Localized Date support:
If we got to this point, it means the field is passed
In has no slashes in it. Use a extra function to build the date
According to supplied date formatstring.
Popcaldateval = Getdatefromformat (TMPSTRING,POPCALDSTFMT);
}
}
Make sure the "date is" a valid date. Set it to this if it is invalid
' NaN ' is the ' return value ' of ' invalid date
if (popcaldateval.tostring () = = "NaN" | | popcaldateval.tostring () = = "0")
{
Popcaldateval = new Date ();
Popcaldstfld.value = "";
}
currentdate = Popcaldateval;
Set the base date to midnight of the the specified month,
This makes things easier?
var datestring = string (Popcaldateval.getmonth () + 1) + "/" + string (popcaldateval.getdate ()) + "/" + S Tring (Popcaldateval.getfullyear ());
Call the routine to draw the initial calendar
Reloadcalpopup (datestring);
return void (0);
}
function Closecalpopup ()
{
Can ' t tell the child windows to close itself, the parent window has to
Tell it to close.
Popcalwin.close ();
DivCal.style.display = "None";
IframeTemp.style.display = "None";
return void (0);
}
function Reloadcalpopup ()//[0]datestring, [1]dstwindowname
{
var tmpdate = n
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.