📄 scw.js
字号:
if (scwDisabledDates[i].length != 2) { if (scwShowRangeDisablingError) alert(scwRangeDisablingError[0] + scwDisabledDates[i] + scwRangeDisablingError[1]); scwPass = false; } else { for (var j = 0; j < scwDisabledDates[i].length; j++) { if (!((typeof scwDisabledDates[i][j] == 'object') && (scwDisabledDates[i][j].constructor == Date))) { if (scwShowRangeDisablingError) alert(scwDateDisablingError[0] + scwDisabledDates[i][j] + scwDateDisablingError[1]); scwPass = false; } } } if (scwPass && (scwDisabledDates[i][0] > scwDisabledDates[i][1]) ) { scwDisabledDates[i].reverse(); } } else { if (scwShowRangeDisablingError) alert(scwDateDisablingError[0] + scwDisabledDates[i] + scwDateDisablingError[1]); } } } // Calculate the number of months that the entered (or // defaulted) month is after the start of the allowed // date range. scwMonthSum = 12 * (scwSeedDate.getFullYear() - scwBaseYear) + scwSeedDate.getMonth(); // Set the drop down boxes. scwID('scwYears').options.selectedIndex = Math.floor(scwMonthSum / 12); scwID('scwMonths').options.selectedIndex = (scwMonthSum % 12); // Opera has a bug with this method of setting the selected index. // It requires the following work-around to force SELECTs to display // correctly. if (window.opera) { scwID('scwMonths').style.display = 'none'; scwID('scwMonths').style.display = 'block'; scwID('scwYears').style.display = 'none'; scwID('scwYears').style.display = 'block'; } // The bug is apparently known and "fixed for future versions" // but they say they aren't going to put the fix into the 9.x // series. // Check whether or not dragging is allowed and display drag handle // if necessary scwID('scwDrag').style.display = (scwAllowDrag) ? ((scwID('scwIFrame')) ? 'block' : 'table-row') : 'none'; // Display the month scwShowMonth(0); // Position the calendar box // The object sniffing for Opera allows for the fact that Opera // is the only major browser that correctly reports the position // of an element in a scrollable DIV. This is because IE and // Firefox omit the DIV from the offsetParent tree. scwTargetEle = scwEle; var offsetTop = parseInt(scwEle.offsetTop, 10) + parseInt(scwEle.offsetHeight, 10), offsetLeft = parseInt(scwEle.offsetLeft, 10); if (!window.opera) { while (scwEle.tagName != 'BODY' && scwEle.tagName != 'HTML') { offsetTop -= parseInt(scwEle.scrollTop, 10); offsetLeft -= parseInt(scwEle.scrollLeft, 10); scwEle = scwEle.parentNode; } scwEle = scwTargetEle; } do { scwEle = scwEle.offsetParent; offsetTop += parseInt(scwEle.offsetTop, 10); offsetLeft += parseInt(scwEle.offsetLeft, 10); } while (scwEle.tagName != 'BODY' && scwEle.tagName != 'HTML'); scwID('scw').style.top = offsetTop + 'px'; scwID('scw').style.left = offsetLeft + 'px'; if (scwID('scwIframe')) { scwID('scwIframe').style.top = offsetTop + 'px'; scwID('scwIframe').style.left = offsetLeft + 'px'; scwID('scwIframe').style.width = (scwID('scw').offsetWidth - 2) + 'px'; scwID('scwIframe').style.height = (scwID('scw').offsetHeight - 2) + 'px'; scwID('scwIframe').style.visibility = 'visible'; } // Show it on the page scwID('scw').style.visibility = 'visible'; // Ensure that Opera actually displays the value that is selected! scwID('scwYears').options.selectedIndex = scwID('scwYears').options.selectedIndex; scwID('scwMonths').options.selectedIndex = scwID('scwMonths').options.selectedIndex; var el = (scwSourceEle.parentNode) ? scwSourceEle.parentNode : scwSourceEle; if (typeof event == 'undefined') { el.addEventListener('click', scwStopPropagation, false); } else { if (el.attachEvent) { el.attachEvent('onclick', scwStopPropagation); } else { event.cancelBubble = true; } }}function scwHide(){ scwID('scw').style.visibility = 'hidden'; if (scwID('scwIframe')) { scwID('scwIframe').style.visibility = 'hidden'; } if (typeof scwNextAction != 'undefined' && scwNextAction != null) { scwNextActionReturn = scwNextAction(); // Explicit null set to prevent closure causing memory leak scwNextAction = null; }}function scwCancel(scwEvt){ if (scwClickToHide) scwHide(); scwStopPropagation(scwEvt);}function scwStopPropagation(scwEvt){ if (scwEvt.stopPropagation) scwEvt.stopPropagation(); // Capture phase else scwEvt.cancelBubble = true; // Bubbling phase}function scwBeginDrag(event){ var elementToDrag = scwID('scw'); var deltaX = event.clientX, deltaY = event.clientY, offsetEle = elementToDrag; do { deltaX -= parseInt(offsetEle.offsetLeft, 10); deltaY -= parseInt(offsetEle.offsetTop, 10); offsetEle = offsetEle.offsetParent; } while (offsetEle.tagName != 'BODY' && offsetEle.tagName != 'HTML'); if (document.addEventListener) { document.addEventListener('mousemove', moveHandler, true); // Capture phase document.addEventListener('mouseup', upHandler, true); // Capture phase } else { elementToDrag.attachEvent('onmousemove', moveHandler); // Bubbling phase elementToDrag.attachEvent('onmouseup', upHandler); // Bubbling phase elementToDrag.setCapture(); } scwStopPropagation(event); function moveHandler(scwEvt) { if (!scwEvt) scwEvt = window.event; elementToDrag.style.left = (scwEvt.clientX - deltaX) + 'px'; elementToDrag.style.top = (scwEvt.clientY - deltaY) + 'px'; if (scwID('scwIframe')) { scwID('scwIframe').style.left = (scwEvt.clientX - deltaX) + 'px'; scwID('scwIframe').style.top = (scwEvt.clientY - deltaY) + 'px'; } scwStopPropagation(scwEvt); } function upHandler(scwEvt) { if (!scwEvt) scwEvt = window.event; if (document.removeEventListener) { document.removeEventListener('mousemove', moveHandler, true); // Capture phase document.removeEventListener('mouseup', upHandler, true); // Capture phase } else { elementToDrag.detachEvent('onmouseup', upHandler); // Bubbling phase elementToDrag.detachEvent('onmousemove', moveHandler); // Bubbling phase elementToDrag.releaseCapture(); } scwStopPropagation(scwEvt); }}function scwShowMonth(scwBias){// Set the selectable Month and Year // May be called: from the left and right arrows // (shift month -1 and +1 respectively) // from the month selection list // from the year selection list // from the showCal routine // (which initiates the display). var scwShowDate = new Date(Date.parse(new Date().toDateString())), scwStartDate = new Date(); // Set the time to the middle of the day so that the handful of // regions that have daylight saving shifts that change the day // of the month (i.e. turn the clock back at midnight or forward // at 23:00) do not mess up the date display in the calendar. scwShowDate.setHours(12); scwSelYears = scwID('scwYears'); scwSelMonths = scwID('scwMonths'); if (scwSelYears.options.selectedIndex > -1) { scwMonthSum = 12 * (scwSelYears.options.selectedIndex) + scwBias; if (scwSelMonths.options.selectedIndex > -1) { scwMonthSum += scwSelMonths.options.selectedIndex; } } else { if (scwSelMonths.options.selectedIndex > -1) { scwMonthSum += scwSelMonths.options.selectedIndex; } } scwShowDate.setFullYear(scwBaseYear + Math.floor(scwMonthSum / 12), (scwMonthSum % 12), 1); // If the Week numbers are displayed, shift the week day names // to the right. scwID('scwWeek_').style.display = (scwWeekNumberDisplay) ? ((scwID('scwIFrame')) ? 'block' : 'table-cell') : 'none'; if ((12 * parseInt((scwShowDate.getFullYear() - scwBaseYear), 10)) + parseInt(scwShowDate.getMonth(), 10) < (12 * scwDropDownYears) && (12 * parseInt((scwShowDate.getFullYear() - scwBaseYear), 10)) + parseInt(scwShowDate.getMonth(), 10) > -1) { scwSelYears.options.selectedIndex = Math.floor(scwMonthSum / 12); scwSelMonths.options.selectedIndex = (scwMonthSum % 12); scwCurMonth = scwShowDate.getMonth(); scwShowDate.setDate((((scwShowDate. getDay() - scwWeekStart) < 0) ? -6 : 1) + scwWeekStart - scwShowDate.getDay()); // This statement moved by Michael Cerveny to make version 3.55 var scwCompareDateValue = new Date(scwShowDate.getFullYear(), scwShowDate.getMonth(), scwShowDate.getDate()).valueOf(); scwStartDate = new Date(scwShowDate); var scwFoot = scwID('scwFoot'); function scwFootOutput() { scwSetOutput(scwDateNow); } if (scwDisabledDates.length == 0) { if (scwActiveToday && scwParmActiveToday)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -