?? calendar.js
字號:
if(navigator.product=='Gecko')
{Document.prototype.attachEvent=function(sType,fHandler){var shortTypeName=sType.replace(/on/,"");
fHandler._ieEmuEventHandler=function(e){window.event=e;return fHandler();};
this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);};
Event.prototype.__defineSetter__("returnValue",function(value){if(!value){this.preventDefault();}return value;});
Event.prototype.__defineGetter__("srcElement",function(){var node=this.target;
while(node.nodeType!=1){node=node.parentNode;}
return node;});
HTMLElement.prototype.attachEvent=function(sType,fHandler)
{var shortTypeName=sType.replace(/on/,"");
fHandler._ieEmuEventHandler=function(e){window.event=e;return fHandler();};
this.addEventListener(shortTypeName,fHandler._ieEmuEventHandler,false);};
HTMLElement.prototype.insertAdjacentElement=function(where,parsedNode){switch(where){case"beforeBegin":
this.parentNode.insertBefore(parsedNode,this);
break;
case"afterBegin":
this.insertBefore(parsedNode,this.firstChild);
break;
case"beforeEnd":
this.appendChild(parsedNode);
break;
case"afterEnd":
if(this.nextSibling){this.parentNode.insertBefore(parsedNode,this.nextSibling);}
else{this.parentNode.appendChild(parsedNode);}
break;}};}
$BindAsEventListener=function(sender,listener){var __method=sender;
return function(event){return __method.call(listener,event||window.event);}}
function __sb()
{this.s=new Array();
this.i=0;
this.a=function(t){this.s[this.i++]=t;};
this.j=function(){return this.s.join('');};}
function $(id){return document.getElementById(id);}
var $d=null;
function My97DatePicker(){if(parent==window)return;
if(location.href.substring(location.href.length-3).toLowerCase()=='#97'){location.href=location.href.substring(0,location.href.length-3);
return;}
else{location.href=location.href+"#97";}
this.init();
this.dd=document.createElement("DIV");
this.dd.style.cssText='position:absolute;z-index:197;display:block;';
this.dd.obj=this;
this.dd.className="WdateDiv";
this.dd.innerHTML=this._createPickerHTML();
var tmpImgs=this.dd.getElementsByTagName('img');
this.dd.navLeftImg=tmpImgs[0];
this.dd.leftImg=tmpImgs[1];
this.dd.rightImg=tmpImgs[2];
this.dd.navRightImg=tmpImgs[3];
this.dd.navLeftImg.onclick=function(){$d.yInput.value=parseInt($d.yInput.value)-1;
$d.obj.redraw();}
this.dd.leftImg.onclick=function(){if(parseInt($d.mInput.getAttribute("realValue"))>1){$d.mInput.setAttribute("realValue",parseInt($d.mInput.getAttribute("realValue"))-1);}
else{$d.mInput.setAttribute("realValue",12);
$d.yInput.value=parseInt($d.yInput.value)-1;}
$d.mInput.value=dpcfg.aMonStr[parseInt($d.mInput.getAttribute("realValue"))-1];
$d.obj.redraw();}
this.dd.rightImg.onclick=function(){if(parseInt($d.mInput.getAttribute("realValue"))<12){$d.mInput.setAttribute("realValue",parseInt($d.mInput.getAttribute("realValue"))+1);}
else{$d.mInput.setAttribute("realValue",1);
$d.yInput.value=parseInt($d.yInput.value)+1;}
$d.mInput.value=dpcfg.aMonStr[parseInt($d.mInput.getAttribute("realValue"))-1];
$d.obj.redraw();}
this.dd.navRightImg.onclick=function(){$d.yInput.value=parseInt($d.yInput.value)+1;
$d.obj.redraw();}
var tmpInputs=this.dd.getElementsByTagName('input');
this.dd.mInput=tmpInputs[0];
this.dd.yInput=tmpInputs[1];
this.dd.mInput.setAttribute('realValue',this.month);
this.dd.mInput.value=dpcfg.aMonStr[this.month-1];
this.dd.yInput.value=this.year;
var tmpDivs=this.dd.getElementsByTagName('div');
this.dd.titleDiv=tmpDivs[0];
this.dd.mDiv=tmpDivs[3];
this.dd.yDiv=tmpDivs[5];
this.dd.dDiv=tmpDivs[7];
this.dd.tDiv=tmpDivs[8].firstChild;
this.dd.bDiv=tmpDivs[10];
this.dd.dDiv.innerHTML=this._createDateTable();
this._inputKeydown=function(){var evt=event;
var k=(evt.which==undefined)?evt.keyCode:evt.which;
if(!((k>=48&&k<=57)||(k>=96&&k<=105)||k==8||k==46||k==37||k==39||k==9)){evt.returnValue=false;}};
this.dd.mInput.attachEvent('onkeydown',function(){var evt=event;
var k=(evt.which==undefined)?evt.keyCode:evt.which;
if(k==9){$d.mDiv.style.display='none';}
if(event.srcElement.value.length-document.selection.createRange().text.length==2){event.returnValue=false;};});
this.dd.yInput.attachEvent('onkeydown',function(){var evt=event;
var k=(evt.which==undefined)?evt.keyCode:evt.which;
if(k==9){$d.yDiv.style.display='none';}});
this.dd.mInput.attachEvent('onkeydown',this._inputKeydown);
this.dd.yInput.attachEvent('onkeydown',this._inputKeydown);
this.dd.yInput.onblur=function(){var v=parseInt(this.value);
if(v<$d.obj.minDate.year){this.value=$d.obj.minDate.year;}
else if(v>$d.obj.maxDate.year){this.value=$d.obj.maxDate.year;}
if(v!=$d.obj.year){$d.obj.redraw();}
this.className='yminput';};
this.dd.mInput.onblur=function(){if(parseInt(this.value)>12){this.value='12';}
else if(v<1){this.value='1';}
var tmpYM=$d.obj.year*100+parseInt(this.value)*1;
if(tmpYM<($d.obj.minDate.year*100+$d.obj.minDate.month*1)){this.value=$d.obj.minDate.month;}
else if(tmpYM>($d.obj.maxDate.year*100+$d.obj.maxDate.month*1)){this.value=$d.obj.maxDate.month;}
var v=parseInt(this.value);
this.setAttribute('realValue',v);
this.value=dpcfg.aMonStr[v-1]
if(v!=$d.obj.month){$d.obj.redraw();}
this.className='yminput';};
this.dd.mInput.onfocus=function(){this.className='yminputfocus';
this.value=this.getAttribute("realValue");
this.select();
if($d.obj.hasDate){$d.obj._fillmonth();
$d.mDiv.style.display='block';}};
this.dd.yInput.onfocus=function(){this.className='yminputfocus';
this.select();
if($d.obj.hasDate){$d.obj._fillyear();
$d.yDiv.style.display='block';}};
this.dd.hhInput=tmpInputs[2];
this.dd.hmSplitInput=tmpInputs[3];
this.dd.mmInput=tmpInputs[4];
this.dd.msSplitInput=tmpInputs[5];
this.dd.ssInput=tmpInputs[6];
this.dd.clearInput=tmpInputs[7];
this.dd.todayInput=tmpInputs[8];
this.dd.okInput=tmpInputs[9];
this.dd.hhInput.onfocus=this.dd.mmInput.onfocus=this.dd.ssInput.onfocus=function(){this.select();$d.obj.currFocus=this;};
this.dd.hhInput.onblur=function(){if(parseInt(this.value)>23){this.value='23';}
else if(parseInt(this.value)<0){this.value='0';}};
this.dd.mmInput.onblur=this.dd.ssInput.onblur=function(){if(parseInt(this.value)>59){this.value='59';}
else if(parseInt(this.value)<0){this.value='0';}};
this.dd.hmSplitInput.attachEvent('onfocus',function(){$d.mmInput.focus();});
this.dd.msSplitInput.attachEvent('onfocus',function(){$d.ssInput.focus();});
this.dd.ssInput.attachEvent('onkeydown',function(){var evt=event;
var k=(evt.which==undefined)?evt.keyCode:evt.which;
if(k==9){$d.downButton.focus();}});
this.dd.hhInput.attachEvent('onkeydown',this._inputKeydown);
this.dd.mmInput.attachEvent('onkeydown',this._inputKeydown);
this.dd.ssInput.attachEvent('onkeydown',this._inputKeydown);
var tmpBtn=this.dd.getElementsByTagName('button');
this.dd.upButton=tmpBtn[0];
this.dd.downButton=tmpBtn[1];
this.dd.upButton.onclick=function(){if($d.obj.currFocus==undefined){$d.obj.currFocus=$d.mmInput;}
if(($d.obj.currFocus==$d.hhInput&&parseInt($d.obj.currFocus.value)<23)||($d.obj.currFocus!=$d.hhInput&&parseInt($d.obj.currFocus.value)<59)){$d.obj.currFocus.value=parseInt($d.obj.currFocus.value)+1;}
else{$d.obj.currFocus.value='0';}
$d.obj.currFocus.focus();};
this.dd.downButton.onclick=function(){if($d.obj.currFocus==undefined){$d.obj.currFocus=$d.mmInput;}
if(parseInt($d.obj.currFocus.value)>0){$d.obj.currFocus.value=parseInt($d.obj.currFocus.value)-1;}
else{if($d.obj.currFocus==$d.hhInput){$d.obj.currFocus.value='23';}
else{$d.obj.currFocus.value='59';}}
$d.obj.currFocus.focus();};
$d=this.dd;
document.body.insertAdjacentElement('beforeEnd',this.dd);
this._setOkInput();
this._setShowAndHide();}
My97DatePicker.prototype.init=function(){this._todayDate=new Date();
this.t_year=this._todayDate.getFullYear();
this.t_month=this._todayDate.getMonth()+1;
this.t_date=this._todayDate.getDate();
this.t_hour=this._todayDate.getHours();
this.t_minute=this._todayDate.getMinutes();
this.t_sec=this._todayDate.getSeconds();
var tmpdd=parent.$dp;
this.eCont=tmpdd.obj.eCont;
this.dateFmt=tmpdd.obj.dateFmt||dpcfg.dateFmt;
this.showTime=(tmpdd.obj.showTime==true)?tmpdd.obj.showTime:dpcfg.showTime;
this.skin=tmpdd.obj.skin||dpcfg.skin;
this.onPicked=new parent.$dp.obj.win.Function(this.eCont.getAttribute("ONPICKED"));
this.onPicked=$BindAsEventListener(this.onPicked,this.eCont);
this.hasYear=(this.dateFmt.indexOf('%Y')==-1)?false:true;
this.hasMonth=(this.dateFmt.indexOf('%M')==-1)?false:true;
this.hasDate=(this.dateFmt.indexOf('%D')==-1)?false:true;
this.hasHour=(this.dateFmt.indexOf('%h')==-1)?false:true;
this.hasMin=(this.dateFmt.indexOf('%m')==-1)?false:true;
this.hasSec=(this.dateFmt.indexOf('%s')==-1)?false:true;
this.minDate=this._doCustomDate(this.eCont.getAttribute("MINDATE"),dpcfg.realValueShortFmt,"min");
this.maxDate=this._doCustomDate(this.eCont.getAttribute("MAXDATE"),dpcfg.realValueShortFmt,"max");
if((this.minDate.year*10000+this.minDate.month*100+this.minDate.date*1)>(this.maxDate.year*10000+this.maxDate.month*100+this.maxDate.date*1)){alert('\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u6700\u5927\u65E5\u671F(MinDate Cannot be bigger than MaxDate)!')
parent.$dp.obj.eCont.onfocus=function(){};
parent.$dp.obj.eCont.onclick=function(){alert('\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u6700\u5927\u65E5\u671F(MinDate Cannot be bigger than MaxDate)!')};}
this._setActiveCSS();
this._initDate(this.eCont.value,this.dateFmt);
if(this.eCont.value!=''&&this.eCont.getAttribute("REALVALUE")==null&&this._judgeCorrectDateTime(this.eCont.value)){this._setRealValue();}
this.s_year=this.year;
this.s_month=this.month;
this.s_date=this.date;
this.eCont.getValue=function(){if(this.value==''){return'';}
else{return this.getAttribute("REALVALUE");}};};
My97DatePicker.prototype._setShowAndHide=function(){if(!(this.hasYear||this.hasMonth)){this.dd.titleDiv.style.display='none';}
else{this.dd.titleDiv.style.display='';}
if(!this.hasYear){this.dd.yInput.style.display=this.dd.navLeftImg.style.display=this.dd.navRightImg.style.display='none';}
else{this.dd.yInput.style.display=this.dd.navLeftImg.style.display=this.dd.navRightImg.style.display='';}
if(!this.hasMonth){this.dd.mInput.style.display=this.dd.leftImg.style.display=this.dd.rightImg.style.display='none';}
else{this.dd.mInput.style.display=this.dd.leftImg.style.display=this.dd.rightImg.style.display='';}
if(!this.hasDate){this.dd.dDiv.style.display='none';}
else{this.dd.dDiv.style.display='';}
if(!this.hasHour){this.dd.hhInput.disabled='disabled';}
else{this.dd.hhInput.disabled='';}
if(!this.hasMin){this.dd.mmInput.disabled='disabled';}
else{this.dd.mmInput.disabled='';}
if(!this.hasSec){this.dd.ssInput.disabled='disabled';}
else{this.dd.ssInput.disabled='';}}
My97DatePicker.prototype._setActiveCSS=function(){var i,a,main;
for(i=0;(a=document.getElementsByTagName("link")[i]);i++){if(a.getAttribute("rel").indexOf("style")!=-1&&a.getAttribute("title")){a.disabled=true;
if(a.getAttribute("title")==this.skin)a.disabled=false;}}};
My97DatePicker.prototype.redraw=function(){this.year=this.dd.yInput.value;
this.month=this.dd.mInput.getAttribute("realValue");
this.dd.dDiv.innerHTML=this._createDateTable();
autoSizeIframe();};
My97DatePicker.prototype._initDate=function(str,fmt)
{this.year=this.month=this.date=this.hour=this.minute=this.sec=-1;
var v=str.split(/\W+/);
var f=fmt.match(/%./g);
for(var i=0;i<f.length;i++){if(v[i]){if(f[i].toLowerCase()=='%y'){this.year=parseInt(v[i],10);
if(isNaN(this.year)){this.year=this.t_year;}}
else if(f[i]=='%M'){this.month=parseInt(v[i],10);
if(isNaN(this.month)){this.month=this.t_month;}}
else if(f[i].toLowerCase()=='%d'){this.date=parseInt(v[i],10);
if(isNaN(this.date)){this.date=this.t_date;}}
else if(f[i].toLowerCase()=='%h'){this.hour=parseInt(v[i],10);
if(isNaN(this.hour)){this.hour=this.t_hour;}}
else if(f[i]=='%m'){this.minute=parseInt(v[i],10);
if(isNaN(this.minute)){this.minute=this.t_minute;}}
else if(f[i].toLowerCase()=='%s'){this.sec=parseInt(v[i],10);
if(isNaN(this.sec)){this.sec=this.t_sec;}}}}
if(!this._isDate(this.year+'-'+this.month+'-'+this.date)){this.year=this.t_year;this.month=this.t_month;this.date=this.t_date;}
if((this.hour<0)||(this.hour>23)){this.hour=this.t_hour;}
if((this.minute<0)||(this.minute>59)){this.minute=this.t_minute;}
if((this.sec<0)||(this.sec>59)){this.sec=this.t_sec;}};
My97DatePicker.prototype._isDate=function(sDate){return sDate.match(/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/);};
My97DatePicker.prototype._createPickerHTML=function()
{var s=new __sb();
s.a("<div id=dpTitle>");
s.a("<div style='float:left;margin:2px;width:45px'><img style='cursor:pointer;' src='skin/"+this.skin+"/navLeft.gif' width=14 height=16 /><img style='cursor:pointer;' src='skin/"+this.skin+"/left.gif' width=14 height=16 /></div>");
s.a("<div style='float:left;margin:2px;'><div style='margin-left:0px;width:62px' class='ymsel'></div><input class='yminput' style='margin-top:1px;width:30px;' maxlength=3></div>");
s.a("<div style='float:left;margin:2px'><div style='margin-left:0px' class='ymsel'></div><input class='yminput' style='margin-top:-1px;width:40px;' maxlength=4></div>");
s.a("<div style='float:right;margin:2px'><img style='cursor:pointer;' src='skin/"+this.skin+"/right.gif' width=14 height=16 /><img style='cursor:pointer;' src='skin/"+this.skin+"/navRight.gif' width=14 height=16 /></div></div>");
s.a("<div></div>");
s.a("<div>");
s.a(this._createTimeTable());
s.a("</div>");
return s.j();};
My97DatePicker.prototype._createDateTable=function(){var tempYear,tempMonth;
if((this.year*100+this.month*1)<(this.minDate.year*100+this.minDate.month*1)){this.dd.yInput.value=tempYear=this.minDate.year;
tempMonth=this.minDate.month;
this.dd.mInput.value=dpcfg.aMonStr[tempMonth-1];
this.dd.mInput.setAttribute('realValue',tempMonth);}
else if((this.year*100+this.month*1)>(this.maxDate.year*100+this.maxDate.month*1)){this.dd.yInput.value=tempYear=this.maxDate.year;
tempMonth=this.maxDate.month;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -