javascript英文日期(有时间)选择器
javascript英文日期(有时间)选择器
发布时间:2016-12-30 来源:查字典编辑
摘要:varlanguageCode='en';//Possiblevalues:en,ge,no,nl,es,pt-br,fr//en=engl...

varlanguageCode='en';//Possiblevalues:en,ge,no,nl,es,pt-br,fr

//en=english,ge=german,no=norwegian,nl=dutch,es=spanish,pt-br=portuguese,fr=french,da=danish,hu=hungarian(UseUTF-8doctypeforhungarian)

varcalendar_display_time=true;

//Formatofcurrentdayatthebottomofthecalendar

//[todayString]=thevalueoftodayString

//[dayString]=dayofweek(examle:mon,tue,wed...)

//[UCFdayString]=dayofweek(examle:Mon,Tue,Wed...)(Firstletterinuppercase)

//[day]=Dayofmonth,1..31

//[monthString]=Nameofcurrentmonth

//[year]=Currentyear

vartodayStringFormat='[todayString][UCFdayString].[day].[monthString][year]';

varpathToImages='images/';//RelativetoyourHTMLfile

varspeedOfSelectBoxSliding=200;//Millisecondsbetweenchangingyearandhourwhenholdingmouseover"-"and"+"-lowervalue=faster

varintervalSelectBox_minutes=5;//Minuteselectbox-intervalbetweeneachoption(5=default)

varcalendar_offsetTop=0;//Offset-calendarplacement-Youprobablyhavetomodifythisvalueifyou'renotusingastrictdoctype

varcalendar_offsetLeft=0;//Offset-calendarplacement-Youprobablyhavetomodifythisvalueifyou'renotusingastrictdoctype

varcalendarDiv=false;

varMSIE=false;

varOpera=false;

if(navigator.userAgent.indexOf('MSIE')>=0&&navigator.userAgent.indexOf('Opera')<0)MSIE=true;

if(navigator.userAgent.indexOf('Opera')>=0)Opera=true;

switch(languageCode){

case"en":/*English*/

varmonthArray=['January','February','March','April','May','June','July','August','September','October','November','December'];

varmonthArrayShort=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];

vardayArray=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];

varweekString='Week';

vartodayString='';

break;

case"ge":/*German*/

varmonthArray=['Januar','Februar','M鋜z','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'];

varmonthArrayShort=['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'];

vardayArray=['Mon','Die','Mit','Don','Fre','Sam','Son'];

varweekString='Woche';

vartodayString='Heute';

break;

case"no":/*Norwegian*/

varmonthArray=['Januar','Februar','Mars','April','Mai','Juni','Juli','August','September','Oktober','November','Desember'];

varmonthArrayShort=['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Des'];

vardayArray=['Man','Tir','Ons','Tor','Fre','Lør','Søn'];

varweekString='Uke';

vartodayString='Dagenidager';

break;

case"nl":/*Dutch*/

varmonthArray=['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'];

varmonthArrayShort=['Jan','Feb','Mar','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'];

vardayArray=['Ma','Di','Wo','Do','Vr','Za','Zo'];

varweekString='Week';

vartodayString='Vandaag';

break;

case"es":/*Spanish*/

varmonthArray=['Enero','Febrero','Marzo','April','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'];

varmonthArrayShort=['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'];

vardayArray=['Lun','Mar','Mie','Jue','Vie','Sab','Dom'];

varweekString='Semana';

vartodayString='Hoyes';

break;

case"pt-br":/*Brazilianportuguese(pt-br)*/

varmonthArray=['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'];

varmonthArrayShort=['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'];

vardayArray=['Seg','Ter','Qua','Qui','Sex','Sáb','Dom'];

varweekString='Sem.';

vartodayString='Hojeé';

break;

case"fr":/*French*/

varmonthArray=['Janvier','F関rier','Mars','Avril','Mai','Juin','Juillet','Ao鹴','Septembre','Octobre','Novembre','D閏embre'];

varmonthArrayShort=['Jan','Fev','Mar','Avr','Mai','Jun','Jul','Aou','Sep','Oct','Nov','Dec'];

vardayArray=['Lun','Mar','Mer','Jeu','Ven','Sam','Dim'];

varweekString='Sem';

vartodayString="Aujourd'hui";

break;

case"da":/*Danish*/

varmonthArray=['januar','februar','marts','april','maj','juni','juli','august','september','oktober','november','december'];

varmonthArrayShort=['jan','feb','mar','apr','maj','jun','jul','aug','sep','okt','nov','dec'];

vardayArray=['man','tirs','ons','tors','fre','lør','søn'];

varweekString='Uge';

vartodayString='Idagerden';

break;

case"hu":/*Hungarian-RemembertouseUTF-8encoding,i.e.the<meta>tag*/

varmonthArray=['Janu谩r','Febru谩r','M谩rcius','?prilis','M谩jus','J煤nius','J煤lius','Augusztus','Szeptember','Okt贸ber','November','December'];

varmonthArrayShort=['Jan','Feb','M谩rc','?pr','M谩j','J煤n','J煤l','Aug','Szep','Okt','Nov','Dec'];

vardayArray=['H茅','Ke','Sze','Cs','P茅','Szo','Vas'];

varweekString='H茅t';

vartodayString='Mainap';

break;

case"it":/*Italian*/

varmonthArray=['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'];

varmonthArrayShort=['Gen','Feb','Mar','Apr','Mag','Giu','Lugl','Ago','Set','Ott','Nov','Dic'];

vardayArray=['Lun',';Mar','Mer','Gio','Ven','Sab','Dom'];

varweekString='Settimana';

vartodayString='Oggièil';

break;

case"sv":/*Swedish*/

varmonthArray=['Januari','Februari','Mars','April','Maj','Juni','Juli','Augusti','September','Oktober','November','December'];

varmonthArrayShort=['Jan','Feb','Mar','Apr','Maj','Jun','Jul','Aug','Sep','Okt','Nov','Dec'];

vardayArray=['Mån','Tis','Ons','Tor','Fre','Lör','Sön'];

varweekString='Vecka';

vartodayString='Idagärdetden';

break;

}

vardaysInMonthArray=[31,28,31,30,31,30,31,31,30,31,30,31];

varcurrentMonth;

varcurrentYear;

varcurrentHour;

varcurrentMinute;

varcalendarContentDiv;

varreturnDateTo;

varreturnFormat;

varactiveSelectBoxMonth;

varactiveSelectBoxYear;

varactiveSelectBoxHour;

varactiveSelectBoxMinute;

variframeObj=false;

////fixforEIframeproblemontimedropdowns09/30/2006

variframeObj2=false;

functionEIS_FIX_EI1(where2fixit)

{

if(!iframeObj2)return;

iframeObj2.style.display='block';

iframeObj2.style.height=document.getElementById(where2fixit).offsetHeight+1;

iframeObj2.style.width=document.getElementById(where2fixit).offsetWidth;

iframeObj2.style.left=getleftPos(document.getElementById(where2fixit))+1-calendar_offsetLeft;

iframeObj2.style.top=getTopPos(document.getElementById(where2fixit))-document.getElementById(where2fixit).offsetHeight-calendar_offsetTop;

}

functionEIS_Hide_Frame()

{if(iframeObj2)iframeObj2.style.display='none';}

////fixforEIframeproblemontimedropdowns09/30/2006

varreturnDateToYear;

varreturnDateToMonth;

varreturnDateToDay;

varreturnDateToHour;

varreturnDateToMinute;

varinputYear;

varinputMonth;

varinputDay;

varinputHour;

varinputMinute;

varcalendarDisplayTime=false;

varselectBoxHighlightColor='#D60808';//Highlightcolorofselectboxes

varselectBoxRolloverBgColor='#E2EBED';//Backgroundcolorondropdownlists(rollover)

varselectBoxMovementInProgress=false;

varactiveSelectBox=false;

functioncancelCalendarEvent()

{

returnfalse;

}

functionisLeapYear(inputYear)

{

if(inputYear%400==0||(inputYear%4==0&&inputYear%100!=0))returntrue;

returnfalse;

}

varactiveSelectBoxMonth=false;

varactiveSelectBoxDirection=false;

functionhighlightMonthYear()

{

if(activeSelectBoxMonth)activeSelectBoxMonth.className='';

activeSelectBox=this;

if(this.className=='monthYearActive'){

this.className='';

}else{

this.className='monthYearActive';

activeSelectBoxMonth=this;

}

if(this.innerHTML.indexOf('-')>=0||this.innerHTML.indexOf('+')>=0){

if(this.className=='monthYearActive')

selectBoxMovementInProgress=true;

else

selectBoxMovementInProgress=false;

if(this.innerHTML.indexOf('-')>=0)activeSelectBoxDirection=-1;elseactiveSelectBoxDirection=1;

}elseselectBoxMovementInProgress=false;

}

functionshowMonthDropDown()

{

if(document.getElementById('monthDropDown').style.display=='block'){

document.getElementById('monthDropDown').style.display='none';

////fixforEIframeproblemontimedropdowns09/30/2006

EIS_Hide_Frame();

}else{

document.getElementById('monthDropDown').style.display='block';

document.getElementById('yearDropDown').style.display='none';

document.getElementById('hourDropDown').style.display='none';

document.getElementById('minuteDropDown').style.display='none';

if(MSIE)

{EIS_FIX_EI1('monthDropDown')}

////fixforEIframeproblemontimedropdowns09/30/2006

}

}

functionshowYearDropDown()

{

if(document.getElementById('yearDropDown').style.display=='block'){

document.getElementById('yearDropDown').style.display='none';

////fixforEIframeproblemontimedropdowns09/30/2006

EIS_Hide_Frame();

}else{

document.getElementById('yearDropDown').style.display='block';

document.getElementById('monthDropDown').style.display='none';

document.getElementById('hourDropDown').style.display='none';

document.getElementById('minuteDropDown').style.display='none';

if(MSIE)

{EIS_FIX_EI1('yearDropDown')}

////fixforEIframeproblemontimedropdowns09/30/2006

}

}

functionshowHourDropDown()

{

if(document.getElementById('hourDropDown').style.display=='block'){

document.getElementById('hourDropDown').style.display='none';

////fixforEIframeproblemontimedropdowns09/30/2006

EIS_Hide_Frame();

}else{

document.getElementById('hourDropDown').style.display='block';

document.getElementById('monthDropDown').style.display='none';

document.getElementById('yearDropDown').style.display='none';

document.getElementById('minuteDropDown').style.display='none';

if(MSIE)

{EIS_FIX_EI1('hourDropDown')}

////fixforEIframeproblemontimedropdowns09/30/2006

}

}

functionshowMinuteDropDown()

{

if(document.getElementById('minuteDropDown').style.display=='block'){

document.getElementById('minuteDropDown').style.display='none';

////fixforEIframeproblemontimedropdowns09/30/2006

EIS_Hide_Frame();

}else{

document.getElementById('minuteDropDown').style.display='block';

document.getElementById('monthDropDown').style.display='none';

document.getElementById('yearDropDown').style.display='none';

document.getElementById('hourDropDown').style.display='none';

if(MSIE)

{EIS_FIX_EI1('minuteDropDown')}

////fixforEIframeproblemontimedropdowns09/30/2006

}

}

functionselectMonth()

{

document.getElementById('calendar_month_txt').innerHTML=this.innerHTML

currentMonth=this.id.replace(/[^d]/g,'');

document.getElementById('monthDropDown').style.display='none';

////fixforEIframeproblemontimedropdowns09/30/2006

EIS_Hide_Frame();

for(varno=0;no<monthArray.length;no++){

document.getElementById('monthDiv_'+no).style.color='';

}

this.style.color=selectBoxHighlightColor;

activeSelectBoxMonth=this;

writeCalendarContent();

}

functionselectHour()

{

document.getElementById('calendar_hour_txt').innerHTML=this.innerHTML

currentHour=this.innerHTML.replace(/[^d]/g,'');

document.getElementById('hourDropDown').style.display='none';

////fixforEIframeproblemontimedropdowns09/30/2006

EIS_Hide_Frame();

if(activeSelectBoxHour){

activeSelectBoxHour.style.color='';

}

activeSelectBoxHour=this;

this.style.color=selectBoxHighlightColor;

}

functionselectMinute()

{

document.getElementById('calendar_minute_txt').innerHTML=this.innerHTML

currentMinute=this.innerHTML.replace(/[^d]/g,'');

document.getElementById('minuteDropDown').style.display='none';

////fixforEIframeproblemontimedropdowns09/30/2006

EIS_Hide_Frame();

if(activeSelectBoxMinute){

activeSelectBoxMinute.style.color='';

}

activeSelectBoxMinute=this;

this.style.color=selectBoxHighlightColor;

}

functionselectYear()

{

document.getElementById('calendar_year_txt').innerHTML=this.innerHTML

currentYear=this.innerHTML.replace(/[^d]/g,'');

document.getElementById('yearDropDown').style.display='none';

////fixforEIframeproblemontimedropdowns09/30/2006

EIS_Hide_Frame();

if(activeSelectBoxYear){

activeSelectBoxYear.style.color='';

}

activeSelectBoxYear=this;

this.style.color=selectBoxHighlightColor;

writeCalendarContent();

}

functionswitchMonth()

{

if(this.src.indexOf('left')>=0){

currentMonth=currentMonth-1;;

if(currentMonth<0){

currentMonth=11;

currentYear=currentYear-1;

}

}else{

currentMonth=currentMonth+1;;

if(currentMonth>11){

currentMonth=0;

currentYear=currentYear/1+1;

}

}

writeCalendarContent();

}

functioncreateMonthDiv(){

vardiv=document.createElement('DIV');

div.className='monthYearPicker';

div.id='monthPicker';

for(varno=0;no<monthArray.length;no++){

varsubDiv=document.createElement('DIV');

subDiv.innerHTML=monthArray[no];

subDiv.onmouseover=highlightMonthYear;

subDiv.onmouseout=highlightMonthYear;

subDiv.onclick=selectMonth;

subDiv.id='monthDiv_'+no;

subDiv.style.width='56px';

subDiv.onselectstart=cancelCalendarEvent;

div.appendChild(subDiv);

if(currentMonth&¤tMonth==no){

subDiv.style.color=selectBoxHighlightColor;

activeSelectBoxMonth=subDiv;

}

}

returndiv;

}

functionchangeSelectBoxYear(e,inputObj)

{

if(!inputObj)inputObj=this;

varyearItems=inputObj.parentNode.getElementsByTagName('DIV');

if(inputObj.innerHTML.indexOf('-')>=0){

varstartYear=yearItems[1].innerHTML/1-1;

if(activeSelectBoxYear){

activeSelectBoxYear.style.color='';

}

}else{

varstartYear=yearItems[1].innerHTML/1+1;

if(activeSelectBoxYear){

activeSelectBoxYear.style.color='';

}

}

for(varno=1;no<yearItems.length-1;no++){

yearItems[no].innerHTML=startYear+no-1;

yearItems[no].id='yearDiv'+(startYear/1+no/1-1);

}

if(activeSelectBoxYear){

activeSelectBoxYear.style.color='';

if(document.getElementById('yearDiv'+currentYear)){

activeSelectBoxYear=document.getElementById('yearDiv'+currentYear);

activeSelectBoxYear.style.color=selectBoxHighlightColor;;

}

}

}

functionchangeSelectBoxHour(e,inputObj)

{

if(!inputObj)inputObj=this;

varhourItems=inputObj.parentNode.getElementsByTagName('DIV');

if(inputObj.innerHTML.indexOf('-')>=0){

varstartHour=hourItems[1].innerHTML/1-1;

if(startHour<0)startHour=0;

if(activeSelectBoxHour){

activeSelectBoxHour.style.color='';

}

}else{

varstartHour=hourItems[1].innerHTML/1+1;

if(startHour>14)startHour=14;

if(activeSelectBoxHour){

activeSelectBoxHour.style.color='';

}

}

varprefix='';

for(varno=1;no<hourItems.length-1;no++){

if((startHour/1+no/1)<11)prefix='0';elseprefix='';

hourItems[no].innerHTML=prefix+(startHour+no-1);

hourItems[no].id='hourDiv'+(startHour/1+no/1-1);

}

if(activeSelectBoxHour){

activeSelectBoxHour.style.color='';

if(document.getElementById('hourDiv'+currentHour)){

activeSelectBoxHour=document.getElementById('hourDiv'+currentHour);

activeSelectBoxHour.style.color=selectBoxHighlightColor;;

}

}

}

functionupdateYearDiv()

{

vardiv=document.getElementById('yearDropDown');

varyearItems=div.getElementsByTagName('DIV');

for(varno=1;no<yearItems.length-1;no++){

yearItems[no].innerHTML=currentYear/1-6+no;

if(currentYear==(currentYear/1-6+no)){

yearItems[no].style.color=selectBoxHighlightColor;

activeSelectBoxYear=yearItems[no];

}else{

yearItems[no].style.color='';

}

}

}

functionupdateMonthDiv()

{

for(no=0;no<12;no++){

document.getElementById('monthDiv_'+no).style.color='';

}

document.getElementById('monthDiv_'+currentMonth).style.color=selectBoxHighlightColor;

activeSelectBoxMonth=document.getElementById('monthDiv_'+currentMonth);

}

functionupdateHourDiv()

{

vardiv=document.getElementById('hourDropDown');

varhourItems=div.getElementsByTagName('DIV');

varaddHours=0;

if((currentHour/1-6+1)<0){

addHours=(currentHour/1-6+1)*-1;

}

for(varno=1;no<hourItems.length-1;no++){

varprefix='';

if((currentHour/1-6+no+addHours)<10)prefix='0';

hourItems[no].innerHTML=prefix+(currentHour/1-6+no+addHours);

if(currentHour==(currentHour/1-6+no)){

hourItems[no].style.color=selectBoxHighlightColor;

activeSelectBoxHour=hourItems[no];

}else{

hourItems[no].style.color='';

}

}

}

functionupdateMinuteDiv()

{

for(no=0;no<60;no+=intervalSelectBox_minutes){

varprefix='';

if(no<10)prefix='0';

document.getElementById('minuteDiv_'+prefix+no).style.color='';

}

if(document.getElementById('minuteDiv_'+currentMinute)){

document.getElementById('minuteDiv_'+currentMinute).style.color=selectBoxHighlightColor;

activeSelectBoxMinute=document.getElementById('minuteDiv_'+currentMinute);

}

}

functioncreateYearDiv()

{

if(!document.getElementById('yearDropDown')){

vardiv=document.createElement('DIV');

div.className='monthYearPicker';

}else{

vardiv=document.getElementById('yearDropDown');

varsubDivs=div.getElementsByTagName('DIV');

for(varno=0;no<subDivs.length;no++){

subDivs[no].parentNode.removeChild(subDivs[no]);

}

}

vard=newDate();

if(currentYear){

d.setFullYear(currentYear);

}

varstartYear=d.getFullYear()/1-5;

varsubDiv=document.createElement('DIV');

subDiv.innerHTML='-';

subDiv.onclick=changeSelectBoxYear;

subDiv.onmouseover=highlightMonthYear;

subDiv.onmouseout=function(){selectBoxMovementInProgress=false;};

subDiv.onselectstart=cancelCalendarEvent;

div.appendChild(subDiv);

for(varno=startYear;no<(startYear+10);no++){

varsubDiv=document.createElement('DIV');

subDiv.innerHTML=no;

subDiv.onmouseover=highlightMonthYear;

subDiv.onmouseout=highlightMonthYear;

subDiv.onclick=selectYear;

subDiv.id='yearDiv'+no;

subDiv.onselectstart=cancelCalendarEvent;

div.appendChild(subDiv);

if(currentYear&¤tYear==no){

subDiv.style.color=selectBoxHighlightColor;

activeSelectBoxYear=subDiv;

}

}

varsubDiv=document.createElement('DIV');

subDiv.innerHTML='+';

subDiv.onclick=changeSelectBoxYear;

subDiv.onmouseover=highlightMonthYear;

subDiv.onmouseout=function(){selectBoxMovementInProgress=false;};

subDiv.onselectstart=cancelCalendarEvent;

div.appendChild(subDiv);

returndiv;

}

/*Thisfunctioncreatesthehourdivatthebottombar*/

functionslideCalendarSelectBox()

{

if(selectBoxMovementInProgress){

if(activeSelectBox.parentNode.id=='hourDropDown'){

changeSelectBoxHour(false,activeSelectBox);

}

if(activeSelectBox.parentNode.id=='yearDropDown'){

changeSelectBoxYear(false,activeSelectBox);

}

}

setTimeout('slideCalendarSelectBox()',speedOfSelectBoxSliding);

}

functioncreateHourDiv()

{

if(!document.getElementById('hourDropDown')){

vardiv=document.createElement('DIV');

div.className='monthYearPicker';

}else{

vardiv=document.getElementById('hourDropDown');

varsubDivs=div.getElementsByTagName('DIV');

for(varno=0;no<subDivs.length;no++){

subDivs[no].parentNode.removeChild(subDivs[no]);

}

}

if(!currentHour)currentHour=0;

varstartHour=currentHour/1;

if(startHour>14)startHour=14;

varsubDiv=document.createElement('DIV');

subDiv.innerHTML='-';

subDiv.onclick=changeSelectBoxHour;

subDiv.onmouseover=highlightMonthYear;

subDiv.onmouseout=function(){selectBoxMovementInProgress=false;};

subDiv.onselectstart=cancelCalendarEvent;

div.appendChild(subDiv);

for(varno=startHour;no<startHour+10;no++){

varprefix='';

if(no/1<10)prefix='0';

varsubDiv=document.createElement('DIV');

subDiv.innerHTML=prefix+no;

subDiv.onmouseover=highlightMonthYear;

subDiv.onmouseout=highlightMonthYear;

subDiv.onclick=selectHour;

subDiv.id='hourDiv'+no;

subDiv.onselectstart=cancelCalendarEvent;

div.appendChild(subDiv);

if(currentYear&¤tYear==no){

subDiv.style.color=selectBoxHighlightColor;

activeSelectBoxYear=subDiv;

}

}

varsubDiv=document.createElement('DIV');

subDiv.innerHTML='+';

subDiv.onclick=changeSelectBoxHour;

subDiv.onmouseover=highlightMonthYear;

subDiv.onmouseout=function(){selectBoxMovementInProgress=false;};

subDiv.onselectstart=cancelCalendarEvent;

div.appendChild(subDiv);

returndiv;

}

/*Thisfunctioncreatestheminutedivatthebottombar*/

functioncreateMinuteDiv()

{

if(!document.getElementById('minuteDropDown')){

vardiv=document.createElement('DIV');

div.className='monthYearPicker';

}else{

vardiv=document.getElementById('minuteDropDown');

varsubDivs=div.getElementsByTagName('DIV');

for(varno=0;no<subDivs.length;no++){

subDivs[no].parentNode.removeChild(subDivs[no]);

}

}

varstartMinute=0;

varprefix='';

for(varno=startMinute;no<60;no+=intervalSelectBox_minutes){

if(no<10)prefix='0';elseprefix='';

varsubDiv=document.createElement('DIV');

subDiv.innerHTML=prefix+no;

subDiv.onmouseover=highlightMonthYear;

subDiv.onmouseout=highlightMonthYear;

subDiv.onclick=selectMinute;

subDiv.id='minuteDiv_'+prefix+no;

subDiv.onselectstart=cancelCalendarEvent;

div.appendChild(subDiv);

if(currentYear&¤tYear==no){

subDiv.style.color=selectBoxHighlightColor;

activeSelectBoxYear=subDiv;

}

}

returndiv;

}

functionhighlightSelect()

