?? popcalendar.js
字號:
else { txtYear = " " + newYear + " " } document.getElementById("y"+i).innerHTML = txtYear } nStartingYear --; bShow=true } function selectYear(nYear) { yearSelected=parseInt(nYear+nStartingYear); yearConstructed=false; constructCalendar(); popDownYear(); } function constructYear() { popDownMonth() sHTML = "" if (!yearConstructed) { sHTML = "<tr><td align='center' onmouseover='this.className=\"dropdown-select-style\"' onmouseout='clearInterval(intervalID1);this.className=\"dropdown-normal-style\"' onmousedown='clearInterval(intervalID1);intervalID1=setInterval(\"decYear()\",30)' onmouseup='clearInterval(intervalID1)'>-</td></tr>" j = 0 nStartingYear = yearSelected-3 for (i=(yearSelected-3); i<=(yearSelected+3); i++) { sName = i; if (i==yearSelected){ sName = "<B>" + sName + "</B>" } sHTML += "<tr><td id='y" + j + "' onmouseover='this.className=\"dropdown-select-style\"' onmouseout='this.className=\"dropdown-normal-style\"' onclick='selectYear("+j+");event.cancelBubble=true'> " + sName + " </td></tr>" j ++; } sHTML += "<tr><td align='center' onmouseover='this.className=\"dropdown-select-style\"' onmouseout='clearInterval(intervalID2);this.className=\"dropdown-normal-style\"' onmousedown='clearInterval(intervalID2);intervalID2=setInterval(\"incYear()\",30)' onmouseup='clearInterval(intervalID2)'>+</td></tr>" document.getElementById("selectYear").innerHTML = "<table width=44 class='dropdown-style' onmouseover='clearTimeout(timeoutID2)' onmouseout='clearTimeout(timeoutID2);timeoutID2=setTimeout(\"popDownYear()\",100)' cellspacing=0>" + sHTML + "</table>" yearConstructed = true } } function popDownYear() { clearInterval(intervalID1) clearTimeout(timeoutID1) clearInterval(intervalID2) clearTimeout(timeoutID2) crossYearObj.visibility= "hidden" } function popUpYear() { var leftOffset constructYear() crossYearObj.visibility = (dom||ie)? "visible" : "show" leftOffset = parseInt(crossobj.left) + document.getElementById("spanYear").offsetLeft if (ie) { leftOffset += 6 } crossYearObj.left = leftOffset crossYearObj.top = parseInt(crossobj.top) + 26 } /*** calendar ***/ function WeekNbr(today) { Year = takeYear(today); Month = today.getMonth(); Day = today.getDate(); now = Date.UTC(Year,Month,Day+1,0,0,0); var Firstday = new Date(); Firstday.setYear(Year); Firstday.setMonth(0); Firstday.setDate(1); then = Date.UTC(Year,0,1,0,0,0); var Compensation = Firstday.getDay(); if (Compensation > 3) Compensation -= 4; else Compensation += 3; NumberOfWeek = Math.round((((now-then)/86400000)+Compensation)/7); return NumberOfWeek; } function takeYear(theDate) { x = theDate.getYear(); var y = x % 100; y += (y < 38) ? 2000 : 1900; return y; } function constructCalendar () { var dateMessage var startDate = new Date (yearSelected,monthSelected,1) var endDate = new Date (yearSelected,monthSelected+1,1); endDate = new Date (endDate - (24*60*60*1000)); numDaysInMonth = endDate.getDate() datePointer = 0 dayPointer = startDate.getDay() - startAt if (dayPointer<0) { dayPointer = 6 } sHTML = "<table border=0 class='body-style'><tr>" if (showWeekNumber==1) { sHTML += "<td width=27><b>" + weekString + "</b></td><td width=1 rowspan=7 class='weeknumber-div-style'><img src='"+imgDir+"divider.gif' width=1></td>" } for (i=0; i<7; i++) { sHTML += "<td width='27' align='right'><B>"+ dayName[i]+"</B></td>" } sHTML +="</tr><tr>" if (showWeekNumber==1) { sHTML += "<td align=right>" + WeekNbr(startDate) + " </td>" } for ( var i=1; i<=dayPointer;i++ ) { sHTML += "<td> </td>" } for ( datePointer=1; datePointer<=numDaysInMonth; datePointer++ ) { dayPointer++; sHTML += "<td align=right>" var sStyle="normal-day-style"; //regular day if ((datePointer==dateNow)&&(monthSelected==monthNow)&&(yearSelected==yearNow)) //today { sStyle = "current-day-style"; } else if (dayPointer % 7 == (startAt * -1) +1) //end-of-the-week day { sStyle = "end-of-weekday-style"; } //selected day if ((datePointer==odateSelected) && (monthSelected==omonthSelected) && (yearSelected==oyearSelected)) { sStyle += " selected-day-style"; } sHint = "" for (k=0;k<HolidaysCounter;k++) { if ((parseInt(Holidays[k].d)==datePointer)&&(parseInt(Holidays[k].m)==(monthSelected+1))) { if ((parseInt(Holidays[k].y)==0)||((parseInt(Holidays[k].y)==yearSelected)&&(parseInt(Holidays[k].y)!=0))) { sStyle += " holiday-style"; sHint+=sHint==""?Holidays[k].desc:"\n"+Holidays[k].desc } } } var regexp= /\"/g sHint=sHint.replace(regexp,""") dateMessage = "onmousemove='window.status=\""+selectDateMessage.replace("[date]",constructDate(datePointer,monthSelected,yearSelected))+"\"' onmouseout='window.status=\"\"' " sHTML += "<a class='"+sStyle+"' "+dateMessage+" title=\"" + sHint + "\" href='javascript:dateSelected="+datePointer+";closeCalendar();'> " + datePointer + " </a>" sHTML += "" if ((dayPointer+startAt) % 7 == startAt) { sHTML += "</tr><tr>" if ((showWeekNumber==1)&&(datePointer<numDaysInMonth)) { sHTML += "<td align=right>" + (WeekNbr(new Date(yearSelected,monthSelected,datePointer+1))) + " </td>" } } } document.getElementById("content").innerHTML = sHTML document.getElementById("spanMonth").innerHTML = " " + monthName[monthSelected] + " <IMG id='changeMonth' SRC='"+imgDir+"drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>" document.getElementById("spanYear").innerHTML = " " + yearSelected + " <IMG id='changeYear' SRC='"+imgDir+"drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>" } function popUpCalendar(ctl, ctl2, format) { var leftpos=0 var toppos=0 if (bPageLoaded) { if ( crossobj.visibility == "hidden" ) { ctlToPlaceValue = ctl2 dateFormat=format; formatChar = " " aFormat = dateFormat.split(formatChar) if (aFormat.length<3) { formatChar = "/" aFormat = dateFormat.split(formatChar) if (aFormat.length<3) { formatChar = "." aFormat = dateFormat.split(formatChar) if (aFormat.length<3) { formatChar = "-" aFormat = dateFormat.split(formatChar) if (aFormat.length<3) { // invalid date format formatChar="" } } } } tokensChanged = 0 if ( formatChar != "" ) { // use user's date aData = ctl2.value.split(formatChar) for (i=0;i<3;i++) { if ((aFormat[i]=="d") || (aFormat[i]=="dd")) { dateSelected = parseInt(aData[i], 10) tokensChanged ++ } else if ((aFormat[i]=="m") || (aFormat[i]=="mm")) { monthSelected = parseInt(aData[i], 10) - 1 tokensChanged ++ } else if (aFormat[i]=="yyyy") { yearSelected = parseInt(aData[i], 10) tokensChanged ++ } else if (aFormat[i]=="mmm") { for (j=0; j<12; j++) { if (aData[i]==monthName[j]) { monthSelected=j tokensChanged ++ } } } } } if ((tokensChanged!=3)||isNaN(dateSelected)||isNaN(monthSelected)||isNaN(yearSelected)) { dateSelected = dateNow monthSelected = monthNow yearSelected = yearNow } odateSelected=dateSelected omonthSelected=monthSelected oyearSelected=yearSelected aTag = ctl do { aTag = aTag.offsetParent; leftpos += aTag.offsetLeft; toppos += aTag.offsetTop; } while(aTag.tagName!="BODY"); crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 : fixedY constructCalendar (1, monthSelected, yearSelected); crossobj.visibility=(dom||ie)? "visible" : "show" hideElement( 'SELECT', document.getElementById("calendar") ); hideElement( 'APPLET', document.getElementById("calendar") ); bShow = true; } } else { init() popUpCalendar(ctl, ctl2, format) } } document.onkeypress = function hidecal1 () { if (event.keyCode==27) { hideCalendar() } } document.onclick = function hidecal2 () { if (!bShow) { hideCalendar() } bShow = false }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -