📄 calendar.js
字号:
function Calendar(selectedDate,type){
var isIE = false;
var isFF = false;
var isSa = false;
if ((navigator.userAgent.indexOf("MSIE")>0) && (parseInt(navigator.appVersion) >=4))isIE = true;
if(navigator.userAgent.indexOf("Firefox")>0)isFF = true;
if(navigator.userAgent.indexOf("Safari")>0)isSa = true;
var container=document.createElement("div");
container.style.cssText="display:block;overflow:hidden;height:180px;width:179px;position:relative;";
container.className="Calendar";
container.onselectstart=function(){return false;}
var head=document.createElement("div");
head.style.cssText="position:relative;width:179px;height:30px;z-Index:1;overflow:hidden;text-align:center;";
head.className="Calendar CalendarHead";
var title;
head.appendChild(document.createElement("span"));
head.firstChild.appendChild(document.createTextNode("←"));
head.firstChild.style.cssText="position:absolute;float:left;left:0px;top:0px;";
head.lastChild.onclick=new Function("this.parentNode.parentNode.lastChild.lastCard();");
head.appendChild(title=document.createElement("span"));
title.style.cssText="margin:auto auto auto auto;"
title.onclick=new Function("this.parentNode.parentNode.lastChild.upperCard();");
head.appendChild(document.createElement("span"));
head.lastChild.appendChild(document.createTextNode("→"));
head.lastChild.style.cssText="position:absolute;float:right;right:0px;top:0px;";
head.lastChild.onclick=new Function("this.parentNode.parentNode.lastChild.nextCard();");
container.appendChild(head);
var body=document.createElement("div");
body.style.cssText="position:relative;width:179px;height:150px;overflow:hidden;"
body.className="Calendar CalendarBody"
container.appendChild(body);
container.selectedDate=selectedDate||new Date();
var months=new String("一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月").split(",");
function HandredyearPicker(selectedDate)
{
var container=document.createElement("div");
container.style.cssText="position:absolute;width:179px;height:150px;overflow:hidden;";
var startyear=selectedDate.getFullYear()-selectedDate.getFullYear()%1000;
container.title=startyear+"-"+(startyear+999);
var datepicker=document.createElement("table");
datepicker.style.cssText="position:relative;width:179px;height:150px;overflow:hidden;text-align:center;font-size:15px;";
datepicker.appendChild(document.createElement("tbody"));
datepicker.cellSpacing="0";
datepicker.border="0";
datepicker.style.tableLayout="fixed";
var i=-1;
for(var x=0;x<3;x++)
{
datepicker.firstChild.appendChild(document.createElement("tr"));
for(var y=0;y<4;y++)
{
datepicker.firstChild.lastChild.appendChild(document.createElement("td"));
var tstart=startyear+100*i++
if(i==0)
{
datepicker.firstChild.lastChild.lastChild.className="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.type="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.lastCard()");
}
else if(i==11)
{
datepicker.firstChild.lastChild.lastChild.className="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.type="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.nextCard()");
}
else
{
datepicker.firstChild.lastChild.lastChild.onmouseover=new Function("this.className=\"Calendar CalendarHoverCell\"");
datepicker.firstChild.lastChild.lastChild.onmouseout=new Function("this.className=this.type");
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.selectedDate.setFullYear("+tstart+");this.parentNode.parentNode.parentNode.parentNode.parentNode.lowerCard()");
}
;
datepicker.firstChild.lastChild.lastChild.appendChild(document.createTextNode(tstart+"-\n"+(tstart+99)));
}
}
container.appendChild(datepicker);
Picker.call(container);
return container;
}
function TenyearPicker(selectedDate)
{
var container=document.createElement("div");
container.style.cssText="position:absolute;width:179px;height:150px;overflow:hidden;";
var startyear=selectedDate.getFullYear()-selectedDate.getFullYear()%100;
container.title=startyear+"-"+(startyear+99);
var datepicker=document.createElement("table");
datepicker.style.cssText="position:relative;width:179px;height:150px;overflow:hidden;text-align:center;font-size:15px;";
datepicker.appendChild(document.createElement("tbody"));
datepicker.cellSpacing="0";
datepicker.border="0";
datepicker.style.tableLayout="fixed";
var i=-1;
for(var x=0;x<3;x++)
{
datepicker.firstChild.appendChild(document.createElement("tr"));
for(var y=0;y<4;y++)
{
datepicker.firstChild.lastChild.appendChild(document.createElement("td"));
var tstart=startyear+10*i++;
if(i==0)
{
datepicker.firstChild.lastChild.lastChild.className="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.type="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.lastCard()");
}
else if(i==11)
{
datepicker.firstChild.lastChild.lastChild.className="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.type="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.nextCard()");
}
else
{
datepicker.firstChild.lastChild.lastChild.onmouseover=new Function("this.className=\"Calendar CalendarHoverCell\"");
datepicker.firstChild.lastChild.lastChild.onmouseout=new Function("this.className=this.type");
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.selectedDate.setFullYear("+tstart+");this.parentNode.parentNode.parentNode.parentNode.parentNode.lowerCard()");
}
datepicker.firstChild.lastChild.lastChild.appendChild(document.createTextNode(tstart+"-\n"+(tstart+9)));
}
}
container.appendChild(datepicker);
Picker.call(container);
return container;
}
function YearPicker(selectedDate)
{
var container=document.createElement("div");
container.style.cssText="position:absolute;width:179px;height:150px;overflow:hidden;";
var startyear=selectedDate.getFullYear()-selectedDate.getFullYear()%10;
container.title=startyear+"-"+(startyear+9);
var datepicker=document.createElement("table");
datepicker.style.cssText="position:relative;width:179px;height:150px;overflow:hidden;text-align:center;font-size:15px;";
datepicker.appendChild(document.createElement("tbody"));
datepicker.cellSpacing="0";
datepicker.border="0";
datepicker.style.tableLayout="fixed";
var i=-1;
for(var x=0;x<3;x++)
{
datepicker.firstChild.appendChild(document.createElement("tr"));
for(var y=0;y<4;y++)
{
datepicker.firstChild.lastChild.appendChild(document.createElement("td"));
if(i==-1)
{
datepicker.firstChild.lastChild.lastChild.className="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.type="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.lastCard()");
}
else if(i==10)
{
datepicker.firstChild.lastChild.lastChild.className="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.type="Calendar CalendarDisabledCell";
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.nextCard()");
}
else
{
datepicker.firstChild.lastChild.lastChild.onmouseover=new Function("this.className=\"Calendar CalendarHoverCell\"");
datepicker.firstChild.lastChild.lastChild.onmouseout=new Function("this.className=this.type");
datepicker.firstChild.lastChild.lastChild.onclick=new Function("this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.selectedDate.setFullYear("+(startyear+i)+");this.parentNode.parentNode.parentNode.parentNode.parentNode.lowerCard()");
}
datepicker.firstChild.lastChild.lastChild.appendChild(document.createTextNode(startyear+i++));
}
}
container.appendChild(datepicker);
Picker.call(container);
return container;
}
function MonthPicker(selectedDate)
{
var container=document.createElement("div");
container.style.cssText="position:absolute;width:179px;height:150px;overflow:hidden;";
container.title=selectedDate.getFullYear();
var datepicker=document.createElement("table");
datepicker.style.cssText="position:relative;width:179px;height:150px;overflow:hidden;text-align:center;font-size:15px;";
datepicker.appendChild(document.createElement("tbody"));
datepicker.cellSpacing="0";
datepicker.border="0";
datepicker.style.tableLayout="fixed";
datepicker.style.fontSize="13px";
var i=0;
for(var x=0;x<3;x++)
{
datepicker.firstChild.appendChild(document.createElement("tr"));
for(var y=0;y<4;y++)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -