📄 dateout.js
字号:
document.writeln(" row.className = \"footrow\";");
document.writeln("");
document.writeln(" cell = hh(Calendar._TT[\"SEL_DATE\"], this.weekNumbers ? 8 : 7, 300);");
document.writeln(" cell.className = \"ttip\";");
document.writeln(" if (this.isPopup) {");
document.writeln(" cell.ttip = Calendar._TT[\"DRAG_TO_MOVE\"];");
document.writeln(" cell.style.cursor = \"move\";");
document.writeln(" }");
document.writeln(" this.tooltips = cell;");
document.writeln("");
document.writeln(" div = Calendar.createElement(\"div\", this.element);");
document.writeln(" this.monthsCombo = div;");
document.writeln(" div.className = \"combo\";");
document.writeln(" for (i = 0; i < Calendar._MN.length; ++i) {");
document.writeln(" var mn = Calendar.createElement(\"div\");");
document.writeln(" mn.className = \"label\";");
document.writeln(" mn.month = i;");
document.writeln(" mn.appendChild(document.createTextNode(Calendar._MN3[i]));");
document.writeln(" div.appendChild(mn);");
document.writeln(" }");
document.writeln("");
document.writeln(" div = Calendar.createElement(\"div\", this.element);");
document.writeln(" this.yearsCombo = div;");
document.writeln(" div.className = \"combo\";");
document.writeln(" for (i = 12; i > 0; --i) {");
document.writeln(" var yr = Calendar.createElement(\"div\");");
document.writeln(" yr.className = \"label\";");
document.writeln(" yr.appendChild(document.createTextNode(\"\"));");
document.writeln(" div.appendChild(yr);");
document.writeln(" }");
document.writeln("");
document.writeln(" this._init(this.mondayFirst, this.date);");
document.writeln(" parent.appendChild(this.element);");
document.writeln("};");
document.writeln("");
document.writeln("\/** keyboard navigation, only for popup calendars *\/");
document.writeln("Calendar._keyEvent = function(ev) {");
document.writeln(" if (!window.calendar) {");
document.writeln(" return false;");
document.writeln(" }");
document.writeln(" (Calendar.is_ie) && (ev = window.event);");
document.writeln(" var cal = window.calendar;");
document.writeln(" var act = (Calendar.is_ie || ev.type == \"keypress\");");
document.writeln(" if (ev.ctrlKey) {");
document.writeln(" switch (ev.keyCode) {");
document.writeln(" case 37: \/\/ KEY left");
document.writeln(" act && Calendar.cellClick(cal._nav_pm);");
document.writeln(" break;");
document.writeln(" case 38: \/\/ KEY up");
document.writeln(" act && Calendar.cellClick(cal._nav_py);");
document.writeln(" break;");
document.writeln(" case 39: \/\/ KEY right");
document.writeln(" act && Calendar.cellClick(cal._nav_nm);");
document.writeln(" break;");
document.writeln(" case 40: \/\/ KEY down");
document.writeln(" act && Calendar.cellClick(cal._nav_ny);");
document.writeln(" break;");
document.writeln(" default:");
document.writeln(" return false;");
document.writeln(" }");
document.writeln(" } else switch (ev.keyCode) {");
document.writeln(" case 32: \/\/ KEY space (now)");
document.writeln(" Calendar.cellClick(cal._nav_now);");
document.writeln(" break;");
document.writeln(" case 27: \/\/ KEY esc");
document.writeln(" act && cal.hide();");
document.writeln(" break;");
document.writeln(" case 37: \/\/ KEY left");
document.writeln(" case 38: \/\/ KEY up");
document.writeln(" case 39: \/\/ KEY right");
document.writeln(" case 40: \/\/ KEY down");
document.writeln(" if (act) {");
document.writeln(" var date = cal.date.getDate() - 1;");
document.writeln(" var el = cal.currentDateEl;");
document.writeln(" var ne = null;");
document.writeln(" var prev = (ev.keyCode == 37) || (ev.keyCode == 38);");
document.writeln(" switch (ev.keyCode) {");
document.writeln(" case 37: \/\/ KEY left");
document.writeln(" (--date >= 0) && (ne = cal.ar_days[date]);");
document.writeln(" break;");
document.writeln(" case 38: \/\/ KEY up");
document.writeln(" date -= 7;");
document.writeln(" (date >= 0) && (ne = cal.ar_days[date]);");
document.writeln(" break;");
document.writeln(" case 39: \/\/ KEY right");
document.writeln(" (++date < cal.ar_days.length) && (ne = cal.ar_days[date]);");
document.writeln(" break;");
document.writeln(" case 40: \/\/ KEY down");
document.writeln(" date += 7;");
document.writeln(" (date < cal.ar_days.length) && (ne = cal.ar_days[date]);");
document.writeln(" break;");
document.writeln(" }");
document.writeln(" if (!ne) {");
document.writeln(" if (prev) {");
document.writeln(" Calendar.cellClick(cal._nav_pm);");
document.writeln(" } else {");
document.writeln(" Calendar.cellClick(cal._nav_nm);");
document.writeln(" }");
document.writeln(" date = (prev) ? cal.date.getMonthDays() : 1;");
document.writeln(" el = cal.currentDateEl;");
document.writeln(" ne = cal.ar_days[date - 1];");
document.writeln(" }");
document.writeln(" Calendar.removeClass(el, \"selected\");");
document.writeln(" Calendar.addClass(ne, \"selected\");");
document.writeln(" cal.date.setDate(ne.caldate);");
document.writeln(" cal.callHandler();");
document.writeln(" cal.currentDateEl = ne;");
document.writeln(" }");
document.writeln(" break;");
document.writeln(" case 13: \/\/ KEY enter");
document.writeln(" if (act) {");
document.writeln(" cal.callHandler();");
document.writeln(" cal.hide();");
document.writeln(" }");
document.writeln(" break;");
document.writeln(" default:");
document.writeln(" return false;");
document.writeln(" }");
document.writeln(" return Calendar.stopEvent(ev);");
document.writeln("};");
document.writeln("");
document.writeln("\/**");
document.writeln(" * (RE)Initializes the calendar to the given date and style (if mondayFirst is");
document.writeln(" * true it makes Monday the first day of week, otherwise the weeks start on");
document.writeln(" * Sunday.");
document.writeln(" *\/");
document.writeln("Calendar.prototype._init = function (mondayFirst, date) {");
document.writeln(" var today = new Date();");
document.writeln(" var year = date.getFullYear();");
document.writeln(" if (year < this.minYear) {");
document.writeln(" year = this.minYear;");
document.writeln(" date.setFullYear(year);");
document.writeln(" } else if (year > this.maxYear) {");
document.writeln(" year = this.maxYear;");
document.writeln(" date.setFullYear(year);");
document.writeln(" }");
document.writeln(" this.mondayFirst = mondayFirst;");
document.writeln(" this.date = new Date(date);");
document.writeln(" var month = date.getMonth();");
document.writeln(" var mday = date.getDate();");
document.writeln(" var no_days = date.getMonthDays();");
document.writeln(" date.setDate(1);");
document.writeln(" var wday = date.getDay();");
document.writeln(" var MON = mondayFirst ? 1 : 0;");
document.writeln(" var SAT = mondayFirst ? 5 : 6;");
document.writeln(" var SUN = mondayFirst ? 6 : 0;");
document.writeln(" if (mondayFirst) {");
document.writeln(" wday = (wday > 0) ? (wday - 1) : 6;");
document.writeln(" }");
document.writeln(" var iday = 1;");
document.writeln(" var row = this.tbody.firstChild;");
document.writeln(" var MN = Calendar._MN3[month];");
document.writeln(" var hasToday = ((today.getFullYear() == year) && (today.getMonth() == month));");
document.writeln(" var todayDate = today.getDate();");
document.writeln(" var week_number = date.getWeekNumber();");
document.writeln(" var ar_days = new Array();");
document.writeln(" for (var i = 0; i < 6; ++i) {");
document.writeln(" if (iday > no_days) {");
document.writeln(" row.className = \"emptyrow\";");
document.writeln(" row = row.nextSibling;");
document.writeln(" continue;");
document.writeln(" }");
document.writeln(" var cell = row.firstChild;");
document.writeln(" if (this.weekNumbers) {");
document.writeln(" cell.className = \"day wn\";");
document.writeln(" cell.firstChild.data = week_number;");
document.writeln(" cell = cell.nextSibling;");
document.writeln(" }");
document.writeln(" ++week_number;");
document.writeln(" row.className = \"daysrow\";");
document.writeln(" for (var j = 0; j < 7; ++j) {");
document.writeln(" cell.className = \"day\";");
document.writeln(" if ((!i && j < wday) || iday > no_days) {");
document.writeln(" \/\/ cell.className = \"emptycell\";");
document.writeln(" cell.innerHTML = \" \";");
document.writeln(" cell.disabled = true;");
document.writeln(" cell = cell.nextSibling;");
document.writeln(" continue;");
document.writeln(" }");
document.writeln(" cell.disabled = false;");
document.writeln(" cell.firstChild.data = iday;");
document.writeln(" if (typeof this.checkDisabled == \"function\") {");
document.writeln(" date.setDate(iday);");
document.writeln(" if (this.checkDisabled(date)) {");
document.writeln(" cell.className += \" disabled\";");
document.writeln(" cell.disabled = true;");
document.writeln(" }");
document.writeln(" }");
document.writeln(" if (!cell.disabled) {");
document.writeln(" ar_days[ar_days.length] = cell;");
document.writeln(" cell.caldate = iday;");
document.writeln(" cell.ttip = \"_\";");
document.writeln(" if (iday == mday) {");
document.writeln(" cell.className += \" selected\";");
document.writeln(" this.currentDateEl = cell;");
document.writeln(" }");
document.writeln(" if (hasToday && (iday == todayDate)) {");
document.writeln(" cell.className += \" today\";");
document.writeln(" cell.ttip += Calendar._TT[\"PART_TODAY\"];");
document.writeln(" }");
document.writeln(" if (wday == SAT || wday == SUN) {");
document.writeln(" cell.className += \" weekend\";");
document.writeln(" }");
document.writeln(" }");
document.writeln(" ++iday;");
document.writeln(" ((++wday) ^ 7) || (wday = 0);");
document.writeln(" cell = cell.nextSibling;");
document.writeln(" }");
document.writeln(" row = row.nextSibling;");
document.writeln(" }");
document.writeln(" this.ar_days = ar_days;");
document.writeln(" this.title.firstChild.data = Calendar._MN[month] + \", \" + year;");
document.writeln(" \/\/ PROFILE");
document.writeln(" \/\/ this.tooltips.firstChild.data = \"Generated in \" + ((new Date()) - today) + \" ms\";");
document.writeln("};");
document.writeln("");
document.writeln("\/**");
document.writeln(" * Calls _init function above for going to a certain date (but only if the");
document.writeln(" * date is different than the currently selected one).");
document.writeln(" *\/");
document.writeln("Calendar.prototype.setDate = function (date) {");
document.writeln(" if (!date.equalsTo(this.date)) {");
document.writeln(" this._init(this.mondayFirst, date);");
document.writeln(" }");
document.writeln("};");
document.writeln("");
document.writeln("\/**");
document.writeln(" * Refreshes the calendar. Useful if the \"disabledHandler\" function is");
document.writeln(" * dynamic, meaning that the list of disabled date can change at runtime.");
document.writeln(" * Just * call this function if you think that the list of disabled dates");
document.writeln(" * should * change.");
document.writeln(" *\/");
document.writeln("Calendar.prototype.refresh = function () {");
document.writeln(" this._init(this.mondayFirst, this.date);");
document.writeln("};");
document.writeln("");
document.writeln("\/** Modifies the \"mondayFirst\" parameter (EU\/US style). *\/");
document.writeln("Calendar.prototype.setMondayFirst = function (mondayFirst) {");
document.writeln(" this._init(mondayFirst, this.date);");
document.writeln(" this._displayWeekdays();");
document.writeln("};");
document.writeln("");
document.writeln("\/**");
document.writeln(" * Allows customization of what dates are enabled. The \"unaryFunction\"");
document.writeln(" * parameter must be a function object that receives the date (as a JS Date");
document.writeln(" * object) and returns a boolean value. If the returned value is true then");
document.writeln(" * the passed date will be marked as disabled.");
document.writeln(" *\/");
document.writeln("Calendar.prototype.setDisabledHandler = function (unaryFunction) {");
document.writeln(" this.checkDisabled = unaryFunction;");
document.writeln("};");
document.writeln("");
document.writeln("\/** Customization of allowed year range for the calendar. *\/");
document.writeln("Calendar.prototype.setRange = function (a, z) {");
document.writeln(" this.minYear = a;");
document.writeln(" this.maxYear = z;");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -