⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calendar.js

📁 这是一个关于日历的js
💻 JS
📖 第 1 页 / 共 2 页
字号:
//==================================================== 2?êyéè?¨2?·? =======================================================
var bMoveable=true;		//éè??è?àúê?·??éò?í??ˉ
var regionTree=false;
var workTypeTree=false;
var calendar=false;
var _VersionInfo="Version:2.0
2.0×÷??:walkingpoison
1.0×÷??: F.R.Huang(meizz)
MAIL: meizz@hzcnc.com"	//°?±?D??¢

//==================================================== WEB ò3????ê?2?·? =====================================================
var strFrame;		//′?·?è?àú2?μ?HTML′ú??
document.writeln('<iframe id=meizzDateLayer Author=wayx frameborder=0 style="position: absolute; width: 144; height: 211; z-index: 9998; display: none"></iframe>');
strFrame='<style>';
strFrame+='INPUT.button{BORDER-RIGHT: #8FB1F3 1px solid;BORDER-TOP: #8FB1F3 1px solid;BORDER-LEFT: #8FB1F3 1px solid;';
strFrame+='BORDER-BOTTOM: #8FB1F3 1px solid;BACKGROUND-COLOR: #fff8ec;font-family:??ì?;}';
strFrame+='TD{FONT-SIZE: 9pt;font-family:??ì?;}';
strFrame+='</style>';
strFrame+='<scr' + 'ipt>';
strFrame+='var datelayerx,datelayery;	/*′?·?è?àú???tμ?êó±ê????*/';
strFrame+='var bDrag;	/*±ê??ê?·??aê?í??ˉ*/';
strFrame+='function document.onmousemove()	/*?úêó±êò??ˉê??t?D£?è?1??aê?í??ˉè?àú£??òò??ˉè?àú*/';
strFrame+='{if(bDrag && window.event.button==1)';
strFrame+='	{var DateLayer=parent.document.all.meizzDateLayer.style;';
strFrame+='		DateLayer.posLeft += window.event.clientX-datelayerx;/*óéóú??′?ò??ˉò?oóêó±ê?????????′?a3?ê?μ?????£?òò′?D′·¨ó?div?D2?í?*/';
strFrame+='		DateLayer.posTop += window.event.clientY-datelayery;}}';
strFrame+='function DragStart()		/*?aê?è?àúí??ˉ*/';
strFrame+='{var DateLayer=parent.document.all.meizzDateLayer.style;';
strFrame+='	datelayerx=window.event.clientX;';
strFrame+='	datelayery=window.event.clientY;';
strFrame+='	bDrag=true;}';
strFrame+='function DragEnd(){		/*?áê?è?àúí??ˉ*/';
strFrame+='	bDrag=false;}';
strFrame+='</scr' + 'ipt>';
strFrame+='<div style="z-index:9999;position: absolute; left:0; top:0;" onselectstart="return false"><span id=tmpSelectYearLayer Author=wayx style="z-index: 9999;position: absolute;top: 3; left: 19;display: none"></span>';
strFrame+='<span id=tmpSelectMonthLayer Author=wayx style="z-index: 9999;position: absolute;top: 3; left: 78;display: none"></span>';
strFrame+='<table border=1 cellspacing=0 cellpadding=0 width=142 height=160 bordercolor=#8FB1F3 bgcolor=#8FB1F3 Author="wayx">';
strFrame+='  <tr Author="wayx"><td width=142 height=23 Author="wayx" bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=140 Author="wayx" height=23>';
strFrame+='      <tr align=center Author="wayx"><td width=16 align=center bgcolor=#8FB1F3 style="font-size:12px;cursor: hand;color: #ffffff" ';
strFrame+='        onclick="parent.meizzPrevM()" title="?ò?°·- 1 ??" Author=meizz><b Author=meizz>&lt;</b>';
strFrame+='        </td><td width=60 align=center style="font-size:12px;cursor:default" Author=meizz ';
strFrame+='onmouseover="style.backgroundColor=\'#FFD700\'" onmouseout="style.backgroundColor=\'white\'" ';
strFrame+='onclick="parent.tmpSelectYearInnerHTML(this.innerText.substring(0,4))" title="μ??÷?aà??????ê·Y"><span Author=meizz id=meizzYearHead></span></td>';
strFrame+='<td width=48 align=center style="font-size:12px;cursor:default" Author=meizz onmouseover="style.backgroundColor=\'#FFD700\'" ';
strFrame+=' onmouseout="style.backgroundColor=\'white\'" onclick="parent.tmpSelectMonthInnerHTML(this.innerText.length==3?this.innerText.substring(0,1):this.innerText.substring(0,2))"';
strFrame+='        title="μ??÷?aà???????·Y"><span id=meizzMonthHead Author=meizz></span></td>';
strFrame+='        <td width=16 bgcolor=#8FB1F3 align=center style="font-size:12px;cursor: hand;color: #ffffff" ';
strFrame+='         onclick="parent.meizzNextM()" title="?òoó·- 1 ??" Author=meizz><b Author=meizz>&gt;</b></td></tr>';
strFrame+='    </table></td></tr>';
strFrame+='  <tr Author="wayx"><td width=142 height=18 Author="wayx">';
strFrame+='<table border=1 cellspacing=0 cellpadding=0 bgcolor=#8FB1F3 ' + (bMoveable? 'onmousedown="DragStart()" onmouseup="DragEnd()"':'');
strFrame+=' BORDERCOLORLIGHT=#8FB1F3 BORDERCOLORDARK=#FFFFFF width=140 height=20 Author="wayx" style="cursor:' + (bMoveable ? 'move':'default') + '">';
strFrame+='<tr Author="wayx" align=center valign=bottom><td style="font-size:12px;color:#FFFFFF" Author=meizz>è?</td>';
strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=meizz>ò?</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>?t</td>';
strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=meizz>èy</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>??</td>';
strFrame+='<td style="font-size:12px;color:#FFFFFF" Author=meizz>??</td><td style="font-size:12px;color:#FFFFFF" Author=meizz>áù</td></tr>';
strFrame+='</table></td></tr><!-- Author:F.R.Huang(meizz) http://www.meizz.com/ mail: meizz@hzcnc.com 2002-10-8 -->';
strFrame+='  <tr Author="wayx"><td width=142 height=120 Author="wayx">';
strFrame+='    <table border=1 cellspacing=2 cellpadding=0 BORDERCOLORLIGHT=#8FB1F3 BORDERCOLORDARK=#FFFFFF bgcolor=#fff8ec width=140 height=120 Author="wayx">';
var n=0; for (j=0;j<5;j++){ strFrame+= ' <tr align=center Author="wayx">'; for (i=0;i<7;i++){
strFrame+='<td width=20 height=20 id=meizzDay'+n+' style="font-size:12px" Author=meizz onclick=parent.meizzDayClick(this.innerText,0)></td>';n++;}
strFrame+='</tr>';}
strFrame+='      <tr align=center Author="wayx">';
for (i=35;i<39;i++)strFrame+='<td width=20 height=20 id=meizzDay'+i+' style="font-size:12px" Author=wayx onclick="parent.meizzDayClick(this.innerText,0)"></td>';
strFrame+='        <td colspan=3 align=right Author=meizz><span onclick=parent.closeLayer() style="font-size:12px;cursor: hand"';
strFrame+='         Author=meizz title="' + _VersionInfo + '"><u>1?±?</u></span>&nbsp;</td></tr>';
strFrame+='    </table></td></tr><tr Author="wayx"><td Author="wayx">';
strFrame+='        <table border=0 cellspacing=1 cellpadding=0 width=100% Author="wayx" bgcolor=#FFFFFF>';
strFrame+='          <tr Author="wayx"><td Author=meizz align=left><input Author=meizz type=button class=button value="<<" title="?ò?°·- 1 ?ê" onclick="parent.meizzPrevY()" ';
strFrame+='             onfocus="this.blur()" style="font-size: 12px; height: 20px"><input Author=meizz class=button title="?ò?°·- 1 ??" type=button ';
strFrame+='             value="< " onclick="parent.meizzPrevM()" onfocus="this.blur()" style="font-size: 12px; height: 20px"></td><td ';
strFrame+='             Author=meizz align=center><input Author=meizz type=button class=button value=??è? onclick="parent.meizzToday()" ';
strFrame+='             onfocus="this.blur()" title="μ±?°è??ú" style="font-size: 12px; height: 20px; cursor:hand"></td><td ';
strFrame+='             Author=meizz align=right><input Author=meizz type=button class=button value=" >" onclick="parent.meizzNextM()" ';
strFrame+='             onfocus="this.blur()" title="?òoó·- 1 ??" class=button style="font-size: 12px; height: 20px"><input ';
strFrame+='             Author=meizz type=button class=button value=">>" title="?òoó·- 1 ?ê" onclick="parent.meizzNextY()"';
strFrame+='             onfocus="this.blur()" style="font-size: 12px; height: 20px"></td>';
strFrame+='</tr></table></td></tr></table></div>';

window.frames.meizzDateLayer.document.writeln(strFrame);
window.frames.meizzDateLayer.document.close();		//?a??ie???èì?2??áê?μ??êìa

//==================================================== WEB ò3????ê?2?·?

var outObject;
var outButton;		//μ??÷μ?°′?¥
var outDate="";		//′?·????óμ?è??ú
var odatelayer=window.frames.meizzDateLayer.document.all;		//′?·?è?àú???ó
function setday(tt,obj) //?÷μ÷oˉêy
{
	if (arguments.length >  2){alert("??2??e£?′?è?±????tμ?2?êyì??à£?");return;}
	if (arguments.length == 0){alert("??2??e£??ú??óD′???±????tè?o?2?êy£?");return;}
   calendar=true;       //±íê?ò??-???ˉè?àú
   lemisTree=false;     //lemisTree
//   alert("lemisTree:"+lemisTree);
//   alert("calendar:"+calendar);
	var dads  = document.all.meizzDateLayer.style;
	var th = tt;
	var ttop  = tt.offsetTop;     //TT???tμ??¨??μ???
	var thei  = tt.clientHeight;  //TT???t±?éíμ???
	var tleft = tt.offsetLeft;    //TT???tμ??¨??μ??í
	var ttyp  = tt.type;          //TT???tμ?ààDí
	while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
	dads.top  = (ttyp=="image")? ttop+thei : ttop+thei+6;
	dads.left = tleft;
	outObject = (arguments.length == 1) ? th : obj;
	outButton = (arguments.length == 1) ? null : th;	//éè?¨ía2?μ??÷μ?°′?¥
	//?ù?Yμ±?°ê?è??òμ?è??ú??ê?è?àúμ??ê??
	var reg = /^(\d+)-(\d{1,2})-(\d{1,2})$/;
	var r = outObject.value.match(reg);
	if(r!=null){
		r[2]=r[2]-1;
		var d= new Date(r[1], r[2],r[3]);
		if(d.getFullYear()==r[1] && d.getMonth()==r[2] && d.getDate()==r[3]){
			outDate=d;		//±£′?ía2?′?è?μ?è??ú
		}
		else outDate="";
			meizzSetDay(r[1],r[2]+1);
	}
	else{
		outDate="";
		meizzSetDay(new Date().getFullYear(), new Date().getMonth() + 1);
	}
	dads.display = '';

	event.returnValue=false;
}

var MonHead = new Array(12);    		   //?¨ò???àú?D??????μ?×?′óììêy
    MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4]  = 31; MonHead[5]  = 30;
    MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31;

var meizzTheYear=new Date().getFullYear(); //?¨ò??êμ?±?á?μ?3?ê??μ
var meizzTheMonth=new Date().getMonth()+1; //?¨ò???μ?±?á?μ?3?ê??μ
var meizzWDay=new Array(39);               //?¨ò?D′è??úμ?êy×é

function document.onclick(){ //è?òaμ??÷ê±1?±??????t	//ie6μ??é???éò?óé????μ??D???1μ?′|àí′úì?
  with(window.event)
  {
      if(workTypeTree){
          if (srcElement.getAttribute("Author")!="zhansk" && srcElement != workType_outObject1){
              regionTree=false;
              workTypeTree=false;
              calendar=false;
              workTypeTree_close();
        	}
      }else if(regionTree){
          if (srcElement.getAttribute("Author")!="zhansk" && srcElement != region_outObject1){
              regionTree=false;
              workTypeTree=false;
              calendar=false;
              regionTree_close();
        	}
      }else if(calendar){
          if (srcElement.getAttribute("Author")!="wayx" && srcElement != outObject && srcElement != outButton)
          {
              regionTree=false;
              workTypeTree=false;
              calendar=false;
              closeLayer();
          }
      }
  }
}

function document.onkeyup()		//°′Esc?ü1?±?£??D???1μ?1?±?
  {
    if (window.event.keyCode==27){
		if(outObject)outObject.blur();
		closeLayer();
	}
	else if(document.activeElement)
		if(document.activeElement.getAttribute("Author")==null && document.activeElement != outObject && document.activeElement != outButton)
		{
			closeLayer();
		}
  }

function meizzWriteHead(yy,mm)  //íù head ?DD′è?μ±?°μ??êó???
  {
	odatelayer.meizzYearHead.innerText  = yy + " ?ê";
    odatelayer.meizzMonthHead.innerText = mm + " ??";
  }

function tmpSelectYearInnerHTML(strYear) //?ê·Yμ???à-?ò
{
  if (strYear.match(/\D/)!=null){alert("?ê·Yê?è?2?êy2?ê?êy×?£?");return;}
  var m = (strYear) ? strYear : new Date().getFullYear();
  if (m < 1000 || m > 9999) {alert("?ê·Y?μ2??ú 1000 μ? 9999 ????£?");return;}
  var n = m - 100;
  if (n < 1000) n = 1000;
  if (n + 26 > 9999) n = 9974;
  var s = "<select Author=meizz name=tmpSelectYear style='font-size: 12px' "
     s += "onblur='document.all.tmpSelectYearLayer.style.display=\"none\"' "
     s += "onchange='document.all.tmpSelectYearLayer.style.display=\"none\";"
     s += "parent.meizzTheYear = this.value; parent.meizzSetDay(parent.meizzTheYear,parent.meizzTheMonth)'>\r\n";
  var selectInnerHTML = s;
  for (var i = n; i < n + 150; i++)
  {
    if (i == m)
       {selectInnerHTML += "<option Author=wayx value='" + i + "' selected>" + i + "?ê" + "</option>\r\n";}
    else {selectInnerHTML += "<option Author=wayx value='" + i + "'>" + i + "?ê" + "</option>\r\n";}
  }
  selectInnerHTML += "</select>";
  odatelayer.tmpSelectYearLayer.style.display="";
  odatelayer.tmpSelectYearLayer.innerHTML = selectInnerHTML;
  odatelayer.tmpSelectYear.focus();
}

function tmpSelectMonthInnerHTML(strMonth) //??·Yμ???à-?ò
{
  if (strMonth.match(/\D/)!=null){alert("??·Yê?è?2?êy2?ê?êy×?£?");return;}
  var m = (strMonth) ? strMonth : new Date().getMonth() + 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -