📄 cal.js
字号:
this.codeINLINE += wtext;
}
}
Calendar.prototype.wwriteA = function(wtext) {
if (this.gType == "POPUP")
this.gWinCal.document.write(wtext);
else {
<!-- Keep adding to the codeINLINE variable.-->
this.codeINLINE += wtext;
}
}
function Calendar_CreateCalendarLayer(pLeft, pTop, pInitText) {
<!-- IMPORTANT :-->
<!--If you use relative positioning of this layer, use LAYER Tag for Netscape.-->
<!--If you want absolute positioning, use DIV tag for Netscape.-->
if (pInitText == null)
pInitText = Calendar.gInitText;
else
Calendar.gInitText = pInitText;
v_InlineX = pLeft;
v_InlineY = pTop;
var Calendar_ID = "Calendar";
if (isIE)
document.writeln("<DIV ID=\"" + Calendar_ID + "\" STYLE=\"" +
"position:absolute;top:" + pTop + ";left:" + pLeft + ";" +
"\">" + pInitText + "<\/DIV>");
else if (isNav)
document.writeln("<DIV ID=\"" + Calendar_ID + "\" STYLE=\"" +
"position:absolute;top:" + pTop + ";left:" + pLeft + ";" +
"\">" + pInitText + "<\/DIV>");
}
function Calendar_Lwwrite(pText, pINLINE) {
if (isIE) {
document.all[pINLINE].innerHTML = pText;
} else if (isNav) {
var lyr = document.layers[pINLINE].document;
lyr.open();
lyr.write(pText);
lyr.close();
}
}
function Calendar_MoveTo(pX, pY, pINLINE) {
if (isIE) {
document.all[pINLINE].style.top = pY;
document.all[pINLINE].style.left = pX;
} else if (isNav) {
document.layers[pINLINE].top = pY;
document.layers[pINLINE].left = pX;
}
}
<!--rag-n-Drop Functions-->
mDown = false;
mUp = false;
function click(e) {
mUp = false;
mDown = true;
if (isIE) {
<!-- Internet Explorer --->
x = event.clientX;
y = event.clientY;
cx = event.clientX - event.offsetX;
cy = event.clientY - event.offsetY;
} else if (isNav) {
<!-- Netscape Navigator --->
x = e.pageX;
y = e.pageY;
cx = theLayer.x;
cy = theLayer.y;
}
}
function unclick(e) {
mUp = true;
mDown = false;
}
function handleMove(e) {
<!-- Get page co-ords-->
if (isIE) {
<!-- Internet Explorer --->
currX = event.clientX;
currY = event.clientY;
} else if (isNav) {
<!-- Netscape Navigator --->
currX = e.pageX;
currY = e.pageY;
}
<!-- Find out the shift in page co-ords-->
incrX = currX - x;
incrY = currY - y;
<!-- If it is dragging, move the layer by the same shift..-->
if (mDown) {
<!-- Re-assign the v_Inline? co-ords so that the calendar layer-->
<!-- maintains it's new position later.-->
v_InlineX = cx + incrX;
v_InlineY = cy + incrY;
window.status = "DRAGGGGGG : X=" + v_InlineX + ", Y=" + v_InlineY;
MoveLayer(v_InlineX, v_InlineY, "myLayer");
} else
window.status = "X=" + currX + ", Y=" + currY;
}
function CalResize() {
<!-- Store these values -->
<!-- so that subsequent calendar windows keep the same settings.-->
v_Height = ggWinCal.innerHeight;
v_Width = ggWinCal.innerWidth;
}
function initEvents() {
if (isNav) {
theLayer.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEMOVE);
}
<!-- Assign handlers for mouse activity-->
theLayer.onmousemove = handleMove;
theLayer.onmousedown = click;
theLayer.onmouseup = unclick;
}
function MoveLayer(pX, pY) {
theCSSLayer.top = pY;
theCSSLayer.left = pX;
}
function drag_init(Leyer) {
if (isIE) {
theCSSLayer = document.all[Leyer].style;
theLayer = document.all[Leyer];
} else if (isNav) {
theCSSLayer = document.layers[Leyer];
theLayer = document.layers[Leyer];
}
initEvents();
}
<!--Calendar Build Function-->
function Build(p_item, p_month, p_year, p_format, p_type, p_custom) {
<!-- Read Custom parameters from the custom string here..-->
if (p_custom && p_custom != "") {
<!-- Reset the name/value variables -->
<!-- which should not be carried forward to the next calendar..-->
v_CurrentDate = "";
var vvars = name_values(p_custom);
} else
v_CurrentDate = "";
<!-- If the current date is specified, -->
<!-- split it & send it to the calendar...-->
var vCurrentDate;
if (v_CurrentDate || v_CurrentDate != "") {
vCurrentDate = new Date(v_CurrentDate);
p_month = vCurrentDate.getMonth();
p_year = vCurrentDate.getFullYear().toString();
} else
vCurrentDate = "NONE";
v_Resizable = (v_Resizable && v_Resizable != "") ? v_Resizable : "No";
<!--Neelesh-->
v_SelectAfter = new Date((v_SelectAfter && v_SelectAfter != "") ? v_SelectAfter : p_item.value);
v_NSHierarchy = isNav ?
((v_NSHierarchy && v_NSHierarchy != "") ? (v_NSHierarchy + ".") : "")
: "";
var vHeight, vWidth;
if (p_type == "POPUP") {
vWidth = (v_Width && v_Width != "") ? v_Width : 260;
if (isIE) vHeight = (v_Height && v_Height != "") ? v_Height : 265;
else if (isNav) vHeight = (v_Height && v_Height != "") ? v_Height : 250;
vWinCal = window.open("", "Calendar",
"width=" + vWidth + ",height=" + vHeight +
",status=no,resizable=" + v_Resizable);
vWinCal.opener = self;
ggWinCal = vWinCal;
var p_WinCal = ggWinCal;
if (isNav) ggWinCal.captureEvents(Event.RESIZE);
ggWinCal.onresize = CalResize;
}
gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format, p_type);
gCal.gCurrentDate = vCurrentDate;
gCal.gAllowWeekends =
(v_AllowWeekends && v_AllowWeekends != "" &&
v_AllowWeekends == "Yes") ? "Yes" : "No";
<!-- ############ CUSTOMIZE #############-->
<!-- Customize your Calendar here..-->
gCal.gBGColor="white";
gCal.gLinkColor="black";
gCal.gTextColor="black";
gCal.gHeaderColor="darkgreen";
gCal.closeable = v_CloseOnSelect ?((v_CloseOnSelect == "Yes") ? true : false): false;
gCal.returnMode = v_AppendOrReplace ?
v_AppendOrReplace : "Replace";
gCal.returnData = v_ReturnData ?
v_ReturnData : "Date";
<!-- Character to be added For Append mode-->
gCal.appendChar = (gCal.returnMode == "Append") ?
v_AppendChar ? v_AppendChar : ";"
: "";
<!-- Position for INLINE Calendar-->
<!-- It either comes from the Calendar_CreateCalendarLayer function or -->
<!-- from the -->
gCal.InlineX = v_InlineX ? v_InlineX : 100;
gCal.InlineY = v_InlineY ? v_InlineY : 100;
<!-- Re-position INLINE Calendar now-->
if (gCal.gType == "INLINE") {
Calendar.MoveTo(gCal.InlineX, gCal.InlineY, gCal.INLINE);
}
gCal.gTitle = v_Title ? v_Title : gCal.gMonthName + "/" + gCal.gYear;
<!-- ############ CUSTOMIZE #############-->
<!-- Choose appropriate show function-->
if (gCal.gYearly) gCal.showY();
else gCal.show();
if (gCal.gType == "INLINE") {
<!-- Initialize INLINE Calendar for drag-n-drop functionality-->
drag_init(gCal.INLINE);
}
}
<!-- ******************************************************************************* -->
<!--Monthly Calendar Code Starts here-->
function show_calendar() {
<!-- p_item : Return Item.-->
<!-- p_month : 0-11 for Jan-Dec 12 for All Months.-->
<!-- p_year : 4-digit year-->
<!-- p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)-->
<!-- p_type : POPUP/INLINE Calendar-->
<!-- p_custom: String of customizable name/value pair parameters-->
<!-- v_CloseOnSelect-->
<!-- v_AppendOrReplace-->
<!-- v_AppendChar-->
<!-- v_ReturnData
<!-- v_InlineX-->
<!-- v_InlineY-->
<!-- v_Title-->
<!-- v_AllowWeekends-->
<!-- v_Height-->
<!-- v_Width-->
<!-- v_Resizable-->
<!-- v_SelectAfter-->
<!-- v_NSHierarchy : If the form calling calendar is in a layer-->
<!-- (reqd only for Netscape)-->
p_item = arguments[0];
if (arguments[1] == null)
p_month = new String(gNow.getMonth());
else
p_month = (typeof(arguments[1]) == "number") ?
arguments[1].toString()
:
arguments[1];
if (arguments[2] == "" || arguments[2] == null)
p_year = new String(gNow.getFullYear().toString());
else
p_year = (typeof(arguments[2]) == "number") ?
arguments[2].toString()
:
arguments[2];
if (arguments[3] == null)
p_format = "DD-MON-YYYY";
else
p_format = (typeof(arguments[3]) == "string") ?
arguments[3]
:
"DD-MON-YYYY";
if (arguments[4] == null)
p_type = "POPUP";
else
p_type = (typeof(arguments[4]) == "string" &&
(arguments[4] == "POPUP" || arguments[4] == "INLINE")) ?
arguments[4]
:
"POPUP";
if (arguments[5] == null)
p_custom = "CloseOnSelect=Yes;AppendOrReplace=Replace;AppendChar=';';ReturnData=Date;Title=Popup Date Picker;AllowWeekends=Yes;Resizable=No";
else
p_custom = typeof(arguments[5]) == "string" ?
arguments[5]
:
"CloseOnSelect=Yes;AppendOrReplace=Replace;AppendChar=';';ReturnData=Date;Title=Popup Date Picker;AllowWeekends=Yes;Resizable=No";
Build(p_item, p_month, p_year, p_format, p_type, p_custom);
}
<!-- ******************************************************************************* -->
<!--Yearly Calendar Code Starts here-->
function show_yearly_calendar(p_item, p_year, p_format) {
<!-- Load the defaults..-->
if (p_year == null || p_year == "")
p_year = new String(gNow.getFullYear().toString());
else
p_year = (typeof(p_year) == "number") ?
p_year.toString()
:
p_year;
if (p_format == null || p_format == "")
p_format = "DD-MON-YYYY";
var vWinCal = window.open("", "Calendar", "scrollbars=yes");
vWinCal.opener = self;
ggWinCal = vWinCal;
Build(p_item, null, p_year, p_format);
}
<!-- *********************************EOF********************************* -->
function isYearOK() {
var retVal = 0;
if (theYear <= 50 && theYear >= 0)
theYear += 2000;
else if (theYear <= 99 && theYear >= 51)
theYear += 1900;
if (theYear >= 1951 && theYear <= 2050)
retVal = 1;
else
retVal = 0;
return retVal;
}
function isMonthOK() {
var retVal = 0;
if(theMonth <= 12 && theMonth != 0)
retVal = 1;
else
retVal = 0;
return retVal;
}
function isDayOK() {
var retVal = 0;
if(theMonth == 1 || theMonth == 3 || theMonth == 5 || theMonth == 7 || theMonth == 8 || theMonth == 10 || theMonth == 12) {
if (theDay >= 1 && theDay <= 31)
retVal = 1;
else
retVal = 0;
} else if (theMonth == 2) {
if (theDay >= 1 && theDay <=28)
retVal = 1;
else if (theDay == 29 && (theYear % 4) == 0)
retVal = 1;
else if (theDay == 29 && (theYear % 4) != 0)
retVal = 0;
else
retVal = 0;
} else {
if (theDay >= 1 && theDay <= 30)
retVal = 1;
else
retVal = 0;
}
return retVal;
}
function verifyDate(enteredMonth, enteredDay, enteredYear) {
retVal = 0;
theMonth = eval(enteredMonth);
theDay = eval(enteredDay);
theYear = eval(enteredYear);
if(enteredDay == null && enteredYear == null)
retVal = seperateDateString(enteredMonth);
else if (isMonthOK() == 0)
retVal = 1;
else if (isDayOK() == 0)
retVal = 2;
else if (isYearOK() == 0)
retVal = 3;
return retVal;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -