1 var calendar={
2 STR:function(){with(this.data)return ""+Y+"年,"+M+"月,"+D+"号,星期"+WN[W];},
3 V:function(o,spli,sx){with(this)return o[sx]=""+data.Y+spli+data.M+spli+data.D},
4 T:function(){with(this)return data.TABLE},
5 dnY:function(){with(this){calendarChange(data.Y+1,data.M-1,data.D)}},
6 dnM:function(){with(this){calendarChange(data.Y,data.M,data.D)}},
7 upY:function(){with(this){calendarChange(data.Y-1,data.M-1,data.D)}},
8 upM:function(){with(this){calendarChange(data.Y,data.M-2,data.D)}},
9 day:function(o){with(this){data.D=o;calendarChange(data.Y,data.M-1,data.D)}},
10 data:{Y:null,M:null,D:null,W:null,H:null,U:null,YMD:null,YMD_C:"hot",ARR:null,TABLE:null,MN:null,WN:null,SELECT:null,TADAY:new Date(),TADAY_C:"taday",ROWLEN:7,VALUE:null},
11
12 creatTable:function(){with(this){
13 var table="<table height=100% width=100%><tr>"
14 for(var i=0;i<data.ROWLEN;i++){var t=data.WN[i]||" ";table+="<th>"+t+"</th>";}
15 for(var i in data.ARR){var showText=data.ARR[i]||" ",br=i%data.ROWLEN,title,css;
16 if(!br){table+="</tr><tr>"};
17 data.ARR[i]?title=data.Y+"-"+data.M+"-"+showText:title="";
18 String(data.TADAY.getDate())==String(data.ARR[i])?
19 (data.YMD.getFullYear()==data.TADAY.getFullYear()&&data.YMD.getMonth()==data.TADAY.getMonth()&&data.YMD.getDate()==data.TADAY.getDate())?
20 css=data.TADAY_C+" "+data.YMD_C:css=data.YMD_C:css="";
21 table+="<td title='"+title+"' class="+css+">"+showText+"</td>";
22 }table+="</tr></table>"
23 data.TABLE=table;return table;
24 }},
25 calendarStarArr:function(userY,userM,userD){with(this){
26 var Arr=[];
27 var now = new Date(userY,userM,userD);
28 var LastDay = now.getLastDay();
29 var FirstDayofWeek = now.FirstDayofWeek();
30 data.YMD=now;data.Y=now.getFullYear();
31 data.M=now.getMonth()+1;data.D=now.getDate();data.W=now.getDay();
32 while(Arr.length!=FirstDayofWeek){Arr.push(false)}
33 for(var i=0;i<LastDay;i++){Arr.push(i+1)}
34 while(Arr.length%data.ROWLEN!=0){Arr.push(false)}
35 data.ARR=Arr;return Arr;
36 }},
37
38 calendarChange:function(userY,userM,userD){with(this){
39 calendarStarArr(userY,userM,userD);creatTable()
40 }},
41 calendarStar:function(userY,userM,userD){with(this){
42 data.MN = ["零","一","二","三","四","五","六","七","八","九","十","十一","十二"];
43 data.WN = ["日","一","二","三","四","五","六"];
44 calendarChange(userY,userM,userD);
45 }},
46 init:function(){with(this){
47 Date.prototype.getLastDay=function(){return(new Date(this.getFullYear(),this.getMonth()+1,0).getDate())}
48 Date.prototype.FirstDayofWeek=function(){return(new Date(this.getFullYear(),this.getMonth(),1).getDay())}
49 calendarStar(new Date().getFullYear(),new Date().getMonth(),new Date().getDate())
50 }}
51 }