一派護法 十九級 |
var inputCalendar={ nodes:new Object(), inputNode:null, frame:null, opened:false, open:function(inputNode){ if (this.opened) this.close(false); this.opened=true; var da=new Date(); var fyear=da.getFullYear(); var fmonth=da.getMonth(); var frame=createNode('inputCalendar_frame','div',top.document.body,'inputCalendar'); var inputPosition=Base.Document.getPosition(inputNode); var x=inputPosition.x; var y=inputPosition.y+25; frame.style.left=x+"px"; frame.style.top=y+"px"; this.frame=frame; var title=createNode(null,'div',frame,'title'); var ta=createNode(null,'div',title,'left'); var tb=createNode(null,'div',title,'left'); var tc=createNode(null,'div',title,'right'); var td=createNode(null,'div',title,'right'); ta.innerHTML='<<'; tb.innerHTML='<'; tc.innerHTML='>>'; td.innerHTML='>'; title.innerHTML+=String(fyear)+"年"+String(fmonth+1)+"月"; var ca=createNode(null,'div',frame,'content'); this.nodes.area=ca; this.changeMonth(fyear,fmonth); var tsel=createNode(null,'div',frame,'time_select'); var t1=createNode(null,'span',tsel); t1.innerHTML="时间:"; var t2=createNode(null,'span',tsel); var t3=createNode(null,'select',t2); var j; for (var i=-1;i<23;i++){ j=i+1; if (j<10) j="0"+String(j); else j=String(j); t3.options[t3.length]=new Option(j,i+1); } var t5=createNode(null,'span',t2); t5.innerHTML=':'; var t4=createNode(null,'select',t2); for (var i=0;i<60;i++){ j=i; if (j<10) j="0"+String(j); else j=String(j); t4.options[t4.length]=new Option(j,i); } var buts=createNode(null,'div',frame,'time_select'); buts.innerHTML='<input onclick="inputCalendar.puts()" type="button" value="确 定" /> <input onclick="inputCalendar.close()" type="button" value="取 消" />'; this.inputNode=inputNode; }, changeMonth:function(year,month){ var da=new Date(); var fyear=da.getFullYear(); var fmonth=da.getMonth(); //获得这个月的1日的星期数 var ca=this.nodes.area; var first=new Date(year,month,1); var firstDay=first.getDay(); var dayN=new Date(first-firstDay*86400000); //第一个日期 //输出星期栏 var xqs=new Array('日','一','二','三','四','五','六'); var ht='<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr class="xql">'; for (var i=0;i<7;i++) ht+='<td>'+xqs[i]+'</td>'; ht+='</tr>'; //输出各日期 var j,k,m,cla; var n=0; for (i=0;i<6;i++){ ht+='<tr>'; for (j=0;j<7;j++,n--){ cla=new Array(); m=new Date(dayN-n*86400000); ht+='<td onmouseover="inputCalendar.mouse.select(this)" onmouseout="inputCalendar.mouse.out(this)" onclick="inputCalendar.mouse.click(this,'+String(m.getFullYear())+','+String(m.getMonth()+1)+','+String(m.getDate())+')"'; if (m.getFullYear()==fyear && m.getMonth()==fmonth && m.getDate()==da.getDate()) cla[0]="istoday"; if (!(m.getFullYear()==year && m.getMonth()==month)) cla[cla.length]="noMonth"; cla=Base.Array.unsplit(' ',cla,true); if (cla!="") ht+=' class="'+cla+'"'; ht+='>'+String(m.getDate()); ht+='</td>'; } ht+='</tr>'; } ca.innerHTML=ht+'</table>'; }, close:function(getFocus){ document.body.removeChild(this.frame); if (getFocus!==false) this.inputNode.focus(); this.inputNode=null; this.opened=false; }, puts:function(){ }, mouse:{ selectedNode:null, selectedDate:null, select:function(that){ var istoday=classhave(that.className,'istoday'); var noMonth=classhave(that.className,'noMonth'); var selected=classhave(that.className,'selected'); var omo="onmouseover"; if (istoday) omo+=" istoday"; if (noMonth) omo+=" noMonth"; if (selected) omo+=" selected"; that.className=omo; }, out:function(that){ var istoday=classhave(that.className,'istoday'); var noMonth=classhave(that.className,'noMonth'); var selected=classhave(that.className,'selected'); var omo=""; if (istoday) omo="istoday"; if (noMonth) omo=classpast(omo,"noMonth"); if (selected) omo=classpast(omo,"selected"); that.className=omo; }, click:function(that,y,m,d){ if (this.selectedNode==that) return false; that.className=classpast(that.className,"selected"); if (this.selectedNode!=null){ var istoday=classhave(this.selectedNode.className,'istoday'); var noMonth=classhave(this.selectedNode.className,'noMonth'); var omo=""; if (istoday) omo="istoday"; if (noMonth) omo=classpast(omo,"noMonth"); this.selectedNode.className=omo; } this.selectedNode=that; this.selectedDate=new Date(y,m-1,d); } } };
|