📄 jscalendar.js
字号:
//if(i == 6) _td.className = "tdSat";
if(d - 1 > _monthDays[_dCurMonth]){
dCurDate = dNextMonthDate++;
//_td.disabled = true;
_td.className = "nextMonth";
_td.name = "NEXTMONTH";
}
//if(dCurDate < 10) dCurDate = "0" + dCurDate;
_td.innerHTML = dCurDate;
if(dCurDate == _dCurDate && _td.name == "CURRENTMONTH"){
//_cldTabFrm.rows(iRow).cells(i).style.backgroundColor = "620662";
//_cldTabFrm.rows(iRow).cells(i).background = "bgCurDate.gif";
_cldTabFrm.rows(iRow).cells(i).className = "tdCurDate";
}
if(dCurDate == _dftD.getDate()
&& _dCurMonth == _dftD.getMonth()
&& _dCurYear == _dftD.getFullYear()
&& _td.name == "CURRENTMONTH"){
_cldTabFrm.rows(iRow).cells(i).className = "tdToday";
if(dCurDate == _dCurDate)
_cldTabFrm.rows(iRow).cells(i).className = "tdTodayCurDate";
}
if(dCurDate == _dftD.getDate() && dCurDate == _dCurDate && _td.name == "CURRENTMONTH"){
//_td.style.backgroundColor = "#663366";
//_td.style.border = "1px solid gray";
//_cldTabFrm.rows(iRow).cells(i).className = "tdTodayCurDate";
}
}
i = 0;
iRow++;
}
}
function placeCldTabFrm(){
var _rect = this._rltvO.getBoundingClientRect();
var _bodyWidth = document.body.clientWidth;
var _bodyHeight = document.body.clientHeight;
var _tmp = _cldTabIFrame;
//alert(_bodyHeight);
_cldTabIFrame = _cldTabIFrame2;
var _innerTabFrmRect = _cldTabFrm.getBoundingClientRect();
//_debug(_innerTabFrmRect.right + "," + _innerTabFrmRect.left)
//_cldTabIFrame2.style.pixelWidth = /*_innerTabFrmRect.right - _innerTabFrmRect.left*/ 350 + (_bBrowserVer55 ? 0 : _nShadowLength);
_cldTabIFrame2.style.pixelWidth = 200;
//_cldTabIFrame2.style.pixelHeight = _innerTabFrmRect.bottom - _innerTabFrmRect.top + (_bBrowserVer55 ? 0 : _nShadowLength);
_cldTabIFrame2.style.pixelHeight = 156;
_cldTabIFrame.style.pixelLeft = _rect.left - 0 + document.body.scrollLeft;
_cldTabIFrame.style.pixelTop = _rect.bottom - 0 + document.body.scrollTop;
var _cldTabFrmRect = _cldTabIFrame.getBoundingClientRect();
if(_cldTabFrmRect.right > _bodyWidth){
_cldTabIFrame.style.pixelLeft -= (_cldTabFrmRect.right - _bodyWidth + _nShadowLength);
}
if(_cldTabFrmRect.bottom > _bodyHeight){
//alert("dd");
_cldTabIFrame.style.pixelTop = _rect.top - _nShadowLength;
_cldTabIFrame.style.pixelTop -= (_cldTabFrmRect.bottom - _cldTabFrmRect.top - document.body.scrollTop);
}
//alert(_cldTabIFrame.style.pixelWidth);
_cldTabIFrame = _tmp;
//if(
}
function whenMouseOverCldTabFrm(){
_bCanHide = false;
}
function whenMouseOutCldTabFrm(){
_bCanHide = true;
}
function getNextDate(year, month, date){
if(date == null) date = 1;
if(date > _monthDays[month + 1]) date = _monthDays[month + 1];
return new Date(year, month + 1, date);
}
function getLastDate(year, month, date){
if(date == null) date = 1;
if(date > _monthDays[month - 1]) date = _monthDays[month - 1];
return new Date(year, month - 1, date);
}
function switchLastMonth(bLast){
if(bLast == null) bLast = true;
var _tmpdate = null;
_tmpdate = bLast ? getLastDate(_dCurYear, _dCurMonth, _dCurDate) : getNextDate(_dCurYear, _dCurMonth, _dCurDate);
//_curCldTabRltvObj.value = _tmpdate.getFullYear() + "-" + (_tmpdate.getMonth() + 1) + "-" + _tmpdate.getDate();
setTargetFormaValue(_tmpdate.getFullYear(), _tmpdate.getMonth() + 1, _tmpdate.getDate());
_bHaveUpdated = false;
//JSCalendar(_curCldTabRltvObj);
fillCldTabFrm(_tmpdate.getFullYear(), _tmpdate.getMonth(), _tmpdate.getDate());;
}
function switchNextMonth(){
switchLastMonth(false);
}
function switchLastYear(){
//_curCldTabRltvObj.value = (_dCurYear * 1 + 1) + "-" + (_dCurMonth + 1) + "-" + _dCurDate;
setTargetFormaValue(_dCurYear * 1 + 1, _dCurMonth * 1 + 1, _dCurDate);
_bHaveUpdated = false;
//JSCalendar(_curCldTabRltvObj);
fillCldTabFrm(_dCurYear * 1 + 1, _dCurMonth * 1, _dCurDate);
}
function switchNextYear(){
//_curCldTabRltvObj.value = (_dCurYear - 1) + "-" + (_dCurMonth + 1) + "-" + _dCurDate;
setTargetFormaValue(_dCurYear * 1 - 1, _dCurMonth * 1 + 1, _dCurDate);
_bHaveUpdated = false;
//JSCalendar(_curCldTabRltvObj);
fillCldTabFrm(_dCurYear * 1 - 1, _dCurMonth * 1, _dCurDate);
}
function whenMouseOverDateItem(){
var e = _cldTabIFrame.event.srcElement;
var _tmpdate = null;
if(e.tagName == "TD"){
if(e.name == "LASTMONTH"){
_tmpdate = getLastDate(_dCurYear, _dCurMonth);
e.title = "Last : " + _tmpdate.getFullYear() + "-" + (_tmpdate.getMonth() + 1) + "-" + e.innerText;
return;
}
if(e.name == "NEXTMONTH"){
_tmpdate = getNextDate(_dCurYear, _dCurMonth);
e.title = "Next : " + _tmpdate.getFullYear() + "-" + (_tmpdate.getMonth() + 1) + "-" + e.innerText;
return;
}
var sCurDate = _dCurYear + "-" + (_dCurMonth + 1) + "-" + e.innerText;
e.title = "当前日期: " + sCurDate;
if(_lstFocus!=null){_lstFocus.style.backgroundColor="#ffffff";
e.style.backgroundColor = "#DEDEDE";
}
else{e.style.backgroundColor = "#DEDEDE";}_lstFocus=e;
setTargetFormaValue(_dCurYear, _dCurMonth + 1, e.innerText);
}
}
function resetTargetValue(){
_curCldTabRltvObj.value = "";
window.returnValue=document.all[_dateObjName].value;
//opener.document.all[_dateObjName].value=document.all[_dateObjName].value;
_bHaveSelectNewValue = true;
window.close();
}
function setTargetFormaValue(year, month, date){
var _year, _month, _date;
_year = year;
_month = month * 1;
_date = date * 1;
if(_month < 10) _month = "0" + _month;
if(_date < 10) _date = "0" + _date;
_curCldTabRltvObj.value = _year + "-" + _month + "-" + _date;
}
function whenMouseOutDateItem(){
var e = _cldTabIFrame.event.srcElement;
if(e.tagName == "TD")
e.style.backgroundColor = "";
}
function whenClickDateItem(){
var e = _cldTabIFrame.event.srcElement;
var _tmpdate = null;
var _month = null;
var _date = null;
if(e.tagName == "TD"){
_bHaveUpdated = false;
if(e.name == "LASTMONTH"){
_tmpdate = getLastDate(_dCurYear, _dCurMonth);
setTargetFormaValue(_tmpdate.getFullYear(), _tmpdate.getMonth() + 1, e.innerText);
fillCldTabFrm(_tmpdate.getFullYear(), _tmpdate.getMonth(), e.innerText);
/* new */ //JSCalendar(_curCldTabRltvObj);
return;
}
if(e.name == "NEXTMONTH"){
_tmpdate = getNextDate(_dCurYear, _dCurMonth);
setTargetFormaValue(_tmpdate.getFullYear(), _tmpdate.getMonth() + 1, e.innerText);
/* new */ //JSCalendar(_curCldTabRltvObj);
fillCldTabFrm(_tmpdate.getFullYear(), _tmpdate.getMonth(), e.innerText);
return;
}
_bHaveSelectNewValue = true;
//hideCldTabFrm();
window.returnValue=document.all[_dateObjName].value;
//opener.document.all[_dateObjName].value=document.all[_dateObjName].value;
window.close();
}
}
function hideCldTabFrm(){
//try{
if(!_bHaveSelectNewValue)
if(_cldTabIFrame == null || !_bCanHide) return;
//alert(_cldTabIFrame);
var oFiredObj = null;
try{
oFiredObj = event.srcElement;
}catch(e){
oFiredObj = _cldTabIFrame.event.srcElement;
}
if(oFiredObj == _curCldTabRltvObj) return;
//alert(_curCldTabRltvObj);//
_cldTabIFrame2.style.display = "none";
_bHaveUpdated = false;
_bHaveShown = false;
removeShadowDiv();
//alert(_bHaveSelectNewValue);
if(!_bHaveSelectNewValue)
_curCldTabRltvObj.value = _curCldTabRltvObjValue;
//}catch(e){_debug(e.description);}
}
function removeShadowDiv(){
try{
var arrShadowDiv = eval("window.document.arr" + _cldTabFrm.id);
for(var i = 0; i < arrShadowDiv.length; i++)
arrShadowDiv[i].removeNode(true);
}catch(e){_debug(e.description);}
}
function getValidateDate(sDate){
if(sDate == null) return new Date();
if(sDate.indexOf("-") == -1){
if(isNaN(sDate)) return new Date();
if(sDate * 1 > 9999 || sDate * 1 < 1000) return new Date();
return new Date(sDate, 0, 1);
}
var tmp = sDate.split("-");
if(isNaN(tmp[0]) || isNaN(tmp[1]) || isNaN(tmp[2])
|| tmp[0] > 9999 || tmp[0] < 1000
|| tmp[1] > 12 || tmp[1] < 1
|| tmp[2] > 31 || tmp[2] < 1)
return new Date();
return new Date(tmp[0], tmp[1] - 1, tmp[2]);
}
//var tst = getValidateDate("2000-7-310");
//alert(tst.getFullYear() + "-" + (tst.getMonth() + 1) + "-" + tst.getDate());
function createDateBox(sBoxName, sDfltValue){
var _d = getValidateDate(sDfltValue);
var _month = _d.getMonth() + 1;
var _date = _d.getDate();
if(_month * 1 < 10) _month = "0" + _month;
if(_date * 1 < 10) _date = "0" + _date;
sDfltValue = _d.getFullYear() + "-" + _month + "-" + _date;
//alert(sDfltValue);
var _str = "<INPUT READONLY STYLE='border:1px solid gray;text-align:center;cursor:default;display:none' NAME='tt' VALUE='" + sDfltValue + "' onchange=fillBlank('tt')>";
document.write(_str);
}
function MakeDivShadowEffect(divObj, color, nLength)
{
//alert(divObj);
var tmpstr = "window.document.arr" + divObj.id + " = new Array();";
eval(tmpstr);
//alert( tmpstr );
var arrShadowDiv = eval("window.document.arr" + divObj.id);
//window.document.arrJACKSHANGJIELOVEFEIFEI = new Array();
//var arrShadowDiv = window.document.arrJACKSHANGJIELOVEFEIFEI;
//alert(arrShadowDiv.length);
var _rect = divObj.getBoundingClientRect();
for( i = nLength; i > 0; i --)
{
var rect = _cldTabIFrame.document.createElement( "DIV" );
rect.style.position = "absolute";
rect.style.left = (divObj.style.posLeft + i ) + "px";
rect.style.top = (divObj.style.posTop + i ) + "px";
rect.style.width = divObj.offsetWidth + "px";
rect.style.height = divObj.offsetHeight + "px";
rect.style.backgroundColor = color;
var opacity = 1 - i / (i + 1);
//alert(rect.style.width);
rect.style.filter = 'alpha(opacity=' + (100 * opacity) + ')';
rect.style.zIndex = divObj.style.zIndex - 1;
//alert(divObj.tagName);
//divObj.insertAdjacentElement("beforeEnd", rect);
_cldTabIFrame.document.body.insertBefore(rect);
arrShadowDiv[arrShadowDiv.length] = rect;
//alert( i );
}
}
function setYearValue(year){
setTargetFormaValue(year, _dCurMonth * 1 + 1 , _dCurDate);
fillCldTabFrm(year, _dCurMonth * 1 , _dCurDate);
}
function setMonthValue(month){
setTargetFormaValue(_dCurYear, month * 1 + 1 , _dCurDate);
fillCldTabFrm(_dCurYear, month * 1 , _dCurDate);
}
function selectQustion(name,inputDate,path){
var _regExp = /^((19)|(20))[0-9]{2}-([0-9]|(0[0-9])|(1[0-2]))-([0-9]|([0-2][0-9])|([3][0-1]))$/g;
if(inputDate.match(_regExp) != null){
var xURL= path + "framework/js/date.jsp?inputName="+name+"&inputDate="+inputDate+"&path="+path;
}else{
var xURL= path + "framework/js/date.jsp?inputName="+name+"&inputDate=''"+"&path="+path;
}
var showx = event.screenX - event.offsetX - 160;
var showy = event.screenY - event.offsetY + 18;
//var retval = window.open(xURL,"日历","height=159, width=203,left="+showx+",top="+showy+",toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no,status=no");
var windowProps="dialogWidth:206px; dialogHeight:200px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px;directories:no;scroll:no;Resizable=no;help:no";
var retval = window.showModalDialog(xURL,"日历",windowProps);
if(retval==null) return null;
window.document.all[name].value=retval;
}
function _debug(s){
return;
//var o = new Option(s, s);
//_debugLst.add(o);
form1._debugLst.options[form1._debugLst.length] = new Option(s, s, 0, 0);
form1._debugLst.options[form1._debugLst.length - 1].selected = true;
//_debugLst.item(_debugLst.length - 1).selected = true;
}
document.onclick = hideCldTabFrm;
//createCldTabFrm();
//-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -