欢迎光临
我们一直在努力

分享:梅花雨日历控件2.02版-网页设计,HTML/CSS

建站超值云服务器,限时71元/月

  感谢meizz和walkingpoison,梅花雨日历控件很好用,我前面的贴子
http://community.csdn.net/expert/topicview.asp?id=3575789
发布了英文版(2.01版),通过最近一段时期的使用,根据用户反馈增加了两个内容:
  一是,当文本框只读的时候,不能清空其内容,现加入了一个c(clear)的按钮,可以清空;
  二是,下面的一行,原本是可以按月或者是年变更,现在加入了按十年变更的按钮。
代码如下

var bmoveable=true;  
var _versioninfo=”version:2.02
2.01&02 author: athos;2.0 author:walkingpoison
1.0 author: f.r.huang(meizz)
mail: meizz@hzcnc.com”;
var strframe;  
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: #ff9900 1px solid;border-top: #ff9900 1px solid;border-left: #ff9900 1px solid;;
strframe+=border-bottom: #ff9900 1px solid;background-color: #fff8ec;};
strframe+=td{font-size: 9pt;};
strframe+=</style>;
strframe+=<scr + ipt>;
strframe+=var datelayerx,datelayery; ;
strframe+=var bdrag; ;
strframe+=function document.onmousemove() ;
strframe+={if(bdrag && window.event.button==1);
strframe+= {var datelayer=parent.document.all.meizzdatelayer.style;;
strframe+=  datelayer.posleft += window.event.clientx-datelayerx;;
strframe+=  datelayer.postop += window.event.clienty-datelayery;}};
strframe+=function dragstart()  ;
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: 48;display: none”></span>;
strframe+=<table border=1 cellspacing=0 cellpadding=0 width=142 height=160 bordercolor=#ff9900 bgcolor=#ff9900 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=#ff9900 style=”font-size:12px;cursor: hand;color: #ffffff” ;
strframe+=        onclick=”parent.meizzprevm()” title=”1 month before” author=meizz><b author=meizz>&lt;</b>;
strframe+=        </td><td width=30 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)” title=”click to select year”><span author=meizz id=meizzyearhead></span></td>;
strframe+=<td width=78 align=center style=”font-size:12px;cursor:default” author=meizz onmouseover=”style.backgroundcolor=\#ffd700\” ;
strframe+= onmouseout=”style.backgroundcolor=\white\” onclick=”parent.tmpselectmonthinnerhtml(parent.athosmonthnametonum(this.innertext))”;
strframe+=        title=”click to select month”><span id=meizzmonthhead author=meizz></span></td>;
strframe+=        <td width=16 bgcolor=#ff9900 align=center style=”font-size:12px;cursor: hand;color: #ffffff” ;
strframe+=         onclick=”parent.meizznextm()” title=”1 month later” 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=#ff9900 + (bmoveable? onmousedown=”dragstart()” onmouseup=”dragend()”:);
strframe+= bordercolorlight=#ff9900 bordercolordark=#ffffff width=140 height=20 author=”wayx” style=”cursor: + (bmoveable ? move:default) + “>;
strframe+=<tr author=”wayx” align=center valign=bottom>;
strframe+=<td width=18px style=”font-size:12px;color:#ffffff” author=meizz title=”sunday”>s</td>;
strframe+=<td width=18px style=”font-size:12px;color:#ffffff” author=meizz title=”monday”>m</td>;
strframe+=<td width=18px style=”font-size:12px;color:#ffffff” author=meizz title=”tuesday”>t</td>;
strframe+=<td width=18px style=”font-size:12px;color:#ffffff” author=meizz title=”wednesday”>w</td>;
strframe+=<td width=18px style=”font-size:12px;color:#ffffff” author=meizz title=”thursday”>t</td>;
strframe+=<td width=18px style=”font-size:12px;color:#ffffff” author=meizz title=”friday”>f</td>;
strframe+=<td width=20px style=”font-size:12px;color:#ffffff” author=meizz title=”saturday”>s</td>;
strframe+=</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=#ff9900 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 align=right author=meizz><span onclick=parent.clearandcloselayer() style=”font-size:12px;cursor: hand;color:#00aaaa;”;
strframe+=         author=meizz title=”clear”><b>c</b></span>&nbsp;</td>;
strframe+=        <td align=right author=meizz><span onclick=parent.closelayer() style=”font-size:12px;cursor: hand;color:red;”;
strframe+=         author=meizz title=”close”><b>x</b></span>&nbsp;</td>;
strframe+=        <td align=right author=meizz><a href=”mailto: athos.liu@gmail.com; meizz@hzcnc.com” style=”text-decoration:none”;
strframe+=         author=meizz title=” + _versioninfo + “><i>&copy;</i></a>&nbsp;</td>;
strframe+=</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>;
strframe+=       <input author=meizz type=button class=button value=”&larr;” title=”10 year before” onclick=”parent.meizzprevy(10)” ;
strframe+=          onfocus=”this.blur()” style=”font-size: 12px; height: 20px”>;
strframe+=       <input author=meizz type=button class=button value=”&#171;” title=”1 year before” onclick=”parent.meizzprevy(1)” ;
strframe+=          onfocus=”this.blur()” style=”font-size: 12px; height: 20px”>;
strframe+=        <input author=meizz class=button title=”1 month before” type=button ;
strframe+=          value=”&lsaquo;” 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=td style=”color:#00007f;background-color:ffd700;font:italic bolder 10pt;” onclick=”parent.meizztoday()” ;
strframe+=             onfocus=”this.blur()” title=”today” style=”font-size: 12px; height: 20px; cursor:hand”></td><td ;
strframe+=             author=meizz align=right>;
strframe+=        <input author=meizz type=button class=button value=”&rsaquo;” onclick=”parent.meizznextm()” ;
strframe+=             onfocus=”this.blur()” title=”1 month later” class=button style=”font-size: 12px; height: 20px”>;
strframe+=        <input author=meizz type=button class=button value=”&#187;” title=”1 year later” onclick=”parent.meizznexty(1)”;
strframe+=             onfocus=”this.blur()” style=”font-size: 12px; height: 20px”>;
strframe+=       <input author=meizz type=button class=button value=”&rarr;” title=”10 year later” onclick=”parent.meizznexty(10)” ;
strframe+=          onfocus=”this.blur()” style=”font-size: 12px; height: 20px”>;
strframe+=      </td></tr></table></td></tr></table></div>;

window.frames.meizzdatelayer.document.writeln(strframe);
window.frames.meizzdatelayer.document.close();  

var outobject;
var outbutton; 
var outdate=””; 
var odatelayer=window.frames.meizzdatelayer.document.all;  
function setday(tt,obj)
{
 if (arguments.length >  2){alert(“sorry, too many parameters”);return;}
 if (arguments.length == 0){alert(“sorry, none parameter!”);return;}
 var dads  = document.all.meizzdatelayer.style;
 var th = tt;
 var ttop  = tt.offsettop;
 var thei  = tt.clientheight; 
 var tleft = tt.offsetleft; 
 var ttyp  = tt.type;       
 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; 
 var reg = /^(\d{1,2})\/(\d{1,2})\/(\d+)$/;
 var r = outobject.value.match(reg);
 
 if(r!=null){
  
  r[0]=r[3];
  r[3]=r[2];
  r[2]=r[1];
  r[1]=r[0];

  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;
  }
  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);        
    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();
var meizzthemonth=new date().getmonth()+1;
var meizzwday=new array(39);              

function document.onclick()
{
  with(window.event)
  { if (srcelement.getattribute(“author”)==null && srcelement != outobject && srcelement != outbutton)
    closelayer();
  }
}

function document.onkeyup() 
  {
    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)
  {
 odatelayer.meizzyearhead.innertext  = string(yy);
    odatelayer.meizzmonthhead.innertext = athosmonthnumtoname(string(mm));
  }

function athosmonthnametonum(mn)
{
 switch (string(mn))
 {
   case “january” :
      return string(1);
   case “feburary” :
      return string(2);
   case “march” :
   return string(3);
   case “april” :
      return string(4);
   case “may” :
      return string(5);
   case “june” :
      return string(6);
   case “july” :
   return string(7);
   case “august” :
      return string(8);
   case “september” :
      return string(9);
   case “october” :
      return string(10);
   case “november” :
   return string(11);
   case “december” :
      return string(12);
   default :
      return string(0);
 }
}

function athosmonthnumtoname(mm)
{
 switch (mm)
 {
   case “1”:
  return string(“january”);
   case “2”:
  return string(“feburary”);
   case “3”:
  return string(“march”);  
   case “4”:
  return string(“april”);
   case “5”:
  return string(“may”);
   case “6”:
  return string(“june”);
   case “7”:
  return string(“july”);
   case “8”:
  return string(“august”);
   case “9”:
  return string(“september”);
   case “10”:
  return string(“october”);
   case “11”:
  return string(“november”);
   case “12”:
  return string(“december”);
   default :
      return string(“unknownmonth”);
 }
}

function tmpselectyearinnerhtml(stryear)
{
  if (stryear.match(/\d/)!=null){alert(“year shall be a number.”);return;}
  var m = (stryear) ? stryear : new date().getfullyear();
  if (m < 1000 || m > 9999) {alert(“year shall between 1000 to 9999.”);return;}
  var n = m – 10;
  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 + 26; 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)
{
 if (strmonth.match(/\d/)!=null){alert(“month shall be a number”);return;}
  var m = (strmonth) ? strmonth : new date().getmonth() + 1;
  var s = “<select author=meizz name=tmpselectmonth style=font-size: 12px “
     s += “onblur=document.all.tmpselectmonthlayer.style.display=\”none\” “
     s += “onchange=document.all.tmpselectmonthlayer.style.display=\”none\”;”
     s += “parent.meizzthemonth = this.value; parent.meizzsetday(parent.meizztheyear,parent.meizzthemonth)>\r\n”;
  var selectinnerhtml = s;
  for (var i = 1; i < 13; i++)
  {
    if (i == m)
       {selectinnerhtml += “<option author=wayx value=”+i+” selected>”+  athosmonthnumtoname(string(i))        +”</option>\r\n”;}
    else {selectinnerhtml += “<option author=wayx value=”+i+”>”+        athosmonthnumtoname(string(i))         +”</option>\r\n”;}
  }
  selectinnerhtml += “</select>”;
  odatelayer.tmpselectmonthlayer.style.display=””;
  odatelayer.tmpselectmonthlayer.innerhtml = selectinnerhtml;
  odatelayer.tmpselectmonth.focus();
}

function closelayer()              
  {
    document.all.meizzdatelayer.style.display=”none”;
  }
function clearandcloselayer()              
  {
  if (outobject)
  {
   outobject.value= “”;
   closelayer();
  }
  else {closelayer(); alert(“none control to output!”);}   
  }

function ispinyear(year)           
  {
    if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
  }

function getmonthcount(year,month) 
  {
    var c=monhead[month-1];if((month==2)&&ispinyear(year)) c++;return c;
  }
function getdow(day,month,year)    
  {
    var dt=new date(year,month-1,day).getday()/7; return dt;
  }

function meizzprevy(intyears) 
  {
    if(meizztheyear > 999 && meizztheyear <10000){meizztheyear-=intyears;}
    else{alert(“year beyond (1000-9999)!”);}
    meizzsetday(meizztheyear,meizzthemonth);
  }
function meizznexty(intyears) 
  {
    if(meizztheyear > 999 && meizztheyear <10000){meizztheyear+=intyears;}
    else{alert(“year beyond (1000-9999)!”);}
    meizzsetday(meizztheyear,meizzthemonth);
  }
function meizztoday() 
  {
 var today;
    meizztheyear = new date().getfullyear();
    meizzthemonth = new date().getmonth()+1;
    today=new date().getdate();
    //meizzsetday(meizztheyear,meizzthemonth);
    if(outobject){
  outobject.value=meizztheyear + “-” + meizzthemonth + “-” + today;
    }
    closelayer();
  }
function meizzprevm() 
  {
    if(meizzthemonth>1){meizzthemonth–}else{meizztheyear–;meizzthemonth=12;}
    meizzsetday(meizztheyear,meizzthemonth);
  }
function meizznextm() 
  {
    if(meizzthemonth==12){meizztheyear++;meizzthemonth=1}else{meizzthemonth++}
    meizzsetday(meizztheyear,meizzthemonth);
  }

