⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cal.js

📁 噶额外噶外骨骼感广泛高热感 就 啊啊
💻 JS
📖 第 1 页 / 共 3 页
字号:
function convertMonthToNumber(month_name) { 
  month_name1= month_name.toLowerCase(); 
  switch(month_name1) { 
  case "jan" : 
         return 1; 
  case "feb" : 
         return 2; 
  case "mar" : 
         return 3; 
  case "apr" : 
         return 4; 
  case "may" : 
         return 5; 
  case "jun" : 
         return 6; 
  case "jul" : 
         return 7; 
  case "aug" : 
         return 8; 
  case "sep" : 
         return 9; 
  case "oct" : 
         return 10; 
  case "nov" : 
         return 11; 
  case "dec" : 
         return 12; 
  } 
} 

var curr_date=null; 
function checkDate(format, item) { 
 
  val = item.value; 
  if (val == "") 
    return 1; 
  if (format == "DD-MON-YYYY") { 
    if (val.length == 10) 
      val="0"+val; 
    re =/\d\d-(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)-\d\d\d\d/i; 
    if(!re.test(val)) { 
      alert("should be of Format DD-MON-YYYY"); 
      item.focus(); 
      return 0; 
    } 
    mnth = convertMonthToNumber(val.substring(3,6)); 
    date = val.substring(0,2); 
    year = val.substring(7,11); 
  } else if (format == "DD-MM-YYYY") { 
    if (val.length == 8) 
      val="0"+val.substring(0,2)+"0"+val.substring(2,8); 
 
    if (val.length == 9) { 
      if (val.substring(2,3) == "-") 
        val=val.substring(0,3)+"0"+val.substring(3,9); 
      else 
        val="0"+val; 
    } 
    re =/\d\d-\d\d-\d\d\d\d/i; 
    if(!re.test(val)) { 
      alert("should be of Format DD-MM-YYYY"); 
      item.focus(); 
      return 0; 
    } 
    mnth = val.substring(3,5); 
    date = val.substring(0,2); 
    year = val.substring(6,10); 
  } else if (format == "MM-DD-YYYY") { 
 
    if (val.length == 8) 
      val="0"+val.substring(0,2)+"0"+val.substring(2,8); 
 
    if (val.length == 9) { 
      if (val.substring(2,3) == "-") 
        val=val.substring(0,3)+"0"+val.substring(3,9); 
      else 
        val="0"+val; 
    } 
    re =/\d\d-\d\d-\d\d\d\d/i; 
    if(!re.test(val)) { 
      alert("should be of Format MM-DD-YYYY"); 
      item.focus(); 
      return 0; 
    } 
    mnth = val.substring(0,2); 
    date = val.substring(3,5); 
    year = val.substring(6,10); 
  } else if (format == "MON-DD-YYYY") { 
    if (val.length == 10) 
      val=val.substring(0,4)+"0"+val.substring(5,10); 
    re =/(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)-\d\d-\d\d\d\d/i; 
    if(!re.test(val)) { 
      alert("should be of Format MON-DD-YYYY"); 
      item.focus(); 
      return 0; 
    } 
    mnth = convertMonthToNumber(val.substring(0,3)); 
    date = val.substring(5,7); 
    year = val.substring(7,11); 
  } 
 
  if (verifyDate(mnth, date, year)!=0) { 
    alert("Invalid date for format "+format); 
    item.focus(); 
    return 0; 
  } 
  return 1; 
} 

function name_values(instring) { 
	<!--  Assumption: ';' is a restricted character in a value.--> 
	<!--// Returns an array of variable names set by this function.--> 
	var vars = new Array(); 
	rc = "\235"; 
	instring = instring.replace(/\\\;/g, rc); 
 
	var pattern = /[a-zA-Z0-9]+\=[\/:#a-zA-Z0-9\. \235]+/gi; 
	var y = instring.match(pattern); 
	for (i=0; i<y.length; i++) { 
		var s = y[i].split("="); 
		s[1] = s[1].replace(rc, ";"); 
		vars[i] = "v_" + s[0]; 
		eval(vars[i] + " = '" + s[1] + "'"); 
	} 
	return vars; 
} 
var onClickFnCode = ""; 
var orig_onClickFnCode = ""; 
  
function onClickFn(pday) { 
	var re = /pday/; 
	onClickFnCode = orig_onClickFnCode; 
	onClickFnCode = onClickFnCode.replace(re, "'" + pday + "'"); 
	eval(onClickFnCode); 
} 
 
<!-- Custom parameters set by the 6th argument to show_calendar function. --> 
<!-- CUSTOM STRING --> 
var v_CloseOnSelect, v_AppendOrReplace, v_AppendChar, v_ReturnData; 
var v_InlineX, v_InlineY, v_Title, v_CurrentDate, v_AllowWeekends; 
var v_Resizable, v_Width, v_Height, v_SelectAfter, v_NSHierarchy; 
 
var weekend = [0,6]; 
var weekendColor = "#e0e0e0"; 
var fontface = "Courier New"; 
var fontsize = 2; 
 
var gNow = new Date(); 
var ggWinCal;                <!-- Really global variable pointing to the calendar window --> 
 
<!-- Drag-n-Drop Variables --> 
var theLayer; 
var theLayerStyle;		<!-- Style used for positioning in IE. --> 
 
var currX, currY; 
var cx, cy;				<!-- Client co-ords--> 
var x, y;				<!-- Co-ords of the point at first click--> 
var incrX, incrY; 
 
var mDown, mUp; 
<!-- ----------- VARIABLE DECLARATIONS END -----------> 
 
isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false; 
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false; 
 
<!-- Month names in YOUR Language (French/Spanish..)--> 
Calendar.Months = ["January", "February", "March", "April", "May", "June", 
	"July", "August", "September", "October", "November", "December"]; 
<!-- Month names in English--> 
Calendar.EMonths = ["January", "February", "March", "April", "May", "June", 
	"July", "August", "September", "October", "November", "December"]; 
 
<!-- Non-Leap year Month days..--> 
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 
<!--Leap year Month days..--> 
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 
 
Calendar.DOW = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; 
 
Calendar.supportedFormats = ["MM/DD/YYYY", "MM/DD/YY", "MM-DD-YYYY", "MM-DD-YY", "DD/MON/YYYY", "DD/MON/YY", "DD-MON-YYYY", "DD-MON-YY", "DD/MONTH/YYYY", "DD/MONTH/YY", "DD-MONTH-YYYY", "DD-MONTH-YY", "MONTH DD, YYYY", "DD/MM/YYYY", "DD/MM/YY", "DOW, DD-MON-YY"]; 
 
Calendar.count = 0; 
Calendar.Format = null; 
 
<!-- For inline calendar, the default contents of the layer. (v1.3)--> 
Calendar.gInitText = "Softricks.com Calendar"; 
 
function Calendar(p_item, p_WinCal, p_month, p_year, p_format, p_type) { 
 
	<!-- Argument p_type defines if the calendar is popup or inline--> 
 
<!--	If p_type is INLINE,    you must pass p_inline parameter which specifies the name of the layer--> 
	<!--   wich displays the calendar inline. --> 
 
 
	if ((p_month == null) && (p_year == null))      return; 
 
	if (p_WinCal == null) 
		this.gWinCal = ggWinCal; 
	else 
		this.gWinCal = p_WinCal; 
 
	if (p_month == null) { 
		this.gMonthName = null; 
		this.gMonth = null; 
		this.gYearly = true; 
	} else { 
		this.gMonthName = Calendar.get_month(p_month); 
		this.gMonth = new Number(p_month); 
		this.gYearly = false; 
	} 
 
	if (p_type == null) 
		this.gType = "POPUP"; 
	else 
		this.gType = p_type; 
 
	if (this.gType == "INLINE") { 
		this.WHO = ""; 
		this.INLINE = "Calendar";	<!-- Inline Calendar Layer name--> 
		this.codeINLINE = "";		<!-- Calendar code will be constructed in this var--> 
	} else 
		this.WHO = "window.opener."; 
 
	this.gYear = p_year; 
	this.gFormat = p_format; 
	this.gBGColor = "white"; 
	this.gFGColor = "black"; 
	this.gTextColor = "black"; 
	this.gHeaderColor = "black"; 
	this.gReturnItem = p_item; 
	this.gTitle = "Softricks.com Calendar"; 
} 
 
Calendar.get_month = Calendar_get_month; 
Calendar.get_daysofmonth = Calendar_get_daysofmonth; 
Calendar.get_dow = Calendar_get_dow; 
Calendar.calc_month_year = Calendar_calc_month_year; 
Calendar.print = Calendar_print; 
Calendar.CreateCalendarLayer = Calendar_CreateCalendarLayer; 
Calendar.Close = Calendar_Close; 
Calendar.Lwwrite = Calendar_Lwwrite; 
Calendar.MoveTo = Calendar_MoveTo; 
Calendar.isWeekend = Calendar_isWeekend; 
 
function Calendar_get_month(monthNo, pLanguage) { 
if (!pLanguage || pLanguage=="E") 
	return Calendar.EMonths[monthNo]; 
else 
	return Calendar.Months[monthNo]; 
} 
 
function Calendar_get_dow(dayNo) { 
	return Calendar.DOW[dayNo]; 
} 
 
function Calendar_get_daysofmonth(monthNo, p_year) { 
 
	<!--Check for leap year .. --> 
	<!--1.Years evenly divisible by four are normally leap years, except for--> 
 <!--	2.Years also evenly divisible by 100 are not leap years, except for--> 
	<!--3.Years also evenly divisible by 400 are leap years. --> 
 
	if ((p_year % 4) == 0) { 
			if ((p_year % 100) == 0 && (p_year % 400) != 0) 
					return Calendar.DOMonth[monthNo]; 
 
			return Calendar.lDOMonth[monthNo]; 
	} else 
			return Calendar.DOMonth[monthNo]; 
} 
 
function Calendar_calc_month_year(p_Month, p_Year, incr) { 
 
	<!--Will return an 1-D array with 1st element being the calculated month--> 
	<!--and second being the calculated year--> 
 <!--	after applying the month increment/decrement as specified by 'incr' parameter.--> 
	<!--'incr' will normally have 1/-1 to navigate thru the months.--> 
	 
	var ret_arr = new Array(); 
 
	if (incr == -1) { 
		<!-- B A C K W A R D--> 
		if (p_Month == 0) { 
			ret_arr[0] = 11; 
			ret_arr[1] = parseInt(p_Year) - 1; 
		} 
		else { 
			ret_arr[0] = parseInt(p_Month) - 1; 
			ret_arr[1] = parseInt(p_Year); 
		} 
	} else if (incr == 1) { 
		<!-- F O R W A R D--> 
		if (p_Month == 11) { 
			ret_arr[0] = 0; 
			ret_arr[1] = parseInt(p_Year) + 1; 
		} 
		else { 
			ret_arr[0] = parseInt(p_Month) + 1; 
			ret_arr[1] = parseInt(p_Year); 
		} 
	} 
 
	return ret_arr; 
} 
 
function Calendar_print() { 
	ggWinCal.print(); 
} 
 
function Calendar_isWeekend(pday) { 
	var i; 
 
	for (i=0; i<weekend.length; i++) { 
		if (pday == weekend[i]) 
			return true; 
	} 
	return false; 
} 
 
<!-- This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.--> 
new Calendar(); 
 
Calendar.prototype.setFormat = function(pFormat) { 
	var j; 
	for (j=0; j<Calendar.supportedFormats.length; j++) { 
		if (Calendar.supportedFormats[j] == pFormat) 
			Calendar.Format = pFormat; 
	} 
} 
 
Calendar.prototype.getMonthlyCalendarCode = function() { 
	var vCode = ""; 
	var vHeader_Code = ""; 
	var vData_Code = ""; 
 
	<!-- Begin Table Drawing code here..--> 
	vCode = vCode + "<TABLE WIDTH='237' BORDER=1 BGCOLOR=\"" + this.gBGColor + "\">"; 
 
	vHeader_Code = this.cal_header(); 
	vData_Code = this.cal_data(); 
	vCode = vCode + vHeader_Code + vData_Code; 
 
	vCode = vCode + "</TABLE>"; 
 
	return vCode; 
} 
 
Calendar.prototype.onclickfn = function() { 
	<!-- This should return the code string for the onclickfn in the calendar document --> 
 
	<!-- This is the reference to the return object--> 
	<!-- window.opener.document. / window.document. ... .value --> 
	var whois = this.WHO + 
				((this.gType == "POPUP") ? 
				"document." + v_NSHierarchy : 
				"window.document." + v_NSHierarchy) + 
				this.gReturnItem + ".value"; 
 
	<!-- apchar will turn out to be either " = " or " += ''" or " += ';'" --> 
	var apchar = (this.returnMode == "Replace") ? " = " : " += "; 
 
	var retCode = "apchar = ''" + 
					((this.returnMode == "Replace") ? ";" : " + ") + 
					"((" + whois + " == '') ? '' : '" + this.appendChar + "');\n" + 
				whois + apchar + "apchar + pday;\n"; 
 
	return retCode; 
} 
 
Calendar.prototype.show = function() { 
	var vCode = ""; 
 
	if (this.gType == "POPUP") 
		this.gWinCal.document.open(); 
 
	<!-- Setup the page...--> 
	this.wwrite("<html>"); 
	this.wwrite("<head><title>Calendar</title>"); 
 
	if (this.gType == "POPUP") 
		this.wwrite("<script language='javascript'>" + 
			"function onClickFn(pday) {\n" + 
			this.onclickfn() + "}\n<\/script>"); 
	else 
		orig_onClickFnCode = this.onclickfn(); 
 
	this.wwrite("</head>"); 
 
	this.wwrite("<body " + 
			"link=\"" + this.gLinkColor + "\" " + 
			"vlink=\"" + this.gLinkColor + "\" " + 
			"alink=\"" + this.gLinkColor + "\" " + 
			"text=\"" + this.gTextColor + "\">"); 
 
	this.wwrite("<TABLE WIDTH='237' BORDER=0 CELLPADDING=0 BGCOLOR='#B3B18E'><TR><TD>" + 
	"<TABLE BORDER=0 WIDTH='100%' CELLPADDING=1 BGCOLOR='#F0F0E6'>" + 
	"<TR><TD BGCOLOR='#B3B18E'>" + 
	"<FONT COLOR=white FACE='" + fontface + "' SIZE=2><B>" + this.gTitle + "</B></FONT>" + 
	"</TD><TD BGCOLOR='#B3B18E' ALIGN=RIGHT>" + 
	"<FONT COLOR=white FACE='" + fontface + "' SIZE=2><B>" + 
	"<A HREF='javascript:" + 
	this.WHO + "Calendar.Close(\"" + this.gType + "\", \"" + this.INLINE + "\");' " + 
	"STYLE='color:white'>" + 
	"x</A></B></FONT></TR><TR>" + 
	"<TD BGCOLOR='#F0F0E6' COLSPAN=2>"); 
 
	this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2><B>"); 
	this.wwriteA(this.gMonthName + " " + this.gYear); 
	this.wwriteA("</B><BR>"); 
 
	<!-- Show navigation buttons--> 
	var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1); 
	var prevMM = prevMMYYYY[0]; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -