cal.js
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:11k
- //日期参照
- function selectDate(txtValue)
- {
- var intLeft=0
- var intTop=0
- if(event.screenX+180 > document.body.clientWidth)
- intLeft=event.screenX+document.body.scrollLeft-180;
- else
- intLeft=event.screenX+document.body.scrollLeft;
- if(event.screenY+190 > document.body.clientHeight)
- intTop=event.screenY+document.body.scrollTop-190;
- else
- intTop=event.screenY+document.body.scrollTop;
-
- //alert(intLeft+";"+intTop)
- var k = window.showModalDialog('dateselector.htm','','dialogwidth=180px; dialogheight=190px;dialogleft='+intLeft+'px;dialogtop='+intTop+'px;status=no');
- if(k!=null){
- //if (txtValue.value!="")
- // txtValue.value =txtValue.value +"n"+k
- //else
- txtValue.value=k;
- }
- txtValue.blur();
- }
- function show(year,month)
- {
- //alert(this.startdate);
- if(this.startday==0)
- {
- for(i=0;i<7;i++)
- {
- calTitle[i].innerHTML="<font size=" + this.titlesize + "px>"+this.tit[i]+"</b></font>";
- }
- }
- else
- {
- calTitle[0].innerHTML="<font size=" + this.titlesize + "px>"+this.tit[6]+"</b></font>";
- for(i=1;i<7;i++)
- {
- calTitle[i].innerHTML="<font size=" + this.titlesize + "px>"+this.tit[i-1]+"</b></font>";
- }
- }
- var da1 = new Date(year,month-1,1);
- var start,totalDay=31;
- if(month==4 || month==6 || month==9 || month==11)
- totalDay=30;
- else if(month==2)
- {
- if(year%400==0 || (year%4==0 && year%25!=0))
- totalDay=29;
- else
- totalDay=28;
- }
- if(this.startday==0)
- {
- start=da1.getDay()-1;
- if(start==-1)start=6;
- }else
- {
- start=da1.getDay();
- }
- for(i=0;i<start;i++)
- calDiv1[i].innerText="";
- for(i=0;i<totalDay;i++,start=start+1)
- {
- calDiv1[start].innerText=i+1;
- if(start==34)start=-1;
- }
- if(start>20)
- {
- for(i=start;i<35;i++)
- {
- calDiv1[i].innerText="";
- }
- }
- }
- function Calendar(language)
- {
- this.language=language;
- this.bgc = "#A3B2D3";
- //"aquamarine";
- this.tit=new Array();
- this.mon=new Array();
- this.cellWidth="80px";
- this.cellHeight="20px";
- this.startday=0;
- this.titlesize=4
- this.contentsize=24
- this.bgcolor="#A3B2D3";
- if(language==0)
- {
- this.tit[this.tit.length]="一";
- this.tit[this.tit.length]="二";
- this.tit[this.tit.length]="三";
- this.tit[this.tit.length]="四";
- this.tit[this.tit.length]="五";
- this.tit[this.tit.length]="六";
- this.tit[this.tit.length]="日";
- // this.tit[this.tit.length]="星期一";
- // this.tit[this.tit.length]="星期二";
- // this.tit[this.tit.length]="星期三";
- // this.tit[this.tit.length]="星期四";
- // this.tit[this.tit.length]="星期五";
- // this.tit[this.tit.length]="星期六";
- // this.tit[this.tit.length]="星期日";
- this.mon[this.mon.length]="一月";
- this.mon[this.mon.length]="二月";
- this.mon[this.mon.length]="三月";
- this.mon[this.mon.length]="四月";
- this.mon[this.mon.length]="五月";
- this.mon[this.mon.length]="六月";
- this.mon[this.mon.length]="七月";
- this.mon[this.mon.length]="八月";
- this.mon[this.mon.length]="九月";
- this.mon[this.mon.length]="十月";
- this.mon[this.mon.length]="十一月";
- this.mon[this.mon.length]="十二月";
- }else if(language==1)
- {
- this.tit[this.tit.length]="Mon";
- this.tit[this.tit.length]="Tues";
- this.tit[this.tit.length]="Wed";
- this.tit[this.tit.length]="Thur";
- this.tit[this.tit.length]="Fri";
- this.tit[this.tit.length]="Sat";
- this.tit[this.tit.length]="Sun";
- this.mon[this.mon.length]="January";
- this.mon[this.mon.length]="February";
- this.mon[this.mon.length]="March";
- this.mon[this.mon.length]="April";
- this.mon[this.mon.length]="May";
- this.mon[this.mon.length]="June";
- this.mon[this.mon.length]="July";
- this.mon[this.mon.length]="August";
- this.mon[this.mon.length]="September";
- this.mon[this.mon.length]="October";
- this.mon[this.mon.length]="November";
- this.mon[this.mon.length]="December";
- }else if(language==2)
- {
- this.tit[this.tit.length]="Monday";
- this.tit[this.tit.length]="Tuesday";
- this.tit[this.tit.length]="Wednesday";
- this.tit[this.tit.length]="Thurday";
- this.tit[this.tit.length]="Friday";
- this.tit[this.tit.length]="Saturday";
- this.tit[this.tit.length]="Sunday";
- this.mon[this.mon.length]="January";
- this.mon[this.mon.length]="February";
- this.mon[this.mon.length]="March";
- this.mon[this.mon.length]="April";
- this.mon[this.mon.length]="May";
- this.mon[this.mon.length]="June";
- this.mon[this.mon.length]="July";
- this.mon[this.mon.length]="August";
- this.mon[this.mon.length]="September";
- this.mon[this.mon.length]="October";
- this.mon[this.mon.length]="November";
- this.mon[this.mon.length]="December";
- }
- this.create=createTa;
- this.showDate=show;
- this.setDetail=calSetDetail;
- this.setColor=calSetColor;
- this.setbgColor=calSetbgColor;
- this.setLanguage=calSetLan;
- this.dateClick="dateClick";
- }
- function calSetLan(language)
- {
- this.language=language;
- this.tit.length=0;
- this.mon.length=0;
- if(language==0)
- {
- this.tit[this.tit.length]="一";
- this.tit[this.tit.length]="二";
- this.tit[this.tit.length]="三";
- this.tit[this.tit.length]="四";
- this.tit[this.tit.length]="五";
- this.tit[this.tit.length]="六";
- this.tit[this.tit.length]="日";
- // this.tit[this.tit.length]="星期一";
- // this.tit[this.tit.length]="星期二";
- // this.tit[this.tit.length]="星期三";
- // this.tit[this.tit.length]="星期四";
- // this.tit[this.tit.length]="星期五";
- // this.tit[this.tit.length]="星期六";
- // this.tit[this.tit.length]="星期日";
- this.mon[this.mon.length]="一月";
- this.mon[this.mon.length]="二月";
- this.mon[this.mon.length]="三月";
- this.mon[this.mon.length]="四月";
- this.mon[this.mon.length]="五月";
- this.mon[this.mon.length]="六月";
- this.mon[this.mon.length]="七月";
- this.mon[this.mon.length]="八月";
- this.mon[this.mon.length]="九月";
- this.mon[this.mon.length]="十月";
- this.mon[this.mon.length]="十一月";
- this.mon[this.mon.length]="十二月";
- }else if(language==1)
- {
- this.tit[this.tit.length]="Mon";
- this.tit[this.tit.length]="Tues";
- this.tit[this.tit.length]="Wed";
- this.tit[this.tit.length]="Thur";
- this.tit[this.tit.length]="Fri";
- this.tit[this.tit.length]="Sat";
- this.tit[this.tit.length]="Sun";
- this.mon[this.mon.length]="January";
- this.mon[this.mon.length]="February";
- this.mon[this.mon.length]="March";
- this.mon[this.mon.length]="April";
- this.mon[this.mon.length]="May";
- this.mon[this.mon.length]="June";
- this.mon[this.mon.length]="July";
- this.mon[this.mon.length]="August";
- this.mon[this.mon.length]="September";
- this.mon[this.mon.length]="October";
- this.mon[this.mon.length]="November";
- this.mon[this.mon.length]="December";
- }else if(language==2)
- {
- this.tit[this.tit.length]="Monday";
- this.tit[this.tit.length]="Tuesday";
- this.tit[this.tit.length]="Wednesday";
- this.tit[this.tit.length]="Thurday";
- this.tit[this.tit.length]="Friday";
- this.tit[this.tit.length]="Saturday";
- this.tit[this.tit.length]="Sunday";
- this.mon[this.mon.length]="January";
- this.mon[this.mon.length]="February";
- this.mon[this.mon.length]="March";
- this.mon[this.mon.length]="April";
- this.mon[this.mon.length]="May";
- this.mon[this.mon.length]="June";
- this.mon[this.mon.length]="July";
- this.mon[this.mon.length]="August";
- this.mon[this.mon.length]="September";
- this.mon[this.mon.length]="October";
- this.mon[this.mon.length]="November";
- this.mon[this.mon.length]="December";
- }
- }
- function calSetbgColor(calDay1,color)
- {
- var day1 = new Date(calDay1.getYear(),calDay1.getMonth(),1);
- var tmp;
-
- //if(this.startday==0)
- //{
- tmp=day1.getDay();
- if(tmp==0)tmp=7;
- //else
- //tmp-=1;
- //}
- //else
- //{
- // tmp=day1.getDay();
- //}
-
- tmp=tmp+calDay1.getDate()-2;
- if(tmp>34)tmp-=35;
- calDiv1[tmp].style.backgroundColor=color;
-
- }
- function calSetColor(calDay1,color)
- {
- var day1 = new Date(calDay1.getYear(),calDay1.getMonth(),1);
- var tmp;
- if(this.startday==0)
- {
- tmp=day1.getDay();
- if(tmp==0)tmp=7;
- else
- tmp-=1;
- }
- else
- {
- tmp=day1.getDay();
- }
- tmp=tmp+calDay1.getDate()-1;
- if(tmp>34)tmp-=35;
- calDiv1[tmp].style.color=color;
- }
- function calSetDetail(detail)
- {
- calDetail.innerText=detail;
- }
- function createTa()
- {
- document.write("<div id=calendar align=right>");
- //document.write("<INPUT type=button value=▼ id=caldown onclick=caldown()>");
- document.write("<font onclick="yeardown()" style="cursor:hand"><< </font><input type=text value=" + new Date().getYear() + " id=calyear style="background-color:" + this.bgcolor + ";BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px; width:40px" disabled></input><font onclick="yearup()" style="cursor:hand">>></font>");
- document.write("<select style="background-color:" + this.bgcolor + "" id=calmonth onchange=bbb.showDate(calyear.value,calmonth.value)>");
- for(i=1;i<13;i++)
- {
- document.write("<option value=" + i + ">" + i + "</option>");
- }
- document.write("</select>");
- //document.write("<input type=text value=12 size=2 id=calmonth></inpub>");
- //document.write("<INPUT type=button value=▲ id=calup onclick=calup()>");
- calmonth.value=new Date().getMonth()+1;
- document.write("</div>");
- //document.write("<hr>");
- document.write("<table align=center>");
- document.write("<tr>");
- if(this.startday==0)
- {
- for(i=0;i<this.tit.length;i++)
- {
- // document.write("<td nowrap align=center><div id=calTitle></td></td>");
- document.write("<td nowrap align=center><div id=calTitle><font size=" + this.titlesize + "px><b>" + this.tit[i] + "</b></font></td></td>");
- }
- }else
- {
- //document.write("<td nowrap><div id=calTitle></div></td>");
- document.write("<td nowrap><div id=calTitle><font size=" + this.titlesize + "px><b>" + this.tit[6] + "</b></font></div></td>");
- for(i=0;i<this.tit.length-1;i++)
- {
- // document.write("<td nowrap align=center><div id=calTitle></div></td>");
- Document.write("<td nowrap align=center><div id=calTitle><font size=" + this.titlesize + "px><b>" + this.tit[i] + "</b></font></div></td>");
- }
- }
- document.write("</tr>");
- document.write("<tr><td colspan=7><hr size=1></td></tr>");
- for(i=0;i<5;i++)
- {
- document.write("<tr>");
- for(j=0;j<7;j++)
- {
- if(j==6 || (j==5 && this.startday==0) || (j==0 && this.startday!=0))
- document.write("<td align=center><div face="Arial Black" id="calDiv1" style="font-size:" + this.contentsize + "px;color:red;BACKGROUND-COLOR:" + this.bgc + ";cursor:hand" onclick="" + this.dateClick +"(calyear.value+(calmonth.value<10?'0':'')+calmonth.value+(this.innerText<10?'0':'')+this.innerText)"></div></td>");
- else
- document.write("<td align=center><div face="Arial Black" id="calDiv1" style="cursor:hand;font-size:" + this.contentsize + "px;color:blue" onclick="" + this.dateClick + "(calyear.value+(calmonth.value<10?'0':'')+calmonth.value+(this.innerText<10?'0':'')+this.innerText)"></div></td>");
- }
- document.write("</tr>");
- //document.write("<tr><td colspan=7><hr size=1></td></tr>");
- }
- document.write("<tr><td colspan=7 align=right><div id="calDetail"></div></td></tr>")
- document.write("</table>");
- //document.write("<hr>");
- }
- function dateClick(date)
- {
- alert(date);
- }
- function yearup()
- {
- calyear.value=calyear.value-1+2;
- bbb.showDate(calyear.value,calmonth.value);
- }
- function yeardown()
- {
- calyear.value=calyear.value-1;
- bbb.showDate(calyear.value,calmonth.value);
- }
- function calup()
- {
- calmonth.value=calmonth.value-1+2;
- if(calmonth.value==13)
- {
- calmonth.value=1;
- calyear.value=calyear.value-1+2;
- }
- bbb.showDate(calyear.value,calmonth.value);
- }
- function caldown()
- {
- calmonth.value=calmonth.value-1;
- if(calmonth.value==0)
- {
- calmonth.value=12;
- calyear.value=calyear.value-1;
- }
- bbb.showDate(calyear.value,calmonth.value);
- }