{

if(this.className=='selectBoxTime'){

this.className='selectBoxTimeOver';

this.getElementsByTagName('IMG')[0].src=pathToImages+'down_time_over.gif';

}elseif(this.className=='selectBoxTimeOver'){

this.className='selectBoxTime';

this.getElementsByTagName('IMG')[0].src=pathToImages+'down_time.gif';

}

if(this.className=='selectBox'){

this.className='selectBoxOver';

this.getElementsByTagName('IMG')[0].src=pathToImages+'down_over.gif';

}elseif(this.className=='selectBoxOver'){

this.className='selectBox';

this.getElementsByTagName('IMG')[0].src=pathToImages+'down.gif';

}

}

functionhighlightArrow()

{

if(this.src.indexOf('over')>=0){

if(this.src.indexOf('left')>=0)this.src=pathToImages+'left.gif';

if(this.src.indexOf('right')>=0)this.src=pathToImages+'right.gif';

}else{

if(this.src.indexOf('left')>=0)this.src=pathToImages+'left_over.gif';

if(this.src.indexOf('right')>=0)this.src=pathToImages+'right_over.gif';

}

}

functionhighlightClose()

{

if(this.src.indexOf('over')>=0){

this.src=pathToImages+'close.gif';

}else{

this.src=pathToImages+'close_over.gif';

}

}

functioncloseCalendar(){

document.getElementById('yearDropDown').style.display='none';

document.getElementById('monthDropDown').style.display='none';

document.getElementById('hourDropDown').style.display='none';

document.getElementById('minuteDropDown').style.display='none';

calendarDiv.style.display='none';

if(iframeObj){

iframeObj.style.display='none';

////////fixforEIframeproblemontimedropdowns09/30/2006

EIS_Hide_Frame();}

if(activeSelectBoxMonth)activeSelectBoxMonth.className='';

if(activeSelectBoxYear)activeSelectBoxYear.className='';

}

functionwriteTopBar()

{

vartopBar=document.createElement('DIV');

topBar.className='topBar';

topBar.id='topBar';

calendarDiv.appendChild(topBar);

//Leftarrow

varleftDiv=document.createElement('DIV');

leftDiv.style.marginRight='1px';

varimg=document.createElement('IMG');

img.src=pathToImages+'left.gif';

img.onmouseover=highlightArrow;

img.onclick=switchMonth;

img.onmouseout=highlightArrow;

leftDiv.appendChild(img);

topBar.appendChild(leftDiv);

if(Opera)leftDiv.style.width='16px';

//Rightarrow

varrightDiv=document.createElement('DIV');

rightDiv.style.marginRight='1px';

varimg=document.createElement('IMG');

img.src=pathToImages+'right.gif';

img.onclick=switchMonth;

img.onmouseover=highlightArrow;

img.onmouseout=highlightArrow;

rightDiv.appendChild(img);

if(Opera)rightDiv.style.width='16px';

topBar.appendChild(rightDiv);

//Monthselector

varmonthDiv=document.createElement('DIV');

monthDiv.id='monthSelect';

monthDiv.onmouseover=highlightSelect;

monthDiv.onmouseout=highlightSelect;

monthDiv.onclick=showMonthDropDown;

varspan=document.createElement('SPAN');

span.innerHTML=monthArray[currentMonth];

span.id='calendar_month_txt';

monthDiv.appendChild(span);

varimg=document.createElement('IMG');

img.src=pathToImages+'down.gif';

img.style.position='absolute';

img.style.right='0px';

monthDiv.appendChild(img);

monthDiv.className='selectBox';

if(Opera){

img.style.cssText='float:right;position:relative';

img.style.position='relative';

img.style.styleFloat='right';

}

topBar.appendChild(monthDiv);

varmonthPicker=createMonthDiv();

monthPicker.style.left='37px';

monthPicker.style.top=monthDiv.offsetTop+monthDiv.offsetHeight+1+'px';

monthPicker.style.width='60px';

monthPicker.id='monthDropDown';

calendarDiv.appendChild(monthPicker);

//Yearselector

varyearDiv=document.createElement('DIV');

yearDiv.onmouseover=highlightSelect;

yearDiv.onmouseout=highlightSelect;

yearDiv.onclick=showYearDropDown;

varspan=document.createElement('SPAN');

span.innerHTML=currentYear;

span.id='calendar_year_txt';

yearDiv.appendChild(span);

topBar.appendChild(yearDiv);

varimg=document.createElement('IMG');

img.src=pathToImages+'down.gif';

yearDiv.appendChild(img);

yearDiv.className='selectBox';

if(Opera){

yearDiv.style.width='50px';

img.style.cssText='float:right';

img.style.position='relative';

img.style.styleFloat='right';

}

varyearPicker=createYearDiv();

yearPicker.style.left='113px';

yearPicker.style.top=monthDiv.offsetTop+monthDiv.offsetHeight+1+'px';

yearPicker.style.width='35px';

yearPicker.id='yearDropDown';

calendarDiv.appendChild(yearPicker);

varimg=document.createElement('IMG');

img.src=pathToImages+'close.gif';

img.style.styleFloat='right';

img.onmouseover=highlightClose;

img.onmouseout=highlightClose;

img.onclick=closeCalendar;

topBar.appendChild(img);

if(!document.all){

img.style.position='absolute';

img.style.right='2px';

}

}

functionwriteCalendarContent()

{

varcalendarContentDivExists=true;

if(!calendarContentDiv){

calendarContentDiv=document.createElement('DIV');

calendarDiv.appendChild(calendarContentDiv);

calendarContentDivExists=false;

}

currentMonth=currentMonth/1;

vard=newDate();

d.setFullYear(currentYear);

d.setDate(1);

d.setMonth(currentMonth);

vardayStartOfMonth=d.getDay();

if(dayStartOfMonth==0)dayStartOfMonth=7;

dayStartOfMonth--;

document.getElementById('calendar_year_txt').innerHTML=currentYear;

document.getElementById('calendar_month_txt').innerHTML=monthArray[currentMonth];

document.getElementById('calendar_hour_txt').innerHTML=currentHour;

document.getElementById('calendar_minute_txt').innerHTML=currentMinute;

varexistingTable=calendarContentDiv.getElementsByTagName('TABLE');

if(existingTable.length>0){

calendarContentDiv.removeChild(existingTable[0]);

}

varcalTable=document.createElement('TABLE');

calTable.width='100%';

calTable.cellSpacing='0';

calendarContentDiv.appendChild(calTable);

varcalTBody=document.createElement('TBODY');

calTable.appendChild(calTBody);

varrow=calTBody.insertRow(-1);

row.className='calendar_week_row';

varcell=row.insertCell(-1);

cell.innerHTML=weekString;

cell.className='calendar_week_column';

cell.style.backgroundColor=selectBoxRolloverBgColor;

for(varno=0;no<dayArray.length;no++){

varcell=row.insertCell(-1);

cell.innerHTML=dayArray[no];

}

varrow=calTBody.insertRow(-1);

varcell=row.insertCell(-1);

cell.className='calendar_week_column';

cell.style.backgroundColor=selectBoxRolloverBgColor;

varweek=getWeek(currentYear,currentMonth,1);

cell.innerHTML=week;//Week

for(varno=0;no<dayStartOfMonth;no++){

varcell=row.insertCell(-1);

cell.innerHTML='';

}

varcolCounter=dayStartOfMonth;

vardaysInMonth=daysInMonthArray[currentMonth];

if(daysInMonth==28){

if(isLeapYear(currentYear))daysInMonth=29;

}

for(varno=1;no<=daysInMonth;no++){

d.setDate(no-1);

if(colCounter>0&&colCounter%7==0){

varrow=calTBody.insertRow(-1);

varcell=row.insertCell(-1);

cell.className='calendar_week_column';

varweek=getWeek(currentYear,currentMonth,no);

cell.innerHTML=week;//Week

cell.style.backgroundColor=selectBoxRolloverBgColor;

}

varcell=row.insertCell(-1);

if(currentYear==inputYear&¤tMonth==inputMonth&&no==inputDay){

cell.className='activeDay';

}

cell.innerHTML=no;

cell.onclick=pickDate;

colCounter++;

}

if(!document.all){

if(calendarContentDiv.offsetHeight)

document.getElementById('topBar').style.top=calendarContentDiv.offsetHeight+document.getElementById('timeBar').offsetHeight+document.getElementById('topBar').offsetHeight-1+'px';

else{

document.getElementById('topBar').style.top='';

document.getElementById('topBar').style.bottom='0px';

}

}

if(iframeObj){

if(!calendarContentDivExists)setTimeout('resizeIframe()',350);elsesetTimeout('resizeIframe()',10);

}

}

functionresizeIframe()

{

iframeObj.style.width=calendarDiv.offsetWidth+'px';

iframeObj.style.height=calendarDiv.offsetHeight+'px';

}

functionpickTodaysDate()

{

vard=newDate();

currentMonth=d.getMonth();

currentYear=d.getFullYear();

pickDate(false,d.getDate());

}

functionpickDate(e,inputDay)

{

varmonth=currentMonth/1+1;

if(month<10)month='0'+month;

varday;

if(!inputDay&&this)day=this.innerHTML;elseday=inputDay;

if(day/1<10)day='0'+day;

if(returnFormat){

returnFormat=returnFormat.replace('dd',day);

returnFormat=returnFormat.replace('mm',month);

returnFormat=returnFormat.replace('yyyy',currentYear);

returnFormat=returnFormat.replace('hh',currentHour);

returnFormat=returnFormat.replace('ii',currentMinute);

returnFormat=returnFormat.replace('d',day/1);

returnFormat=returnFormat.replace('m',month/1);

returnDateTo.value=returnFormat;

try{

returnDateTo.onchange();

}catch(e){

}

}else{

for(varno=0;no<returnDateToYear.options.length;no++){

if(returnDateToYear.options[no].value==currentYear){

returnDateToYear.selectedIndex=no;

break;

}

}

for(varno=0;no<returnDateToMonth.options.length;no++){

if(returnDateToMonth.options[no].value==month){

returnDateToMonth.selectedIndex=no;

break;

}

}

for(varno=0;no<returnDateToDay.options.length;no++){

if(returnDateToDay.options[no].value==day){

returnDateToDay.selectedIndex=no;

break;

}

}

if(calendarDisplayTime){

for(varno=0;no<returnDateToHour.options.length;no++){

if(returnDateToHour.options[no].value==currentHour){

returnDateToHour.selectedIndex=no;

break;

}

}

for(varno=0;no<returnDateToMinute.options.length;no++){

if(returnDateToMinute.options[no].value==currentMinute){

returnDateToMinute.selectedIndex=no;

break;

}

}

}

}

closeCalendar();

}

//Thisfunctionisfromhttp://www.codeproject.com/csharp/gregorianwknum.asp

//Onlychangedthemonthadd

functiongetWeek(year,month,day){

day=day/1;

year=year/1;

month=month/1+1;//use1-12

vara=Math.floor((14-(month))/12);

vary=year+4800-a;

varm=(month)+(12*a)-3;

varjd=day+Math.floor(((153*m)+2)/5)+

(365*y)+Math.floor(y/4)-Math.floor(y/100)+

Math.floor(y/400)-32045;//(gregoriancalendar)

vard4=(jd+31741-(jd%7))%146097%36524%1461;

varL=Math.floor(d4/1460);

vard1=((d4-L)%365)+L;

NumberOfWeek=Math.floor(d1/7)+1;

returnNumberOfWeek;

}

functionwriteTimeBar()

{

vartimeBar=document.createElement('DIV');

timeBar.id='timeBar';

timeBar.className='timeBar';

varsubDiv=document.createElement('DIV');

subDiv.innerHTML='Time:';

//timeBar.appendChild(subDiv);

//Yearselector

varhourDiv=document.createElement('DIV');

hourDiv.onmouseover=highlightSelect;

hourDiv.onmouseout=highlightSelect;

hourDiv.onclick=showHourDropDown;

hourDiv.style.width='30px';

varspan=document.createElement('SPAN');

span.innerHTML=currentHour;

span.id='calendar_hour_txt';

hourDiv.appendChild(span);

timeBar.appendChild(hourDiv);

varimg=document.createElement('IMG');

img.src=pathToImages+'down_time.gif';

hourDiv.appendChild(img);

hourDiv.className='selectBoxTime';

if(Opera){

hourDiv.style.width='30px';

img.style.cssText='float:right';

img.style.position='relative';

img.style.styleFloat='right';

}

varhourPicker=createHourDiv();

hourPicker.style.left='130px';

//hourPicker.style.top=monthDiv.offsetTop+monthDiv.offsetHeight+1+'px';

hourPicker.style.width='35px';

hourPicker.id='hourDropDown';

calendarDiv.appendChild(hourPicker);

//AddMinutepicker

//Yearselector

varminuteDiv=document.createElement('DIV');

minuteDiv.onmouseover=highlightSelect;

minuteDiv.onmouseout=highlightSelect;

minuteDiv.onclick=showMinuteDropDown;

minuteDiv.style.width='30px';

varspan=document.createElement('SPAN');

span.innerHTML=currentMinute;

span.id='calendar_minute_txt';

minuteDiv.appendChild(span);

timeBar.appendChild(minuteDiv);

varimg=document.createElement('IMG');

img.src=pathToImages+'down_time.gif';

minuteDiv.appendChild(img);

minuteDiv.className='selectBoxTime';

if(Opera){

minuteDiv.style.width='30px';

img.style.cssText='float:right';

img.style.position='relative';

img.style.styleFloat='right';

}

varminutePicker=createMinuteDiv();

minutePicker.style.left='167px';

//minutePicker.style.top=monthDiv.offsetTop+monthDiv.offsetHeight+1+'px';

minutePicker.style.width='35px';

minutePicker.id='minuteDropDown';

calendarDiv.appendChild(minutePicker);

returntimeBar;

}

functionwriteBottomBar()

{

vard=newDate();

varbottomBar=document.createElement('DIV');

bottomBar.id='bottomBar';

bottomBar.style.cursor='pointer';

bottomBar.className='todaysDate';

//vartodayStringFormat='[todayString][dayString][day][monthString][year]';;;

varsubDiv=document.createElement('DIV');

subDiv.onclick=pickTodaysDate;

subDiv.id='todaysDateString';

subDiv.style.width=(calendarDiv.offsetWidth-95)+'px';

varday=d.getDay();

if(day==0)day=7;

day--;

varbottomString=todayStringFormat;

bottomString=bottomString.replace('[monthString]',monthArrayShort[d.getMonth()]);

bottomString=bottomString.replace('[day]',d.getDate());

bottomString=bottomString.replace('[year]',d.getFullYear());

bottomString=bottomString.replace('[dayString]',dayArray[day].toLowerCase());

bottomString=bottomString.replace('[UCFdayString]',dayArray[day]);

bottomString=bottomString.replace('[todayString]',todayString);

subDiv.innerHTML=todayString+':'+d.getDate()+'.'+monthArrayShort[d.getMonth()]+','+d.getFullYear();

subDiv.innerHTML=bottomString;

bottomBar.appendChild(subDiv);

vartimeDiv=writeTimeBar();

bottomBar.appendChild(timeDiv);

calendarDiv.appendChild(bottomBar);

}

functiongetTopPos(inputObj)

{

varreturnValue=inputObj.offsetTop+inputObj.offsetHeight;

while((inputObj=inputObj.offsetParent)!=null)returnValue+=inputObj.offsetTop;

returnreturnValue+calendar_offsetTop;

}

functiongetleftPos(inputObj)

{

varreturnValue=inputObj.offsetLeft;

while((inputObj=inputObj.offsetParent)!=null)returnValue+=inputObj.offsetLeft;

returnreturnValue+calendar_offsetLeft;

}

functionpositionCalendar(inputObj)

{

calendarDiv.style.left=getleftPos(inputObj)+'px';

calendarDiv.style.top=getTopPos(inputObj)+'px';

if(iframeObj){

iframeObj.style.left=calendarDiv.style.left;

iframeObj.style.top=calendarDiv.style.top;

////fixforEIframeproblemontimedropdowns09/30/2006

iframeObj2.style.left=calendarDiv.style.left;

iframeObj2.style.top=calendarDiv.style.top;

}

}

functioninitCalendar()

{

if(MSIE){

iframeObj=document.createElement('IFRAME');

iframeObj.style.filter='alpha(opacity=0)';

iframeObj.style.position='absolute';

iframeObj.border='0px';

iframeObj.style.border='0px';

iframeObj.style.backgroundColor='#FF0000';

////fixforEIframeproblemontimedropdowns09/30/2006

iframeObj2=document.createElement('IFRAME');

iframeObj2.style.position='absolute';

iframeObj2.border='0px';

iframeObj2.style.border='0px';

iframeObj2.style.height='1px';

iframeObj2.style.width='1px';

document.body.appendChild(iframeObj2);

////fixforEIframeproblemontimedropdowns09/30/2006

//AddedfixedforHTTPS

iframeObj2.src='blank.html';

iframeObj.src='blank.html';

document.body.appendChild(iframeObj);

}

calendarDiv=document.createElement('DIV');

calendarDiv.id='calendarDiv';

calendarDiv.style.zIndex=1000;

slideCalendarSelectBox();

document.body.appendChild(calendarDiv);

writeBottomBar();

writeTopBar();

if(!currentYear){

vard=newDate();

currentMonth=d.getMonth();

currentYear=d.getFullYear();

}

writeCalendarContent();

}

functionsetTimeProperties()

{

if(!calendarDisplayTime){

document.getElementById('timeBar').style.display='none';

document.getElementById('timeBar').style.visibility='hidden';

document.getElementById('todaysDateString').style.width='100%';

}else{

document.getElementById('timeBar').style.display='block';

document.getElementById('timeBar').style.visibility='visible';

document.getElementById('hourDropDown').style.top=document.getElementById('calendar_minute_txt').parentNode.offsetHeight+calendarContentDiv.offsetHeight+document.getElementById('topBar').offsetHeight+'px';

document.getElementById('minuteDropDown').style.top=document.getElementById('calendar_minute_txt').parentNode.offsetHeight+calendarContentDiv.offsetHeight+document.getElementById('topBar').offsetHeight+'px';

document.getElementById('minuteDropDown').style.right='50px';

document.getElementById('hourDropDown').style.right='50px';

document.getElementById('todaysDateString').style.width='115px';

}

}

functioncalendarSortItems(a,b)

{

returna/1-b/1;

}

functiondisplayCalendar(inputField,format,buttonObj,displayTime,timeInput)

{

if(displayTime)calendarDisplayTime=true;elsecalendarDisplayTime=false;

if(inputField.value.length>0){

if(!format.match(/^[0-9]*?$/gi)){

varitems=inputField.value.split(/[^0-9]/gi);

varpositionArray=newArray();

positionArray['m']=format.indexOf('mm');

if(positionArray['m']==-1)positionArray['m']=format.indexOf('m');

positionArray['d']=format.indexOf('dd');

if(positionArray['d']==-1)positionArray['d']=format.indexOf('d');

positionArray['y']=format.indexOf('yyyy');

positionArray['h']=format.indexOf('hh');

positionArray['i']=format.indexOf('ii');

varpositionArrayNumeric=Array();

positionArrayNumeric[0]=positionArray['m'];

positionArrayNumeric[1]=positionArray['d'];

positionArrayNumeric[2]=positionArray['y'];

positionArrayNumeric[3]=positionArray['h'];

positionArrayNumeric[4]=positionArray['i'];

positionArrayNumeric=positionArrayNumeric.sort(calendarSortItems);

varitemIndex=-1;

currentHour='00';

currentMinute='00';

for(varno=0;no<positionArrayNumeric.length;no++){

if(positionArrayNumeric[no]==-1)continue;

itemIndex++;

if(positionArrayNumeric[no]==positionArray['m']){

currentMonth=items[itemIndex]-1;

continue;

}

if(positionArrayNumeric[no]==positionArray['y']){

currentYear=items[itemIndex];

continue;

}

if(positionArrayNumeric[no]==positionArray['d']){

tmpDay=items[itemIndex];

continue;

}

if(positionArrayNumeric[no]==positionArray['h']){

currentHour=items[itemIndex];

continue;

}

if(positionArrayNumeric[no]==positionArray['i']){

currentMinute=items[itemIndex];

continue;

}

}

currentMonth=currentMonth/1;

tmpDay=tmpDay/1;

}else{

varmonthPos=format.indexOf('mm');

currentMonth=inputField.value.substr(monthPos,2)/1-1;

varyearPos=format.indexOf('yyyy');

currentYear=inputField.value.substr(yearPos,4);

vardayPos=format.indexOf('dd');

tmpDay=inputField.value.substr(dayPos,2);

varhourPos=format.indexOf('hh');

if(hourPos>=0){

tmpHour=inputField.value.substr(hourPos,2);

currentHour=tmpHour;

}else{

currentHour='00';

}

varminutePos=format.indexOf('ii');

if(minutePos>=0){

tmpMinute=inputField.value.substr(minutePos,2);

currentMinute=tmpMinute;

}else{

currentMinute='00';

}

}

}else{

vard=newDate();

currentMonth=d.getMonth();

currentYear=d.getFullYear();

currentHour='08';

currentMinute='00';

tmpDay=d.getDate();

}

inputYear=currentYear;

inputMonth=currentMonth;

inputDay=tmpDay/1;

if(!calendarDiv){

initCalendar();

}else{

if(calendarDiv.style.display=='block'){

closeCalendar();

returnfalse;

}

writeCalendarContent();

}

returnFormat=format;

returnDateTo=inputField;

positionCalendar(buttonObj);

calendarDiv.style.visibility='visible';

calendarDiv.style.display='block';

if(iframeObj){

iframeObj.style.display='';

iframeObj.style.height='140px';

iframeObj.style.width='195px';

iframeObj2.style.display='';

iframeObj2.style.height='140px';

iframeObj2.style.width='195px';

}

setTimeProperties();

updateYearDiv();

updateMonthDiv();

updateMinuteDiv();

updateHourDiv();

}

functiondisplayCalendarSelectBox(yearInput,monthInput,dayInput,hourInput,minuteInput,buttonObj)

{

if(!hourInput)calendarDisplayTime=false;elsecalendarDisplayTime=true;

currentMonth=monthInput.options[monthInput.selectedIndex].value/1-1;

currentYear=yearInput.options[yearInput.selectedIndex].value;

if(hourInput){

currentHour=hourInput.options[hourInput.selectedIndex].value;

inputHour=currentHour/1;

}

if(minuteInput){

currentMinute=minuteInput.options[minuteInput.selectedIndex].value;

inputMinute=currentMinute/1;

}

inputYear=yearInput.options[yearInput.selectedIndex].value;

inputMonth=monthInput.options[monthInput.selectedIndex].value/1-1;

inputDay=dayInput.options[dayInput.selectedIndex].value/1;

if(!calendarDiv){

initCalendar();

}else{

writeCalendarContent();

}

returnDateToYear=yearInput;

returnDateToMonth=monthInput;

returnDateToDay=dayInput;

returnDateToHour=hourInput;

returnDateToMinute=minuteInput;

returnFormat=false;

returnDateTo=false;

positionCalendar(buttonObj);

calendarDiv.style.visibility='visible';

calendarDiv.style.display='block';

if(iframeObj){

iframeObj.style.display='';

iframeObj.style.height=calendarDiv.offsetHeight+'px';

iframeObj.style.width=calendarDiv.offsetWidth+'px';

////fixforEIframeproblemontimedropdowns09/30/2006

iframeObj2.style.display='';

iframeObj2.style.height=calendarDiv.offsetHeight+'px';

iframeObj2.style.width=calendarDiv.offsetWidth+'px'

}

setTimeProperties();

updateYearDiv();

updateMonthDiv();

updateHourDiv();

updateMinuteDiv();

}

打包文件下载

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类