';
var index=1;
// 判断每月の第一天在哪个位置
var style='';
if(this.weekstart
{
tablestr ='
';
for (var i = 0; i tablestr ='
';
};
for (var i = 0; i
style=this.day==(i 1)?"background-Color:green;":"";
インデックス ;
tablestr ='
' (i 1) '
';
};
tablestr ='
';
}
///残り日数に対応する位置
//整数行を決定し、対応する位置に対応付けます
Var leftays = this.monthdays- (7-This.weekstart);
var row=Math.floor(remaindays%7==0?remaindays/7:((remaindays/7) 1)) ;
var count=Math.floor(remaindays/7);
for (var i = 0; i
tablestr ='
';
for (var k = 0; k
style=this.day==(index k)?"background-Color:green;":"";
tablestr ='
';
tablestr =index k;
tablestr ='
';
};
tablestr ='
';
インデックス =7;
};
//最後の残り日数(埋められない曜日)に対応するポジション
var maincols=this.monthdays-(index-1);
tablestr ='
';
for (var i = 0; i
style=this.day==index?"background-Color:green;":"";
tablestr ='
';
tablestr =index;
tablestr ='
';
インデックス ;
};
tablestr ='
';
tablestr ='
'; return tablestr;
}、
Render:function(){
var calenderDiv=document.createElement('div');
calenderDiv.style.border=this.options.border;
calenderDiv.style.width=this.options.width;
calenderDiv.style.height=this.options.height;
calenderDiv.style.cursor='ポインター';
calenderDiv.style.backgroundColor=this.options.backgroundColor;
// calenderDiv.style.color=this.options.fontColor;
calenderDiv.style.color='red' ;
calenderDiv.onclick=function(e){
var evt=e||window.event;
var target=evt.srcElement||evt.target;
if(target&&target.getAttribute('val'))
{
alert(target.getAttribute('val'));
}
}
var tablestr=this.View();
this.tablestr=tablestr;
calenderDiv.innerHTML=tablestr;
var div=document.createElement('div');
div.style.width='auto';
div.style.height='auto';
div.appendChild(calenderDiv);
///翻訳div
var pagerDiv=document.createElement('div');
pagerDiv.style.width='auto';
pagerDiv.style.height='auto';
var that=this;
/// 重新設置パラメータ
var resetPara=function(年,月,日){
that.date=new 日付(年,月,日);
that.year=that.date.getFull Year();
that.month=that.date.getMonth() 1;
that.day=that.date.getDate();
that.week=that.date.getDay();
that.weekstart=that.getWeekDay(that.year, that.month-1, 1);
that.monthdays= that.getMonthDays(that.year,that.month);
}
//上一页
var preBtn=document.createElement('input'); preBtn.type='ボタン';
preBtn.value='
preBtn.onclick=function(){
that.containerDiv.removeChild(div);
リセットPara(その年,その月-2,その日);
that.Render();
}
//次の一页
var nextBtn=document.createElement('input');
nextBtn.type='ボタン';
nextBtn.value='>';
nextBtn.onclick=function(){
that.containerDiv.removeChild(div);
リセットPara(その年,その月,その日);
that.Render();
}
pagerDiv.appendChild(preBtn);
pagerDiv.appendChild(nextBtn);
div.appendChild(pagerDiv);
var dropDiv=document.createElement('div');
var dropdivstr='';
//选择年份
dropdivstr ='';
//选择月份
dropdivstr ='';
dropDiv.innerHTML=dropdivstr; div.appendChild(dropDiv);
that.containerDiv.appendChild(div);
///绑定选择年份和月份的事件
var ddlChange=function(){
var ddlYear=document.getElementById('ddlYear');
var ddlMonth=document.getElementById('ddlMonth');
var yearIndex=ddlYear.selectedIndex;
var year=ddlYear.options[yearIndex].value;
var monthIndex=ddlMonth.selectedIndex;
var month=ddlMonth.options[monthIndex].value;
that.containerDiv.removeChild(div);
resetPara(year,month-1,that.day);
that.Render();
}
ddlYear.onchange=function(){
ddlChange();
}
ddlMonth.onchange=function(){
ddlChange();
}
}
}
var calender=new Calender('dvTest',{
border:'1px solid green',
width:'400px',
height:'200px',
backgroundColor:''
}
);
calender.Render();
}