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

📄 calendar.js

📁 电信的网厅的整站代码
💻 JS
📖 第 1 页 / 共 5 页
字号:
	s["%a"] = Calendar._SDN[w]; // abbreviated weekday name [FIXME: I18N]
	s["%A"] = Calendar._DN[w]; // full weekday name
	s["%b"] = Calendar._SMN[m]; // abbreviated month name [FIXME: I18N]
	s["%B"] = Calendar._MN[m]; // full month name
	// FIXME: %c : preferred date and time representation for the current locale
	s["%C"] = 1 + Math.floor(y / 100); // the century number
	s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
	s["%e"] = d; // the day of the month (range 1 to 31)
	// FIXME: %D : american date style: %m/%d/%y
	// FIXME: %E, %F, %G, %g, %h (man strftime)
	s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
	s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
	s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
	s["%k"] = hr;		// hour, range 0 to 23 (24h format)
	s["%l"] = ir;		// hour, range 1 to 12 (12h format)
	s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
	s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
	s["%n"] = "\n";		// a newline character
	s["%p"] = pm ? "PM" : "AM";
	s["%P"] = pm ? "pm" : "am";
	// FIXME: %r : the time in am/pm notation %I:%M:%S %p
	// FIXME: %R : the time in 24-hour notation %H:%M
	s["%s"] = Math.floor(this.getTime() / 1000);
	s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
	s["%t"] = "\t";		// a tab character
	// FIXME: %T : the time in 24-hour notation (%H:%M:%S)
	s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
	s["%u"] = w + 1;	// the day of the week (range 1 to 7, 1 = MON)
	s["%w"] = w;		// the day of the week (range 0 to 6, 0 = SUN)
	// FIXME: %x : preferred date representation for the current locale without the time
	// FIXME: %X : preferred time representation for the current locale without the date
	s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
	s["%Y"] = y;		// year with the century
	s["%%"] = "%";		// a literal '%' character

	var re = /%./g;
	if (!Calendar.is_ie5 && !Calendar.is_khtml)
		return str.replace(re, function (par) { return s[par] || par; });

	var a = str.match(re);
	for (var i = 0; i < a.length; i++) {
		var tmp = s[a[i]];
		if (tmp) {
			re = new RegExp(a[i], 'g');
			str = str.replace(re, tmp);
		}
	}

	return str;
};

Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
Date.prototype.setFullYear = function(y) {
	var d = new Date(this);
	d.__msh_oldSetFullYear(y);
	if (d.getMonth() != this.getMonth())
		this.setDate(28);
	this.__msh_oldSetFullYear(y);
};

// END: DATE OBJECT PATCHES


// global object that remembers the calendar
window._dynarch_popupCalendar = null;

//add by panlq
//添加新的时间控件
function DefineMonthView(theTextObject,hasTime){ //the month view construct function
  this.GetOnlyName = function( ){ //create one and only name on the document
    var theName = "MV"; //prefix
	var aryName = new Array();
	aryName[0] = "_MonthView"; //the month view main body's name postfix
	aryName[1] = "_MonthGrid"; //the month view day area's name postfix
	aryName[2] = "_goPreviousMonth"; //the month view go previous month button's name postfix
	aryName[3] = "_goNextMonth"; //the month view go next month button's name postfix
	aryName[4] = "_YearList"; //the month view year list's name postfix
	aryName[5] = "_MonthList"; //the month view month list's name postfix
	aryName[6] = "_DayList"; //keep the month view current day's element name postfix
	aryName[7] = "_TimeCtrl";
	aryName[8] = "_HourInput";
	aryName[9] = "_MinuteInput";
	aryName[10] = "_SecondInput";
	aryName[11] = "_Now";
	aryName[12] = "_TimeInputUp";
	aryName[13] = "_TimeInputDown";
	aryName[13] = "_TimeInput";
	
	var i = -1, j = 0, maxi = 2000;
	var exTag = true;
	while ((exTag == true) && (i < maxi)){
	  i++;
	  exTag = false;
	  for (j=0;j<aryName.length;j++){
	    if (document.all.item(theName + i.toString() + aryName[j]) != null){
		  exTag = true;
		}
	  }
	}
	if (exTag == false){
	  return(theName + i.toString());
	}else{
	  return("_" + theName);
	}
  }
  var theName = this.GetOnlyName();
  this.Name = theName; //the month view name
  this.Source = theTextObject; //the month view act on theTextObject
  this.hasTime = false;
  if (!isNaN(hasTime)&&hasTime!=null)
	this.hasTime = hasTime;
  this.MinYear = 1900; //year list min value
  //return between 1000 and 9999 and <= this.MaxYear
  this.MaxYear = 2020; //year list max value
  //return between 1000 and 9999 and >= this.MinYear
  this.Width = 250; //the month view main body's width
  this.Height = 180; //the month view main body's height
  this.DateFormat = "<yyyy>-<mm>-<dd>"; //the date format
  //<yy> or <yyyy> is year, <m> or <mm> is digital format month, <MMM> or <MMMMMM> is character format month, <d> or <dd> is day, other char unchanged
  //this function setting year, month and day sequence
  //example:
  //  <yyyy>-<mm>-<dd> : 2002-04-01
  //  <yy>.<m>.<d> : 02.4.1
  //  <yyyy> Year <MMMMMM> Month <d> Day : 2002 Year April Month 1 Day
  //  <m>/<d>/<yy> : 4/1/02
  //  <MMM> <dd>, <yyyy> : Apr 01, 2002
  //  <MMMMMM> <d>, <yyyy> : April 1, 2002
  //  <dd> <MMM> <yyyy> : 01 Apr 2002
  //  <dd>/<mm>/<yyyy> : 01/04/2002
  this.UnselectBgColor = "#FFFFFF"; //the month view default background color
  this.SelectedBgColor = "#808080"; //the selected date background color
  this.SelectedColor = "#FFFFFF"; //the selected date front color
  this.DayBdWidth = "2"; //the day unit border width, unit is px
  this.DayBdColor = this.UnselectBgColor; //the day unit border color,default is this.UnselectBgColor
  this.TodayBdColor = "#FF0000"; //denote today's date border color
  this.InvalidColor = "#808080"; //it is not current month day front color
  this.ValidColor = "#0000FF"; //it is current month day front color
  this.WeekendBgColor = this.UnselectBgColor; //the weekend background color, default is this.UnselectBgColor
  this.WeekendColor = this.ValidColor; //the weekend front color, default is  this.ValidColor
  this.YearListStyle = "font-size:12px; font-family:Verdana;"; //the year list's style
  this.MonthListStyle = "font-size:12px; font-family:Verdana;"; //the month list's style
  this.MonthName = new Array(); //month name list, font is include this.MonthListStyle
  this.MonthName[0] = "一月";
  this.MonthName[1] = "二月";
  this.MonthName[2] = "三月";
  this.MonthName[3] = "四月";
  this.MonthName[4] = "五月";
  this.MonthName[5] = "六月";
  this.MonthName[6] = "七月";
  this.MonthName[7] = "八月";
  this.MonthName[8] = "九月";
  this.MonthName[9] = "十月";
  this.MonthName[10] = "十一月";
  this.MonthName[11] = "十二月";
  this.TitleStyle = "cursor:default; color:#000000; background-color:" + this.UnselectBgColor + "; font-size:16px; font-weight:bolder; font-family:Times new roman; text-align:center; vertical-align:bottom;"; //the month view title area's style
  this.WeekName = new Array(); //week name list, font is include this.TitleStyle
  this.WeekName[0] = "日";
  this.WeekName[1] = "一";
  this.WeekName[2] = "二";
  this.WeekName[3] = "三";
  this.WeekName[4] = "四";
  this.WeekName[5] = "五";
  this.WeekName[6] = "六";
  this.FooterStyle = "cursor:hand; color:#000000; background-color:" + this.UnselectBgColor + "; font-size:12px; font-family:Verdana; text-align:left; vertical-align:middle;"; //the month footer area's style
  this.TodayTitle = "今天"; //today tip string, font is include this.FooterStyle
  this.MonthBtStyle = "font-family:Marlett; font-size:12px;"; //the change month button style
  this.PreviousMonthText = "3"; //the go previous month button text
  //font is include this.MonthBtStyle
  this.NextMonthText = "4"; //the go next month button text
  //font is include this.MonthBtStyle
  this.MonthGridStyle = "border-width:1px; border-style:solid; border-color:#000000;"; //the month view main body's default style
  this.HeaderStyle = "height:32px; background-color:menu;"; //the month view header area's style
  this.LineBgStyle = "height:10px; background-color:" + this.UnselectBgColor + "; text-align:center; vertical-align:middle;"; //the month view title area and day area compart area background style
  this.LineStyle = "width:90%; height:1px; background-color:#000000;"; //the month view title area and day area compart area front style
  this.DayStyle = "cursor:hand; font-size:12px; font-family:Verdana; text-align:center; vertical-align:middle;"; //the month view day area's style
  this.OverDayStyle = "this.style.textDecoration='underline';"; //the mouse over a day style
  this.OutDayStyle = "this.style.textDecoration='none';"; //the mouse out a day style

  this.mctr_frameborder =" border-left: 2px inset #D4D0C8; border-top: 2px inset #D4D0C8; border-right: 2px inset #FFFFFF; border-bottom: 2px inset #FFFFFF; width: 152px; height: 22px; background-color: #FFFFFF; overflow: hidden; text-align: left;        font-family: \"Tahoma\"; font-size: 12px;";
  this.mctr_arrow =" width: 16px; height: 10px; font-family: \"Marlett\"; font-size: 9px; line-height: 2px; padding-left: 2px; cursor: default;";
  this.mctr_input =" width: 18px; height: 14px; border: 0px solid black; font-family: \"Tahoma\"; font-size: 12px; text-align: right;";

  this.GetoffsetLeft = function(theObject){ //return theObject's absolute offsetLeft
    var absLeft = 0;
	var thePosition="";
    var tmpObject = theObject;
    while (tmpObject != null){
	  thePosition = tmpObject.position;
	  tmpObject.position = "static";
	  absLeft += tmpObject.offsetLeft;
	  tmpObject.position = thePosition;
	  tmpObject = tmpObject.offsetParent;
    }
    return absLeft;
  }
  this.GetoffsetTop = function(theObject){ //return theObj's absolute offsetTop
    var absTop = 0;
	var thePosition = "";
    var tmpObject = theObject;
    while (tmpObject != null){
	  thePosition = tmpObject.position;
	  tmpObject.position = "static";
      absTop += tmpObject.offsetTop;
	  tmpObject.position = thePosition;
	  tmpObject = tmpObject.offsetParent;
    }
    return absTop;
  }
  this.GetFormatYear = function(theYear){//format theYear to 4 digit
    var tmpYear = theYear;
    if (tmpYear < 100){
      tmpYear += 1900;
      if (tmpYear < 1970){
	    tmpYear += 100;
      }
    }
	if (tmpYear < this.MinYear){
	  tmpYear = this.MinYear;
	}
	if (tmpYear > this.MaxYear){
	  tmpYear = this.MaxYear;
	}
    return(tmpYear);
  }
  this.GetMonthDays = function(theYear, theMonth){ //get theYear and theMonth days number
    var theDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    var theMonthDay = 0, tmpYear = this.GetFormatYear(theYear);
    theMonthDay = theDays[theMonth];
    if (theMonth == 1){ //theMonth is February
      if(((tmpYear % 4 == 0) && (tmpYear % 100 != 0)) || (tmpYear % 400 == 0)){
	    theMonthDay++;
	  }
    }
    return(theMonthDay);
  }
  this.SetDateFormat = function(theYear, theMonth, theDay, theHour, theMinute, theSecond){//format a date to this.DateFormat
    var theDate = this.DateFormat;
	var tmpYear = this.GetFormatYear(theYear);
	var tmpMonth = theMonth;
	if (tmpMonth < 0){
	  tmpMonth = 0;
	}
	if (tmpMonth > 11){
	  tmpMonth = 11;
	}
	var tmpDay = theDay;
	if (tmpDay < 1){
	  tmpDay = 1;
	}else{
      tmpDay = this.GetMonthDays(tmpYear, tmpMonth);
      if (theDay < tmpDay){
	    tmpDay = theDay;
	  }
	}
    theDate = theDate.replace(/<yyyy>/g, tmpYear.toString());
    theDate = theDate.replace(/<yy>/g, tmpYear.toString().substr(2,2));
    theDate = theDate.replace(/<MMMMMM>/g, this.MonthName[tmpMonth]);
    theDate = theDate.replace(/<MMM>/g, this.MonthName[tmpMonth].substr(0,3));
    if (theMonth < 9){
      theDate = theDate.replace(/<mm>/g, "0" + (tmpMonth + 1).toString());
    }else{
	  theDate = theDate.replace(/<mm>/g, (tmpMonth + 1).toString());
    }
    theDate = theDate.replace(/<m>/g, (tmpMonth + 1).toString());
    if (theDay < 10){
      theDate = theDate.replace(/<dd>/g, "0" + tmpDay.toString());
    }else{
	  theDate = theDate.replace(/<dd>/g, tmpDay.toString());
    }
    theDate = theDate.replace(/<d>/g, tmpDay.toString());
	if (this.hasTime)
		theDate = theDate + " "+this.formatTime(theHour)+":"+this.formatTime(theMinute)+":"+this.formatTime(theSecond);
    return(theDate);
  }
  this.GetTextDate = function(theString){ //convert a string to a date, if the string is not a date, return a empty string
    var i = 0, tmpChar = "", find_tag = "";
    var start_at = 0, end_at = 0, year_at = 0, month_at = 0, day_at = 0;
    var tmp_at = 0, one_at = 0, two_at = 0, one_days = 0, two_days = 0;
    var aryDate = new Array();
    var tmpYear = -1, tmpMonth = -1, tmpDay = -1;

	var tmpDateTime =theString;
	tmpTime = tmpDateTime.substr(tmpDateTime.length-9,9);
	tmpDateTime = tmpDateTime.substr(0,tmpDateTime.length-9);
	var tmpDate ;
	var tmpHour = 0;
	var tmpMinute = 0;
	var tmpSecond = 0;
	if (this.hasTime){
		tmpDate = tmpDateTime.toLowerCase();
		tmpHour = parseInt(tmpTime.substr(0,tmpTime.indexOf(':')),10);
		tmpTime = tmpTime.substr(tmpTime.indexOf(':')+1,tmpTime.length);
		tmpMinute = parseInt(tmpTime.substr(0,tmpTime.indexOf(':')),10);
		tmpTime = tmpTime.substr(tmpTime.indexOf(':')+1,tmpTime.length);
		tmpSecond = parseInt(tmpTime.substr(0,tmpTime.length),10);
	}
	else
		tmpDate = theString.toLowerCase();		

	var defDate = "";
	end_at = tmpDate.length;
	for (i=1;i<end_at;i++){
	  if (tmpDate.charAt(i)=="0"){
	    tmpChar = tmpDate.charAt(i-1);
	    if (tmpChar<"0" || tmpChar>"9"){
		  tmpDate = tmpDate.substr(0,i-1) + "-" + tmpDate.substr(i+1);
		}
	  }
	}
    for (i=0;i<9;i++){
      tmpDate = tmpDate.replace(this.MonthName[i].toLowerCase().substr(0,3), "-00" + (i+1).toString() + "-");
    }
    for (i=9;i<12;i++){
      tmpDate = tmpDate.replace(this.MonthName[i].toLowerCase().substr(0,3), "-0" + (i+1).toString() + "-");
    }
    tmpDate = tmpDate.replace(/jan/g, "-001-");
    tmpDate = tmpDate.replace(/feb/g, "-002-");
    tmpDate = tmpDate.replace(/mar/g, "-003-");
    tmpDate = tmpDate.replace(/apr/g, "-004-");
    tmpDate = tmpDate.replace(/may/g, "-005-");
    tmpDate = tmpDate.replace(/jun/g, "-006-");
    tmpDate = tmpDate.replace(/jul/g, "-007-");
    tmpDate = tmpDate.replace(/aug/g, "-008-");
    tmpDate = tmpDate.replace(/sep/g, "-009-");
    tmpDate = tmpDate.replace(/oct/g, "-010-");
    tmpDate = tmpDate.replace(/nov/g, "-011-");
    tmpDate = tmpDate.replace(/dec/g, "-012-");
    for (i=0;i<tmpDate.length;i++){
      tmpChar = tmpDate.charAt(i);
      if ((tmpChar<"0" || tmpChar>"9") && (tmpChar != "-")){
	    tmpDate = tmpDate.replace(tmpChar,"-")
	  }
    }
    while(tmpDate.indexOf("--") != -1){
      tmpDate = tmpDate.replace(/--/g,"-");
    }
    start_at = 0;
    end_at = tmpDate.length-1;
    while (tmpDate.charAt(start_at)=="-"){
      start_at++;
    }
    while (tmpDate.charAt(end_at)=="-"){
      end_at--;
    }
    if (start_at < end_at+1){
      tmpDate = tmpDate.substring(start_at,end_at+1);
    }else{
      tmpDate = "";
    }
    aryDate = tmpDate.split("-");
    if (aryDate.length != 3){
      return(defDate);
    }
    for (i=0;i<3;i++){
      if (parseInt(aryDate[i],10)<1){
	    aryDate[i] = "1";
      }
    }
    find_tag="000";
    for (i=2;i>=0;i--){
      if (aryDate[i].length==3){
        if (aryDate[i]>="001" && aryDate[i]<="012"){
	      tmpMonth = parseInt(aryDate[i],10)-1;
		  switch (i){
		    case 0:
		      find_tag = "100";
			  one_at = parseInt(aryDate[1],10);
			  two_at = parseInt(aryDate[2],10);
			  break;
		    case 1:
		      find_tag = "010";
			  one_at = parseInt(aryDate[0],10);
			  two_at = parseInt(aryDate[2],10);
			  break;
		    case 2:
		      find_tag = "001";
			  one_at = parseInt(aryDate[0],10);
			  two_at = parseInt(aryDate[1],10);
			  break;
		  }
	    }
	  }
    }
    if (find_tag!="000"){
	  one_days = this.GetMonthDays(two_at,tmpMonth);
	  two_days = this.GetMonthDays(one_at,tmpMonth);
	  if ((one_at>one_days)&&(two_at>two_days)){
	    return(defDate);
	  }
      if ((one_at<=one_days)&&(two_at>two_days)){
	    tmpYear = this.GetFormatYear(two_at);
	    tmpDay = one_at;
	  }
	  if ((one_at>one_days)&&(two_at<=two_days)){
	    tmpYear = this.GetFormatYear(one_at);
	    tmpDay = two_at;
	  }
	  if ((one_at<=one_days)&&(two_at<=two_days)){
	    tmpYear = this.GetFormatYear(one_at);
	    tmpDay = two_at;
	    tmpDate = this.DateFormat;
	    year_at = tmpDate.indexOf("<yyyy>");
	    if (year_at == -1){
	      year_at = tmpDate.indexOf("<yy>");
	    }
	    day_at = tmpDate.indexOf("<dd>");
	    if (day_at == -1){
	      day_at = tmpDate.indexOf("<d>");
	    }
	    if (year_at >= day_at){
	      tmpYear = this.GetFormatYear(two_at);
		  tmpDay = one_at;
	    }
  	  }
	  return(new Date(tmpYear, tmpMonth, tmpDay,tmpHour,tmpMinute,tmpSecond));
    }
    find_tag = "000";
    for (i=2;i>=0;i--){
      if (parseInt(aryDate[i],10)>31){
	    tmpYear = this.GetFormatYear(parseInt(aryDate[i],10));
	    switch (i){
	      case 0:
	        find_tag = "100";
		    one_at = parseInt(aryDate[1],10);
		    two_at = parseInt(aryDate[2],10);
		    break;
	      case 1:
	        find_tag = "010";
		    one_at = parseInt(aryDate[0],10);
		    two_at = parseInt(aryDate[2],10);

⌨️ 快捷键说明

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