📄 popcalendar.js
字号:
var objPopCalendar = null
var objPopCalList = []
var lPopCalList = -1
function getCalendarInstance()
{
objPopCalendar = new PoPCalCreateCalendarInstance()
if (!objPopCalendar.ns4)
{
if (objPopCalendar.dom)
{
++lPopCalList
document.write ("<div id='CalendarInstanceCreated" + lPopCalList + "' Style='display:none'></div>")
objPopCalendar.calendarInstance = document.getElementById("CalendarInstanceCreated" + lPopCalList)
if (objPopCalendar.calendarInstance!=null)
{
if (objPopCalendar.ie)
{
objPopCalendar.calendarInstance.style.filter="alpha()"
objPopCalendar.calendarInstance.style.filter="blendTrans()"
}
objPopCalendar.calendarInstance.initialized = 0
}
objPopCalendar.id = lPopCalList
objPopCalendar.initCalendar = new Function("objPopCalendar=objPopCalList[" + lPopCalList + "];PopCalInitCalendar()")
objPopCalendar.show = new Function("ctl", "format", "from", "to", "execute", "overwrite", "objPopCalendar=objPopCalList[" + lPopCalList + "];PopCalShow(ctl, format, from, to, execute, overwrite);")
objPopCalendar.addHoliday = new Function("d", "m", "y", "desc0", "desc1", "objPopCalendar=objPopCalList[" + lPopCalList + "];PopCalAddHoliday(d, m, y, desc0, desc1);")
objPopCalendar.addSpecialDay = new Function("d", "m", "y", "desc0", "desc1", "objPopCalendar=objPopCalList[" + lPopCalList + "];PopCalAddSpecialDay(d, m, y, desc0, desc1);")
objPopCalendar.formatDate = PopCalFormatDate
objPopCalendar.forcedToday = new Function("dateValue", "format", "objPopCalendar=objPopCalList[" + lPopCalList + "];PopCalForcedToday(dateValue, format);")
objPopCalendar.getDate = PopCalGetDate
objPopCalendar.selectWeekendHoliday = new Function("weekend", "holidays", "objPopCalendar=objPopCalList[" + lPopCalList + "];PopCalSelectWeekendHoliday(weekend, holidays);")
objPopCalendar.scroll = new Function("objPopCalendar=objPopCalList[" + lPopCalList + "];PopCalScroll();")
objPopCalendar.hide = new Function("objPopCalendar=objPopCalList[" + lPopCalList + "];PopCalHideCalendar();")
objPopCalList[lPopCalList] = objPopCalendar
}
}
return (objPopCalendar)
}
function PoPCalCreateCalendarInstance()
{
this.id = 0
this.startAt = 0 // 0 - sunday, 1 - monday
this.showWeekNumber = 0 // 0 - don't show, 1 - show
this.showTime = 1 // 0 - don't show, 1 - show
this.showToday = 1 // 0 - don't show, 1 - show
this.showWeekend = 0 // 0 - don't show, 1 - show
this.showHolidays = 1 // 0 - don't show, 1 - show
this.showSpecialDay = 1 // 0 - don't show, 1 - show
this.selectWeekend = 1 // 0 - don't Select, 1 - Select
this.selectHoliday = 1 // 0 - don't Select, 1 - Select
this.addCarnival = 0 // 0 - don't Add, Add to Holiday (Tuesday)
this.addGoodFriday = 0 // 0 - don't Add, Add to Holiday
this.language = 0 // 0 - Chinese, 1 - English
this.defaultFormat = "yyyy-mm-dd" //Default Format
this.fixedX = -1 // x position (-1 if to appear below control)
this.fixedY = -1 // y position (-1 if to appear below control)
this.fade = 0 // 0 - don't fade, .1 to 1 - fade (Only IE)
this.shadow = 0 // 0 - don't shadow, 1 - shadow
this.move = 0 // 0 - don't move, 1 - move
this.saveMovePos = 0 // 0 - don't save, 1 - save
this.centuryLimit = 40 // 1940 - 2039
this.GXLink = 0
this.showEndOfWeek = null // compatibility version 2.0
this.selectEndOfWeek = null // compatibility version 2.0
this.executeFade = true
this.forceTodayTo = null
this.forceTodayFormat = null
this.overWriteSelectWeekend = null
this.overWriteSelectHoliday = null
this.overWriteWeekend = null
this.overWriteHoliday = null
this.imgDir = "Images/" // directory for images ... e.g. var imgDir="/img/"
this.gotoString = ""
this.todayString = ""
this.weekString = ""
this.scrollLeftMessage = ""
this.scrollRightMessage = ""
this.selectMonthMessage = ""
this.selectYearMessage = ""
this.selectDateMessage = ""
this.crossobj = null
this.crossShadowRObj = null
this.crossShadowBObj = null
this.crossMonthObj = null
this.crossYearObj = null
this.monthSelected = null
this.yearSelected = null
this.dateSelected = null
this.timeSelected = null
this.omonthSelected = null
this.oyearSelected = null
this.odateSelected = null
this.monthConstructed = null
this.yearConstructed = null
this.intervalID1 = null
this.intervalID2 = null
this.timeoutID1 = null
this.timeoutID2 = null
this.timeoutID3 = null
this.ctlToPlaceValue = null
this.ctlNow = null
this.dateFormat = null
this.nStartingYear = null
this.onKeyPress = null
this.onClick = null
this.onSelectStart = null
this.onContextMenu = null
this.onmousemove = null
this.onmouseup = null
this.onresize = null
this.onscroll = null
this.ie = false
this.ieVersion = 0
this.dom = document.getElementById
this.ns4 = document.layers
this.opera = navigator.userAgent.indexOf("Opera") != -1
if (!this.opera)
{
this.ie = document.all
var ms = navigator.appVersion.indexOf("MSIE")
if (ms>0)
{
this.ieVersion = parseFloat(navigator.appVersion.substring(ms+5, ms+8))
}
}
this.dateFrom = 01
this.monthFrom = 00
this.yearFrom = 1900
this.dateUpTo = 31
this.monthUpTo = 11
this.yearUpTo = 2099
this.oDate = null
this.oMonth = null
this.oYear = null
this.countMonths = 12
this.today = null
this.dayNow = 0
this.dateNow = 0
this.monthNow = 0
this.yearNow = 0
this.defaultX = 0
this.defaultY = 0
this.keepMonth = false
this.keepYear = false
this.bShow = false
this.PopCalTimeOut = null
this.PopCalDragClose = false
this.HalfYearList = 4
this.HolidaysCounter = 0
this.Holidays = new Array()
this.movePopCal = false
this.styleAnchor="text-decoration:none;color:black;cursor:default;"
this.styleLightBorder="border-style:solid;border-width:1px;border-color:#a0a0a0;" //选择框颜色
this.commandExecute = null
this.calendarInstance = null
}
function PopCalCommonComponents()
{
document.write ("<div id='popupSuperShadowRight' style='z-index:+10000;position:absolute;top:0;left:0;font-size:10px;width:10;visibility:hidden;background-color:black;'></div>")
document.write ("<div id='popupSuperShadowBottom' style='z-index:+10000;position:absolute;top:0;left:0;font-size:10px;height:10;visibility:hidden;background-color:black'></div>")
document.write ("<div id='popupSuperMonth' style='z-index:+10000;position:absolute;top:0;left:0;display:none;' onclick='objPopCalendar.bShow=true;'></div>")
document.write ("<div id='popupSuperYear' style='z-index:+10000;position:absolute;top:0;left:0;display:none;' onclick='objPopCalendar.bShow=true;' onMouseWheel='PopCalWheelYear()'></div>")
}
function PopCalInitCalendar()
{
var PopCal=PopCalInstanceCreated()
if (PopCal)
{
if (PopCal.initialized==0)
{
if ((objPopCalendar.language > 1) || (objPopCalendar.language < 0))
{
objPopCalendar.language = 0
}
if (objPopCalendar.showEndOfWeek!=null) // compatibility
{
objPopCalendar.showWeekend = objPopCalendar.showEndOfWeek
}
if (objPopCalendar.selectEndOfWeek!=null) // compatibility
{
objPopCalendar.selectWeekend = objPopCalendar.selectEndOfWeek
}
if ((objPopCalendar.centuryLimit < 0) || (objPopCalendar.centuryLimit > 99))
{
objPopCalendar.centuryLimit = 40
}
document.write ("<div id='popupSuperCalendar" + objPopCalendar.id + "' onclick='PopCalDownMonth();PopCalDownYear();objPopCalendar.bShow=true;' style='z-index:+1000;position:absolute;top:0;left:0;visibility:hidden;background-color:#ffffff'><table id='popupSuperHighLight" + objPopCalendar.id + "' width="+((objPopCalendar.showWeekNumber==1)?250:220)+" style='font-family:arial;font-size:11px;border-width:1;border-style:solid;border-color:#a0a0a0;font-family:arial; font-size:11px}' bgcolor='#ffffff'><tr bgcolor='#0650D2'><td Style='cursor:default'><table width='"+((objPopCalendar.showWeekNumber==1)?248:218)+"'><tr><td style='padding:2px;font-family:arial; font-size:11px;cursor:default' nowrap><font color='#ffffff'><span id='popupSuperCaption" + objPopCalendar.id + "'></span></font></td><td id='popupSuperMoveCalendar" + objPopCalendar.id + "' width='1px'></td><td align=right Style='cursor:default'><Span onClick='ImgCloseBoton" + objPopCalendar.id + ".src=\""+ objPopCalendar.imgDir + "Calendar_Close.gif\";objPopCalendar.PopCalTimeOut=window.setTimeout(\"window.clearTimeout(objPopCalendar.PopCalTimeOut);objPopCalendar.PopCalTimeOut=null;PopCalHideCalendar()\",100)'><IMG ID='ImgCloseBoton" + objPopCalendar.id + "' SRC='"+objPopCalendar.imgDir+"Calendar_Close.gif' onMouseOver='if(objPopCalendar.PopCalDragClose){this.src=\""+ objPopCalendar.imgDir + "Calendar_Closed.gif\"}' onMouseDown='this.src=\""+ objPopCalendar.imgDir + "Calendar_Closed.gif\"' onMouseUp='this.src=\""+ objPopCalendar.imgDir + "Calendar_Close.gif\"' onMouseOut='this.src=\""+ objPopCalendar.imgDir + "Calendar_Close.gif\"' onDrag='objPopCalendar.PopCalDragClose=true;return(false)' WIDTH='15' HEIGHT='13' BORDER='0'></Span></td></tr></table></td></tr><tr><td style='padding:5px;cursor:default' bgcolor=#ffffff><span id='popupSuperContent" + objPopCalendar.id + "'></span></td></tr>")
if (objPopCalendar.showTime==1)
{
document.write ("<tr bgcolor=#f0f0f0><td style='padding:5px;cursor:default' align=center><span id='popupSuperTime" + objPopCalendar.id + "'></span></td></tr>")
}
if (objPopCalendar.showToday==1)
{
document.write ("<tr bgcolor=#f0f0f0><td style='padding:5px;cursor:default' align=center><span id='popupSuperToday" + objPopCalendar.id + "'></span></td></tr>")
}
document.write ("</table></div>")
if (objPopCalendar.language == 0)
{
objPopCalendar.monthName = new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月")
if (objPopCalendar.startAt==0)
{
objPopCalendar.dayName = new Array ("周日","周一","周二","周三","周四","周五","周六")
}
else
{
objPopCalendar.dayName = new Array ("周一","周二","周三","周四","周五","周六","周日")
}
objPopCalendar.gotoString = "当前月"
objPopCalendar.weekString = "周"
objPopCalendar.scrollLeftMessage = "上个月"
objPopCalendar.scrollRightMessage = "下个月"
objPopCalendar.selectMonthMessage = "选取月"
objPopCalendar.selectYearMessage = "选取年"
objPopCalendar.selectDateMessage = "选取 [date]" // do not replace [date], it will be replaced by date.
}
else
{
objPopCalendar.monthName = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
if (objPopCalendar.startAt==0)
{
objPopCalendar.dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
}
else
{
objPopCalendar.dayName = new Array ("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")
}
objPopCalendar.gotoString = "Current Month"
objPopCalendar.weekString = "Week"
objPopCalendar.scrollLeftMessage = "Previous Month."
objPopCalendar.scrollRightMessage = "Next Month."
objPopCalendar.selectMonthMessage = "Select Month."
objPopCalendar.selectYearMessage = "Select Year."
objPopCalendar.selectDateMessage = "Select [date] ." // do not replace [date], it will be replaced by date.
}
objPopCalendar.today = new Date()
if (objPopCalendar.forceTodayTo!=null)
{
if (objPopCalendar.forceTodayFormat==null)
{
objPopCalendar.forceTodayFormat = objPopCalendar.defaultFormat
}
if (PopCalSetDMY(objPopCalendar.forceTodayTo, objPopCalendar.forceTodayFormat))
{
objPopCalendar.today = new Date(objPopCalendar.oYear, objPopCalendar.oMonth, objPopCalendar.oDate)
}
}
objPopCalendar.dayNow = objPopCalendar.today.getDay()
objPopCalendar.dateNow = objPopCalendar.today.getDate()
objPopCalendar.monthNow = objPopCalendar.today.getMonth()
objPopCalendar.yearNow = objPopCalendar.today.getFullYear()
if (objPopCalendar.language == 0)
{
objPopCalendar.todayString = "今天是" + objPopCalendar.dayName[(objPopCalendar.dayNow-objPopCalendar.startAt==-1)?6:(objPopCalendar.dayNow-objPopCalendar.startAt)]+ "," + objPopCalendar.yearNow + "年" + (objPopCalendar.monthNow + 1) + "月" + objPopCalendar.dateNow + "日"
}
else
{
objPopCalendar.todayString = "Today is " + objPopCalendar.dayName[(objPopCalendar.dayNow-objPopCalendar.startAt==-1)?6:(objPopCalendar.dayNow-objPopCalendar.startAt)]+ ", " + objPopCalendar.monthName[objPopCalendar.monthNow] + " " + objPopCalendar.dateNow + ", " + objPopCalendar.yearNow
}
objPopCalendar.crossShadowRObj = (objPopCalendar.dom)?document.getElementById("popupSuperShadowRight").style : objPopCalendar.ie? document.all.popupSuperShadowRight : document.popupSuperShadowRight
objPopCalendar.crossShadowBObj = (objPopCalendar.dom)?document.getElementById("popupSuperShadowBottom").style : objPopCalendar.ie? document.all.popupSuperShadowBottom : document.popupSuperShadowBottom
if(objPopCalendar.ie)
{
objPopCalendar.crossShadowRObj.filter="alpha(opacity=50)"
objPopCalendar.crossShadowBObj.filter="alpha(opacity=50)"
}
else
{
objPopCalendar.crossShadowRObj.MozOpacity=.5
objPopCalendar.crossShadowBObj.MozOpacity=.5
}
objPopCalendar.crossobj = (objPopCalendar.dom)?document.getElementById("popupSuperCalendar" + objPopCalendar.id).style : objPopCalendar.ie? eval("document.all.popupSuperCalendar" + objPopCalendar.id) : eval("document.popupSuperCalendar" + objPopCalendar.id)
if (objPopCalendar.ie)
{
objPopCalendar.crossobj.filter="blendTrans()"
}
objPopCalendar.crossMonthObj=(objPopCalendar.dom)?document.getElementById("popupSuperMonth").style : objPopCalendar.ie? document.all.popupSuperMonth : document.popupSuperMonth
objPopCalendar.crossYearObj=(objPopCalendar.dom)?document.getElementById("popupSuperYear").style : objPopCalendar.ie? document.all.popupSuperYear : document.popupSuperYear
objPopCalendar.monthConstructed=false
objPopCalendar.yearConstructed=false
if (objPopCalendar.showTime==1)
{
document.getElementById("popupSuperTime" + objPopCalendar.id).innerHTML = "<Span>TEST</Span>"
}
if (objPopCalendar.showToday==1)
{
document.getElementById("popupSuperToday" + objPopCalendar.id).innerHTML = "<Span onmouseover='window.status=\""+objPopCalendar.gotoString+"\"' onmouseout='window.status=\"\"' title='"+objPopCalendar.gotoString+"' style='"+objPopCalendar.styleAnchor+"Font-Size:9pt;' onClick='PopCalChangeCurrentMonth();'>" + objPopCalendar.todayString + "</Span>"
}
var sHTML1="<span id='popupSuperSpanLeft" + objPopCalendar.id + "' style='border-style:solid;border-width:1;border-color:0099FF;cursor:default;' onDrag='return(false)' onmouseover='PopCalSwapImage(\"popupSuperChangeLeft" + objPopCalendar.id + "\",\"Calendar_Left2.gif\");this.style.borderColor=\"#99CCFF\";window.status=\""+objPopCalendar.scrollLeftMessage+"\"' onmouseout='clearInterval(objPopCalendar.intervalID1);PopCalSwapImage(\"popupSuperChangeLeft" + objPopCalendar.id + "\",\"Calendar_Left1.gif\");this.style.borderColor=\"0099FF\";window.status=\"\"' onclick='PopCalDecMonth()' onmousedown='clearTimeout(objPopCalendar.timeoutID1);objPopCalendar.timeoutID1=setTimeout(\"PopCalStartDecMonth()\",100)' onmouseup='clearTimeout(objPopCalendar.timeoutID1);clearInterval(objPopCalendar.intervalID1)'> <IMG id='popupSuperChangeLeft" + objPopCalendar.id + "' SRC='"+objPopCalendar.imgDir+"Calendar_Left1.gif' width=10 height=11 border=0> </span> "
sHTML1+="<span id='popupSuperSpanRight" + objPopCalendar.id + "' style='border-style:solid;border-width:1;border-color:0099FF;cursor:default;' onDrag='return(false)' onmouseover='PopCalSwapImage(\"popupSuperChangeRight" + objPopCalendar.id + "\",\"Calendar_Right2.gif\");this.style.borderColor=\"#99CCFF\";window.status=\""+objPopCalendar.scrollRightMessage+"\"' onmouseout='clearInterval(objPopCalendar.intervalID1);PopCalSwapImage(\"popupSuperChangeRight" + objPopCalendar.id + "\",\"Calendar_Right1.gif\");this.style.borderColor=\"0099FF\";window.status=\"\"' onclick='PopCalIncMonth()' onmousedown='clearTimeout(objPopCalendar.timeoutID1);objPopCalendar.timeoutID1=setTimeout(\"PopCalStartIncMonth()\",100)' onmouseup='clearTimeout(objPopCalendar.timeoutID1);clearInterval(objPopCalendar.intervalID1)'> <IMG id='popupSuperChangeRight" + objPopCalendar.id + "' SRC='"+objPopCalendar.imgDir+"Calendar_Right1.gif' width=10 height=11 border=0> </span> "
sHTML1+="<span id='popupSuperSpanMonth" + objPopCalendar.id + "' style='border-style:solid;border-width:1;border-color:0099FF;cursor:default;' onDrag='return(false)' onmouseover='PopCalSwapImage(\"popupSuperChangeMonth" + objPopCalendar.id + "\",\"Calendar_Drop2.gif\");this.style.borderColor=\"#99CCFF\";window.status=\""+objPopCalendar.selectMonthMessage+"\"' onmouseout='PopCalSwapImage(\"popupSuperChangeMonth" + objPopCalendar.id + "\",\"Calendar_Drop1.gif\");this.style.borderColor=\"0099FF\";window.status=\"\"' onclick='objPopCalendar.keepMonth=!PopCalIsVisible(objPopCalendar.crossMonthObj);PopCalUpMonth()'></span> "
sHTML1+="<span id='popupSuperSpanYear" + objPopCalendar.id + "' style='border-style:solid;border-width:1;border-color:0099FF;cursor:default;' onDrag='return(false)' onmouseover='PopCalSwapImage(\"popupSuperChangeYear" + objPopCalendar.id + "\",\"Calendar_Drop2.gif\");this.style.borderColor=\"#99CCFF\";window.status=\""+objPopCalendar.selectYearMessage+"\"' onmouseout='PopCalSwapImage(\"popupSuperChangeYear" + objPopCalendar.id + "\",\"Calendar_Drop1.gif\");this.style.borderColor=\"0099FF\";window.status=\"\"' onclick='objPopCalendar.keepYear=!PopCalIsVisible(objPopCalendar.crossYearObj);PopCalUpYear()' onMouseWheel='PopCalWheelYear()'></span> "
document.getElementById("popupSuperCaption" + objPopCalendar.id).innerHTML = sHTML1
if (objPopCalendar.ie)
{
if (objPopCalendar.move == 1)
{
var superMoveCalendar = document.getElementById("popupSuperMoveCalendar" + objPopCalendar.id)
superMoveCalendar.width="100%"
superMoveCalendar.onmousedown=PopCalDrag
superMoveCalendar.ondblclick=PopCalMoveDefault
superMoveCalendar.onmouseup=PopCalDrop
}
}
PopCalAddRegularHolidays()
PopCal.startAt = objPopCalendar.startAt
PopCal.showWeekNumber = objPopCalendar.showWeekNumber
PopCal.showTime = objPopCalendar.showTime
PopCal.showToday = objPopCalendar.showToday
PopCal.showWeekend = objPopCalendar.showWeekend
PopCal.showHolidays = objPopCalendar.showHolidays
PopCal.showSpecialDay = objPopCalendar.showSpecialDay
PopCal.selectWeekend = objPopCalendar.selectWeekend
PopCal.selectHoliday = objPopCalendar.selectHoliday
PopCal.addCarnival = objPopCalendar.addCarnival
PopCal.addGoodFriday = objPopCalendar.addGoodFriday
PopCal.language = objPopCalendar.language
PopCal.defaultFormat = objPopCalendar.defaultFormat
PopCal.fixedX = objPopCalendar.fixedX
PopCal.fixedY = objPopCalendar.fixedY
PopCal.fade = objPopCalendar.fade
PopCal.shadow = objPopCalendar.shadow
PopCal.centuryLimit = objPopCalendar.centuryLimit
PopCal.move = objPopCalendar.move
PopCal.saveMovePos = objPopCalendar.saveMovePos
PopCal.GXLink = objPopCalendar.GXLink
PopCal.Elements = []
PopCal.LoadElements = -1
PopCal.popupSuperCalendar = document.getElementById("popupSuperCalendar" + objPopCalendar.id)
PopCal.popupSuperShadowRight = document.getElementById("popupSuperShadowRight")
PopCal.popupSuperShadowBottom = document.getElementById("popupSuperShadowBottom")
PopCal.popupSuperMonth = document.getElementById("popupSuperMonth")
PopCal.popupSuperYear = document.getElementById("popupSuperYear")
PopCal.popupSuperYearList = []
if(objPopCalendar.ie)
{
if ((objPopCalendar.ieVersion < 5.5) || (typeof(PopCal.filters)!="object"))
{
PopCal.fade = 0
}
}
PopCal.initialized = 1
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -