- 论坛徽章:
- 0
|
再发一个,再次恳求不要删啊~~
#calendar_main, #calendar_header, #calendar_week #calendar_main_date{
width:280px;
}
#calendar_main {
border:2px solid black;
height:250px;
background-color:#FFFFCC;
}
#calendar_header {
height:25px;
background-color:gray;
}
#calendar_pre_day, #calendar_nex_day, #calendar_select_month, #calendar_select_year{
border:1px solid black;
}
#calendar_pre_day, #calendar_nex_day
{
width:20px;
height:20px;
margin-left:13px;
margin-top:2px;
}
#calendar_week
{
background-color:white;
}
.calendar_week_table{
border-top:1px solid black;
border-bottom:1px solid black;
}
.calendar_week_table td, .calendar_main_date_table td{
width:40px;
font-size:14px;
text-align:center;
font-weight:bold;
}
#calendar_main_date{
}
.calendar_main_date_table td{
}
.calendar_content_block{
border:1px solid #FFCCCC;
}
.calendar_content_block_nom{
border:1px solid #FFCCCC;
color:#FF9966;
} |
function Calendar() {
this.cur_date = new Date();
this.con_date = new Date();
this.con_date.setMonth(this.cur_date.getMonth()-1);
this.con_date.setDate(0);
this.last_date = this.con_date.getDate();
this.con_date.setDate(1);
this.first_day = this.con_date.getDay();
this.time_for_show_str = "";
/* 一些需要配置的东西 */
this.element_for_timeshow = "Calendar_time_show";//显示时间的地方
this.element_for_mainshow = "calendar_main_date";
//document.write("sdf");
}
Calendar.prototype.showTime = function() {
window.obj = this;
var cr_date = new Date();
var time_for_show_str = cr_date.getHours() + ":" + cr_date.getMinutes() + ":" + cr_date.getSeconds() + "<br />";
document.getElementById(this.element_for_timeshow).innerHTML = time_for_show_str;
var timeID = setTimeout("obj.showTime();",1000);
}
/*
返回本月第一天是星期几
*/
Calendar.prototype.getFirstDay = function() {
return this.first_day;
}
Calendar.prototype.getLastDate = function() {
return this.last_date;
}
/*
写入中间主要的数据
*/
Calendar.prototype.writeMainData = function() {
//document.write("sdf");
var pre_month_date = new Date();
pre_month_date.setMonth(this.con_date.getMonth());
pre_month_date.setDate(0);//设定为最后一天
var pre_month_dates = pre_month_date.getDate();
var pre_month_last_day = pre_month_date.getDay();
var w_block = pre_month_dates - pre_month_last_day;
if(pre_month_last_day == 6)
{
w_block = 1;
}
var have_write_con_month = false;
var str_for_write = "";
for(var r = 0; r < 6; r++)
{
str_for_write += "<table class=\"calendar_main_date_table\"\n<tr>\n";
for(var c = 0; c < 7; c++)
{
if(pre_month_last_day >= 0 && pre_month_last_day != 6)
{
//document.write(pre_month_last_day);
str_for_write += "<td><div class=\"calendar_content_block_nom\">" + w_block + "</div></td>\n";
if(pre_month_last_day == 0)
{
w_block = 1;
pre_month_last_day--;
}
else
{
pre_month_last_day--;
w_block++;
}
continue;
}
else if (!have_write_con_month)
{
str_for_write += "<td><div class=\"calendar_content_block\">" + w_block + "</div></td>\n";
if(w_block == this.last_date)
{
w_block = 1;
have_write_con_month = true;
}
else{
w_block++;
}
continue;
}
str_for_write += "<td><div class=\"calendar_content_block_nom\">" + w_block + "</div></td>\n";
w_block++;
}
str_for_write += "</tr>\n</table>\n";
}//end for
document.getElementById(this.element_for_mainshow ).innerHTML = str_for_write;
} |
|
|