📄 scw.js
字号:
true, true, true, true, true, true, true];// You can disable any specific date (e.g. 24-Jan-2006 or Today) by// creating an element of the array scwDisabledDates as a date object// with the value you want to disable. Date ranges can be disabled// by placing an array of two values (Start and End) into an element// of this array.var scwDisabledDates = new Array();// e.g. To disable 10-Dec-2005:// scwDisabledDates[0] = new Date(2005,11,10);//// or a range from 2004-Dec-25 to 2005-Jan-01:// scwDisabledDates[1] = [new Date(2004,11,25),new Date(2005,0,1)];//// Remember that Javascript months are Zero-based.// The disabling by date and date range does prevent the current day// from being selected. Disabling days of the week does not so you can set// the scwActiveToday value to false to prevent selection.var scwActiveToday = true;// Dates that are out of the displayed month are shown at the start// (unless the month starts on the first day of the week) and end of each// month.//// Set scwOutOfMonthDisable to true to disable these dates (or false// to allow their selection).//// Set scwOutOfMonthHide to true to hide these dates (or false// to make them visible).var scwOutOfMonthDisable = false;var scwOutOfMonthHide = false;// Dates that are out of the specified range can be displayed at the start// of the very first month and end of the very last. Set// scwOutOfRangeDisable to true to disable these dates (or false to// allow their selection).var scwOutOfRangeDisable = true;// You can allow the calendar to be dragged around the screen by// using the setting scwAllowDrag to true.// I can't say I recommend it because of the danger of the user// forgetting which date field the calendar will update when there// are multiple date fields on a page.var scwAllowDrag = false;// Closing the calendar by clicking on it (rather than elsewhere on the// main page) can be inconvenient. The scwClickToHide boolean value// controls this feature.var scwClickToHide = false;// I have made every effort to isolate the pop-up script from any// CSS defined on the main page but if you have anything set that// affects the pop-up (or you may want to change the way it looks)// then you can address it in the following style sheets.document.writeln( '<style type="text/css">' + '.scw {padding:1px;vertical-align:middle;}' + 'iframe.scw {position:absolute;z-index:' + scwZindex + ';top:0px;left:0px;visibility:hidden;' + 'width:1px;height:1px;}' + 'table.scw {padding:0px;visibility:hidden;' + 'position:absolute;cursor:default;' + 'width:200px;top:0px;left:0px;' + 'z-index:' + (scwZindex + 1) + ';text-align:center;}' + '</style>');// This style sheet can be extracted from the script and edited into regular// CSS (by removing all occurrences of + and '). That can be used as the// basis for themes. Classes are described in comments within the style// sheet.document.writeln( '<style type="text/css">' + '/* IMPORTANT: The SCW calendar script requires all ' + ' the classes defined here.' + '*/' + 'table.scw {padding: 1px;' + 'vertical-align:middle;' + 'border: ridge 2px;' + 'font-size: 10pt;' + 'font-family: Arial,Helvetica,Sans-Serif;' + 'font-weight: bold;}' + 'td.scwDrag,' + 'td.scwHead {padding: 0px 0px;' + 'text-align: center;}' + 'td.scwDrag {font-size: 8pt;}' + 'select.scwHead {margin: 3px 1px;' + 'text-align: center;}' + 'input.scwHead {height: 22px;' + 'width: 22px;' + 'vertical-align:middle;' + 'text-align: center;' + 'margin: 2px 1px;' + 'font-weight: bold;' + 'font-size: 10pt;' + 'font-family: fixedSys;}' + 'td.scwWeekNumberHead,' + 'td.scwWeek {padding: 0px;' + 'text-align: center;' + 'font-weight: bold;}' + 'td.scwFoot,' + 'td.scwFootHover,' + 'td.scwFoot:hover,' + 'td.scwFootDisabled {padding: 0px;' + 'text-align: center;' + 'font-weight: normal;}' + 'table.scwCells {text-align: right;' + 'font-size: 8pt;' + 'width: 96%;}' + 'td.scwCells,' + 'td.scwCellsHover,' + 'td.scwCells:hover,' + 'td.scwCellsDisabled,' + 'td.scwCellsExMonth,' + 'td.scwCellsExMonthHover,' + 'td.scwCellsExMonth:hover,' + 'td.scwCellsExMonthDisabled,' + 'td.scwCellsWeekend,' + 'td.scwCellsWeekendHover,' + 'td.scwCellsWeekend:hover,' + 'td.scwCellsWeekendDisabled,' + 'td.scwInputDate,' + 'td.scwInputDateHover,' + 'td.scwInputDate:hover,' + 'td.scwInputDateDisabled,' + 'td.scwWeekNo,' + 'td.scwWeeks {padding: 3px;' + 'width: 16px;' + 'height: 16px;' + 'font-weight: bold;' + 'vertical-align: middle;}' + '/* Blend the colours into your page here... */' + '/* Calendar background */' + 'table.scw {background-color: #6666CC;}' + '/* Drag Handle */' + 'td.scwDrag {background-color: #9999CC;' + 'color: #CCCCFF;}' + '/* Week number heading */' + 'td.scwWeekNumberHead {color: #6666CC;}' + '/* Week day headings */' + 'td.scwWeek {color: #CCCCCC;}' + '/* Week numbers */' + 'td.scwWeekNo {background-color: #776677;' + 'color: #CCCCCC;}' + '/* Enabled Days */' + '/* Week Day */' + 'td.scwCells {background-color: #CCCCCC;' + 'color: #000000;}' + '/* Day matching the input date */' + 'td.scwInputDate {background-color: #CC9999;' + 'color: #FF0000;}' + '/* Weekend Day */' + 'td.scwCellsWeekend {background-color: #CCCCCC;' + 'color: #CC6666;}' + '/* Day outside the current month */' + 'td.scwCellsExMonth {background-color: #CCCCCC;' + 'color: #666666;}' + '/* Today selector */' + 'td.scwFoot {background-color: #6666CC;' + 'color: #FFFFFF;}' + '/* MouseOver/Hover formatting ' + ' If you want to "turn off" any of the formatting ' + ' then just set to the same as the standard format' + ' above.' + ' ' + ' Note: The reason that the following are' + ' implemented using both a class and a :hover' + ' pseudoclass is because Opera handles the rendering' + ' involved in the class swap very poorly and IE6 ' + ' (and below) only implements pseudoclasses on the' + ' anchor tag.' + '*/' + '/* Active cells */' + 'td.scwCells:hover,' + 'td.scwCellsHover {background-color: #FFFF00;' + 'cursor: pointer;' + 'cursor: hand;' + 'color: #000000;}' + '/* Day matching the input date */' + 'td.scwInputDate:hover,' + 'td.scwInputDateHover {background-color: #FFFF00;' + 'cursor: pointer;' + 'cursor: hand;' + 'color: #000000;}' + '/* Weekend cells */' + 'td.scwCellsWeekend:hover,' + 'td.scwCellsWeekendHover {background-color: #FFFF00;' + 'cursor: pointer;' + 'cursor: hand;' + 'color: #000000;}' + '/* Day outside the current month */' + 'td.scwCellsExMonth:hover,' + 'td.scwCellsExMonthHover {background-color: #FFFF00;' + 'cursor: pointer;' + 'cursor: hand;' + 'color: #000000;}' + '/* Today selector */' + 'td.scwFoot:hover,' + 'td.scwFootHover {color: #FFFF00;' + 'cursor: pointer;' + 'cursor: hand;' + 'font-weight: bold;}' + '/* Disabled cells */' + '/* Week Day */' + '/* Day matching the input date */' + 'td.scwInputDateDisabled {background-color: #999999;' + 'color: #000000;}' + 'td.scwCellsDisabled {background-color: #999999;' + 'color: #000000;}' + '/* Weekend Day */' + 'td.scwCellsWeekendDisabled {background-color: #999999;' + 'color: #CC6666;}' + '/* Day outside the current month */' + 'td.scwCellsExMonthDisabled {background-color: #999999;' + 'color: #666666;}' + 'td.scwFootDisabled {background-color: #6666CC;' + 'color: #FFFFFF;}' + '</style>' );//******************************************************************************//------------------------------------------------------------------------------// End of customisation section//------------------------------------------------------------------------------//******************************************************************************// Variables required by both scwShow and scwShowMonthvar scwTargetEle, scwTriggerEle, scwMonthSum = 0, scwBlnFullInputDate = false, scwPassEnabledDay = new Array(), scwSeedDate = new Date(), scwParmActiveToday = true, scwWeekStart = scwWeekStart % 7, scwToday, scwDrag, scwArrMonthNames, scwArrWeekInits, scwInvalidDateMsg, scwOutOfRangeMsg, scwDoesNotExistMsg, scwInvalidAlert, scwDateDisablingError, scwRangeDisablingError;// Add a method to format a date into the required patternDate.prototype.scwFormat =function(scwFormat){ var charCount = 0, codeChar = '', result = ''; for (var i = 0; i <= scwFormat.length; i++) { if (i < scwFormat.length && scwFormat.charAt(i) == codeChar) {// If we haven't hit the end of the string and // the format string character is the same as // the previous one, just clock up one to the // length of the current element definition charCount++; } else { switch (codeChar) {case 'y': case 'Y': result += (this.getFullYear() % Math. pow(10, charCount)).toString(). scwPadLeft(charCount); break; case 'm': case 'M': // If we find an M, check the number of them to // determine whether to get the month number or // the month name. result += (charCount < 3) ? (this.getMonth() + 1). toString().scwPadLeft(charCount) : scwArrMonthNames[this.getMonth()]; break; case 'd': case 'D': // If we find a D, get the date and format it result += this.getDate().toString(). scwPadLeft(charCount); break; default: // Copy any unrecognised characters across while (charCount-- > 0) { result += codeChar; } } if (i < scwFormat.length) {// Store the character we have just worked on codeChar = scwFormat.charAt(i); charCount = 1; } } } return result;}// Add a method to left pad zeroesString.prototype.scwPadLeft =function(padToLength){ var result = ''; for (var i = 0; i < (padToLength - this.length); i++) { result += '0'; } return (result + this);}// Set up a closure so that any next function can be triggered// after the calendar has been closed AND that function can take// arguments.Function.prototype.runsAfterSCW =function() { var func = this, args = new Array(arguments.length); for (var i = 0; i < args.length; ++i) { args[i] = arguments[i]; } return function() {// concat/join the two argument arrays for (var i = 0; i < arguments.length; ++i) { args[args.length] = arguments[i]; } return (args.shift() == scwTriggerEle) ? func.apply(this, args) : null; }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -