📄 scw.js
字号:
{ scwFoot.onclick = scwFootOutput; scwFoot.className = 'scwFoot'; if (scwID('scwIFrame')) { scwFoot.onmouseover = scwChangeClass; scwFoot.onmouseout = scwChangeClass; } } else { scwFoot.onclick = null; scwFoot.className = 'scwFootDisabled'; if (scwID('scwIFrame')) { scwFoot.onmouseover = null; scwFoot.onmouseout = null; } if (document.addEventListener) { scwFoot.addEventListener('click', scwStopPropagation, false); } else { scwFoot.attachEvent('onclick', scwStopPropagation); } } } else { for (var k = 0; k < scwDisabledDates.length; k++) { if (!scwActiveToday || !scwParmActiveToday || ((typeof scwDisabledDates[k] == 'object') && (((scwDisabledDates[k].constructor == Date) && scwDateNow.valueOf() == scwDisabledDates[k]. valueOf() ) || ((scwDisabledDates[k].constructor == Array) && scwDateNow.valueOf() >= scwDisabledDates[k][0]. valueOf() && scwDateNow.valueOf() <= scwDisabledDates[k][1]. valueOf() ) ) ) ) { scwFoot.onclick = null; scwFoot.className = 'scwFootDisabled'; if (scwID('scwIFrame')) { scwFoot.onmouseover = null; scwFoot.onmouseout = null; } if (document.addEventListener) { scwFoot.addEventListener('click', scwStopPropagation, false); } else { scwFoot.attachEvent('onclick', scwStopPropagation); } break; } else { scwFoot.onclick = scwFootOutput; scwFoot.className = 'scwFoot'; if (scwID('scwIFrame')) { scwFoot.onmouseover = scwChangeClass; scwFoot.onmouseout = scwChangeClass; } } } } function scwSetOutput(scwOutputDate) { if (typeof scwTargetEle.value == 'undefined') { scwTriggerEle.scwTextNode. replaceData(0, scwTriggerEle.scwLength, scwOutputDate.scwFormat(scwDateOutputFormat)); } else { scwTargetEle.value = scwOutputDate.scwFormat(scwDateOutputFormat); } scwHide(); } function scwCellOutput(scwEvt) { var scwEle = scwEventTrigger(scwEvt), scwOutputDate = new Date(scwStartDate); if (scwEle.nodeType == 3) scwEle = scwEle.parentNode; scwOutputDate.setDate(scwStartDate.getDate() + parseInt(scwEle.id.substr(8), 10)); scwSetOutput(scwOutputDate); } function scwChangeClass(scwEvt) { var scwEle = scwEventTrigger(scwEvt); if (scwEle.nodeType == 3) scwEle = scwEle.parentNode; switch (scwEle.className) {case 'scwCells': scwEle.className = 'scwCellsHover'; break; case 'scwCellsHover': scwEle.className = 'scwCells'; break; case 'scwCellsExMonth': scwEle.className = 'scwCellsExMonthHover'; break; case 'scwCellsExMonthHover': scwEle.className = 'scwCellsExMonth'; break; case 'scwCellsWeekend': scwEle.className = 'scwCellsWeekendHover'; break; case 'scwCellsWeekendHover': scwEle.className = 'scwCellsWeekend'; break; case 'scwFoot': scwEle.className = 'scwFootHover'; break; case 'scwFootHover': scwEle.className = 'scwFoot'; break; case 'scwInputDate': scwEle.className = 'scwInputDateHover'; break; case 'scwInputDateHover': scwEle.className = 'scwInputDate'; } return true; } function scwEventTrigger(scwEvt) { if (!scwEvt) scwEvt = event; return scwEvt.target || scwEvt.srcElement; } function scwWeekNumber(scwInDate) {// The base day in the week of the input date var scwInDateWeekBase = new Date(scwInDate); scwInDateWeekBase.setDate(scwInDateWeekBase.getDate() - scwInDateWeekBase.getDay() + scwWeekNumberBaseDay + ((scwInDate.getDay() > scwWeekNumberBaseDay) ? 7 : 0)); // The first Base Day in the year var scwFirstBaseDay = new Date(scwInDateWeekBase.getFullYear(), 0, 1) scwFirstBaseDay.setDate(scwFirstBaseDay.getDate() - scwFirstBaseDay.getDay() + scwWeekNumberBaseDay ); if (scwFirstBaseDay < new Date(scwInDateWeekBase.getFullYear(), 0, 1)) { scwFirstBaseDay.setDate(scwFirstBaseDay.getDate() + 7); } // Start of Week 01 var scwStartWeekOne = new Date(scwFirstBaseDay - scwWeekNumberBaseDay + scwInDate.getDay()); if (scwStartWeekOne > scwFirstBaseDay) { scwStartWeekOne.setDate(scwStartWeekOne.getDate() - 7); } // Subtract the date of the current week from the date of the // first week of the year to get the number of weeks in // milliseconds. Divide by the number of milliseconds // in a week then round to no decimals in order to remove // the effect of daylight saving. Add one to make the first // week, week 1. Place a string zero on the front so that // week numbers are zero filled. var scwWeekNo = '0' + (Math.round((scwInDateWeekBase - scwFirstBaseDay) / 604800000, 0) + 1); // Return the last two characters in the week number string return scwWeekNo.substring(scwWeekNo.length - 2, scwWeekNo.length); } // Treewalk to display the dates. // I tried to use getElementsByName but IE refused to cooperate // so I resorted to this method which works for all tested // browsers. var scwCells = scwID('scwCells'); for (i = 0; i < scwCells.childNodes.length; i++) { var scwRows = scwCells.childNodes[i]; if (scwRows.nodeType == 1 && scwRows.tagName == 'TR') { if (scwWeekNumberDisplay) {//Calculate the week number using scwShowDate scwRows.childNodes[0].innerHTML = scwWeekNumber(scwShowDate); scwRows.childNodes[0].style.display = (scwID('scwIFrame')) ? 'block' : 'table-cell'; } else { scwRows.childNodes[0].style.display = 'none'; } for (j = 1; j < scwRows.childNodes.length; j++) { var scwCols = scwRows.childNodes[j]; if (scwCols.nodeType == 1 && scwCols.tagName == 'TD') { scwRows.childNodes[j].innerHTML = scwShowDate.getDate(); var scwCell = scwRows.childNodes[j], scwDisabled = ((scwOutOfRangeDisable && (scwShowDate < (new Date(scwBaseYear, 0, 1, scwShowDate.getHours())) || scwShowDate > (new Date(scwBaseYear + scwDropDownYears, 0, 0, scwShowDate.getHours())) ) ) || (scwOutOfMonthDisable && (scwShowDate < (new Date(scwShowDate.getFullYear(), scwCurMonth, 1, scwShowDate.getHours())) || scwShowDate > (new Date(scwShowDate.getFullYear(), scwCurMonth + 1, 0, scwShowDate.getHours())) ) ) ) ? true : false; scwCell.style.visibility = (scwOutOfMonthHide && (scwShowDate < (new Date(scwShowDate.getFullYear(), scwCurMonth, 1, scwShowDate.getHours())) || scwShowDate > (new Date(scwShowDate.getFullYear(), scwCurMonth + 1, 0, scwShowDate.getHours())) ) ) ? 'hidden' : ''; for (var k = 0; k < scwDisabledDates.length; k++) { if ((typeof scwDisabledDates[k] == 'object') && (scwDisabledDates[k].constructor == Date ) && scwCompareDateValue == scwDisabledDates[k].valueOf() ) { scwDisabled = true; } else { if ((typeof scwDisabledDates[k] == 'object') && (scwDisabledDates[k].constructor == Array ) && scwCompareDateValue >= scwDisabledDates[k][0].valueOf() && scwCompareDateValue <= scwDisabledDates[k][1].valueOf() ) { scwDisabled = true; } } } if (scwDisabled || !scwEnabledDay[j - 1 + (7 * ((i * scwCells. childNodes. length) / 6))] || !scwPassEnabledDay[(j - 1 + (7 * (i * scwCells. childNodes. length / 6))) % 7] ) { scwRows.childNodes[j].onclick = null; if (scwID('scwIFrame')) { scwRows.childNodes[j].onmouseover = null; scwRows.childNodes[j].onmouseout = null; } scwCell.className = (scwShowDate.getMonth() != scwCurMonth) ? 'scwCellsExMonthDisabled' : (scwBlnFullInputDate && scwShowDate.toDateString() == scwSeedDate.toDateS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -