LeftCalendar.js
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:5k
- var gdCtrl = new Object();
- var goSelectTag = new Array();
- var gcGray = "#808080";
- var gcToggle = "#FFFF00";
- var gcred = "#FF0000";
- var gcBG = "#F8F9EE";
- var gcGreen = "#00FF00"
- var gdCurDate = new Date();
- var giYear = gdCurDate.getFullYear();
- var giMonth = gdCurDate.getMonth()+1;
- var giDay = gdCurDate.getDate();
- function fSetDate(iYear, iMonth, iDay){
- gdCtrl.value = iYear+"-"+iMonth+"-"+iDay;
- }
- function fSetSelected(aCell){
- var iOffset = 0;
- var iYear =parseInt(tbSelYear.value);//动态改变文本框的年
- var iMonth = parseInt(tbSelMonth.value);//动态改变文本框的月
- aCell.bgColor = gcBG;
- with (aCell.children["cellText"]){
- var iDay = parseInt(innerText);
- if (color==gcGray)
- iOffset = (Victor<10)?-1:1;
- iMonth += iOffset;
- if (iMonth<1) {
- iYear--;
- iMonth = 12;
- }else if (iMonth>12){
- iYear++;
- iMonth = 1;
- }
- }
- this.top.frames[2].location = "Schedule/SchedByDay.aspx?date="+iYear+"-"+iMonth+"-"+iDay;
- }
- function fBuildCal(iYear, iMonth) {
- var aMonth=new Array();
- for(i=1;i<7;i++)
- aMonth[i]=new Array(i);
- var dCalDate=new Date(iYear, iMonth-1, 1);
- var iDayOfFirst=dCalDate.getDay();
- var iDaysInMonth=new Date(iYear, iMonth, 0).getDate();
- var iOffsetLast=new Date(iYear, iMonth-1, 0).getDate()-iDayOfFirst+1;
- var iDate = 1;
- var iNext = 1;
- for (d = 0; d < 7; d++)
- aMonth[1][d] = (d<iDayOfFirst)?-(iOffsetLast+d):iDate++;
- for (w = 2; w < 7; w++)
- for (d = 0; d < 7; d++)
- aMonth[w][d] = (iDate<=iDaysInMonth)?iDate++:-(iNext++);
- return aMonth;
- }
- function fDrawCal(iYear, iMonth, iCellHeight, iDateTextSize) {
- var WeekDay = new Array("日","一","二","三","四","五","六");
- var styleTD = " bgcolor='"+gcBG+"' valign='middle' align='center' height='"+iCellHeight+"' style='font-size:9pt "+iDateTextSize+" 宋体;";
- with (document) {
- write("<tr>");
- for(i=0; i<7; i++)
- write("<td "+styleTD+"color:purple'>" + WeekDay[i] + "</td>");
- write("</tr>");
- for (w = 1; w < 7; w++) {
- write("<tr>");
- for (d = 0; d < 7; d++) {
- write("<td id=calCell "+styleTD+"cursor:hand;' onMouseOver='this.bgColor=gcToggle' onMouseOut='this.bgColor=gcBG' onclick='fSetSelected(this)'>");
- write("<font id=cellText Victor='Liming Weng'> </font>");
- write("</td>")
- }
- write("</tr>");
- }
- }
- }
- function fUpdateCal(iYear, iMonth) {
- myMonth = fBuildCal(iYear, iMonth);
- var i = 0;
- for (w = 0; w < 6; w++)
- for (d = 0; d < 7; d++)
- with (cellText[(7*w)+d]) {
- Victor = i++;
- if (myMonth[w+1][d]<0) {
- color = gcGray;
- innerText = -myMonth[w+1][d];
- }else{
- if (myMonth[w+1][d] == giDay && iYear == giYear && iMonth == giMonth)
- {
- //color = ((d==0)||(d==6))?"blue":"black";
- color = "red";
- innerText = myMonth[w+1][d];
- }
- else
- {
- color = ((d==0)||(d==6))?"blue":"black";
- innerText = myMonth[w+1][d];
- }
- }
- }
- }
- //该函数动态改变年后引起表格中的变化
- function fSetYearMon(iYear, iMon){
- tbSelMonth.options[iMon-1].selected = true;
- for (i = 0; i < tbSelYear.length; i++)
- if (tbSelYear.options[i].value == iYear)
- tbSelYear.options[i].selected = true;
- fUpdateCal(iYear, iMon);//将改变厚的值传给fUpdateCal()以便以在表格中显示变化
- }
- function fPrevMonth(){
- var iMon = tbSelMonth.value;
- var iYear = tbSelYear.value;
- if (--iMon<1) {
- iMon = 12;
- iYear--;
- }
- fSetYearMon(iYear, iMon);
- }
- function fNextMonth(){
- var iMon = tbSelMonth.value;
- var iYear = tbSelYear.value;
- if (++iMon>12) {
- iMon = 1;
- iYear++;
- }
- fSetYearMon(iYear, iMon);
- }
- function ShowCalendar()
- {
- var gMonths = new Array(" 1月"," 2月"," 3月"," 4月"," 5月"," 6月"," 7月"," 8月"," 9月","10月","11月","12月");
- with (document) {
- write("<table border='0' bgcolor='#F8F9EE'>");
- write("<TR>");
- write("<td valign='middle' align='center'><input type='button' name='PrevMonth' value='<' style='height:18;width:18' onClick='fPrevMonth()'>");
- write(" <SELECT name='tbSelYear' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' style='font-color:#000080;width:50;border:1 solid #99CCFF; font-size:9pt; background-color:#F8F9EE' Victor='Won'>");
- for(i=1900;i<=2100;i++)
- write("<OPTION value='"+i+"'>"+i+"</OPTION>");
- write("</SELECT>");
- write("<select name='tbSelMonth' onChange='fUpdateCal(tbSelYear.value, tbSelMonth.value)' style='font-color:#000080;width:50;border:0 solid #99CCFF; font-size:9pt; background-color:#F8F9EE' Victor='Won'>");
- for (i=0; i<12; i++)
- write("<option value='"+(i+1)+"'>"+gMonths[i]+"</option>");
- write("</SELECT>");
- write(" <input type='button' name='PrevMonth' value='>' style='height:18;width:18' onclick='fNextMonth()'>");
- write("</td>");
- write("</TR><TR>");
- write("<td align='center'>");
- write("<table border='0' cellspacing='0' cellpadding='0' width='100%'><tr><td><table border='0' cellspacing='0' width='100%' cellpadding='0'>");
- fDrawCal(giYear, giMonth, 12, 12);
- write("</table></td></tr></table>");
- write("</td></TR></TABLE>");
- fSetYearMon(giYear, giMonth)
- }
- }