function meizzsetday(yy,mm)  
{
  meizzwritehead(yy,mm);
  meizztheyear=yy;
  meizzthemonth=mm;
 
  for (var i = 0; i < 39; i++){meizzwday[i]=””}; 
  var day1 = 1,day2=1,firstday = new date(yy,mm-1,1).getday(); 
  for (i=0;i<firstday;i++)meizzwday[i]=getmonthcount(mm==1?yy-1:yy,mm==1?12:mm-1)-firstday+i+1 
  for (i = firstday; day1 < getmonthcount(yy,mm)+1; i++){meizzwday[i]=day1;day1++;}
  for (i=firstday+getmonthcount(yy,mm);i<39;i++){meizzwday[i]=day2;day2++}
  for (i = 0; i < 39; i++)
  { var da = eval(“odatelayer.meizzday”+i)
    if (meizzwday[i]!=””)
      {
  da.bordercolorlight=”#ff9900″;
  da.bordercolordark=”#ffffff”;
  if(i<firstday)  
  {
   da.innerhtml=”<b><font color=gray>” + meizzwday[i] + “</font></b>”;
   da.title=(mm==1?12:mm-1) +”mn” + meizzwday[i] + “dt”;
   da.onclick=function(“meizzdayclick(this.innertext,-1)”);
   if(!outdate)
    da.style.backgroundcolor = ((mm==1?yy-1:yy) == new date().getfullyear() &&
     (mm==1?12:mm-1) == new date().getmonth()+1 && meizzwday[i] == new date().getdate()) ?
      “#ffd700″:”#e0e0e0”;
   else
   {
    da.style.backgroundcolor =((mm==1?yy-1:yy)==outdate.getfullyear() && (mm==1?12:mm-1)== outdate.getmonth() + 1 &&
    meizzwday[i]==outdate.getdate())? “#00ffff” :
    (((mm==1?yy-1:yy) == new date().getfullyear() && (mm==1?12:mm-1) == new date().getmonth()+1 &&
    meizzwday[i] == new date().getdate()) ? “#ffd700″:”#e0e0e0”);
    if((mm==1?yy-1:yy)==outdate.getfullyear() && (mm==1?12:mm-1)== outdate.getmonth() + 1 &&
    meizzwday[i]==outdate.getdate())
    {
     da.bordercolorlight=”#ffffff”;
     da.bordercolordark=”#ff9900″;
    }
   }
  }
  else if (i>=firstday+getmonthcount(yy,mm))
  {
   da.innerhtml=”<b><font color=gray>” + meizzwday[i] + “</font></b>”;
   da.title=(mm==12?1:mm+1) +”mn” + meizzwday[i] + “dt”;
   da.onclick=function(“meizzdayclick(this.innertext,1)”);
   if(!outdate)
    da.style.backgroundcolor = ((mm==12?yy+1:yy) == new date().getfullyear() &&
     (mm==12?1:mm+1) == new date().getmonth()+1 && meizzwday[i] == new date().getdate()) ?
      “#ffd700″:”#e0e0e0”;
   else
   {
    da.style.backgroundcolor =((mm==12?yy+1:yy)==outdate.getfullyear() && (mm==12?1:mm+1)== outdate.getmonth() + 1 &&
    meizzwday[i]==outdate.getdate())? “#00ffff” :
    (((mm==12?yy+1:yy) == new date().getfullyear() && (mm==12?1:mm+1) == new date().getmonth()+1 &&
    meizzwday[i] == new date().getdate()) ? “#ffd700″:”#e0e0e0”);
    if((mm==12?yy+1:yy)==outdate.getfullyear() && (mm==12?1:mm+1)== outdate.getmonth() + 1 &&
    meizzwday[i]==outdate.getdate())
    {
     da.bordercolorlight=”#ffffff”;
     da.bordercolordark=”#ff9900″;
    }
   }
  }
  else  
  {
   da.innerhtml=”<b>” + meizzwday[i] + “</b>”;
   da.title=mm +”mn” + meizzwday[i] + “dt”;
   da.onclick=function(“meizzdayclick(this.innertext,0)”);  
   
   if(!outdate)
    da.style.backgroundcolor = (yy == new date().getfullyear() && mm == new date().getmonth()+1 && meizzwday[i] == new date().getdate())?
     “#ffd700″:”#e0e0e0”;
   else
   {
    da.style.backgroundcolor =(yy==outdate.getfullyear() && mm== outdate.getmonth() + 1 && meizzwday[i]==outdate.getdate())?
     “#00ffff”:((yy == new date().getfullyear() && mm == new date().getmonth()+1 && meizzwday[i] == new date().getdate())?
     “#ffd700″:”#e0e0e0”);
    if(yy==outdate.getfullyear() && mm== outdate.getmonth() + 1 && meizzwday[i]==outdate.getdate())
    {
     da.bordercolorlight=”#ffffff”;
     da.bordercolordark=”#ff9900″;
    }
   }
  }
        da.style.cursor=”hand”
      }
    else{da.innerhtml=””;da.style.backgroundcolor=””;da.style.cursor=”default”}
  }
}

function meizzdayclick(n,ex)
{
  var yy=meizztheyear;
  var mm = parseint(meizzthemonth)+ex; 
 if(mm<1){
  yy–;
  mm=12+mm;
 }
 else if(mm>12){
  yy++;
  mm=mm-12;
 }
 
  if (mm < 10){mm = “0” + mm;}
  if (outobject)
  {
    if (!n) {
      return;}
    if ( n < 10){n = “0” + n;}
    outobject.value= mm + “/” + n + “/” + yy ;
    closelayer();
  }
  else {closelayer(); alert(“none control to output!”);}
}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 分享:梅花雨日历控件2.02版-网页设计,HTML/CSS
分享到: 更多 (0)