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

📄 calendarforworkplan.htc

📁 企业办公自动化管理系统 asp+sql server 2005
💻 HTC
📖 第 1 页 / 共 5 页
字号:
//
//  Function:  fnSetDate
//
//  Synopsis:  The fnSetDate function is used internally to set the day,
//             month, and year values.  
//
//  Arguments: iDay     The new day
//             iMonth   The new month  
//             iYear    The new year
//
//  Returns:   none
//
//  Notes:     It does some error checking and some minor performance 
//             optimizations if the month & year are not being changed.
//
//------------------------------------------------------------------------

function fnSetDate(iDay, iMonth, iYear)
{
  var bValueChange = false
  if (gbValueIsNull)
  { 
    gbValueIsNull = false
    fnFireOnPropertyChange("propertyName", "valueIsNull")
  }

  if (iYear < giMinYear) iYear = giMinYear
  if (iYear > giMaxYear) iYear = giMaxYear
  if (giYear != iYear)
  {
    fnCheckLeapYear(iYear)
  }

  if (iMonth < 1) iMonth = 1
  if (iMonth > 12) iMonth = 12

  if (iDay < 1) iDay = 1
  if (iDay > gaMonthDays[giMonth - 1]) iDay = gaMonthDays[giMonth - 1]

  if ((giDay == iDay) && (giMonth == iMonth) && (giYear == iYear))
    return
  else
    bValueChange = true
  
  if (giDay != iDay) 
  {
    giDay = iDay
    fnFireOnPropertyChange("propertyName", "day")
  }

  if ((giYear == iYear) && (giMonth == iMonth))
  {
    goCurrentDayCell.className = 'Day_' + uniqueID 

    //当前日期加红显示
    if ((gcurrentYear == iYear) && (gcurrentMonth == iMonth))
     { 
        goCurrentDayCell = gaDayCell[giStartDayIndex + gcurrentDay - 1]
	goCurrentDayCell.className = 'CurrentDay_' + uniqueID
     }

    goCurrentDayCell = gaDayCell[giStartDayIndex + iDay - 1]
    goCurrentDayCell.className = 'DaySelected_' + uniqueID
    giDay = iDay
  }
  else 
  {

    if (giYear != iYear)
    {
      giYear = iYear
      fnFireOnPropertyChange("propertyName", "year")
      fnUpdateYearSelect()
    }
    
    if (giMonth != iMonth) 
    {
      giMonth = iMonth
      fnFireOnPropertyChange("propertyName", "month")
      fnUpdateMonthSelect()
    }
 
    fnUpdateTitle()   
    fnFillInCells()
  }
  
  if (bValueChange) fnFireOnPropertyChange("propertyName", "value")
}

//------------------------------------------------------------------------
//
//  Function:  fnUpdateTitle
//
//  Synopsis:  This function updates the title with the currently selected
//             month and year.  The month is displayed in the format
//             specified by the monthLength option
//
//  Arguments: none
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnUpdateTitle()
{
  var oTitleCell = element.children[0].rows[0].cells[0]
  if (gbShowTitle)
    oTitleCell.innerHTML = gaMonthNames[giMonthLength][giMonth - 1] + " " + giYear
  else 
	oTitleCell.innerHTML = ' '
}

//------------------------------------------------------------------------
//
//  Function:  fnUpdateDayTitles
//
//  Synopsis:  This function updates the titles for the days of the week.
//             They are displayed in the format specified by the dayLength 
//             option beginning with the day of the week specified by the
//             firstDay option.
//
//  Arguments: none
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnUpdateDayTitles()
{
  var dayTitleRow = element.children[0].rows[1].cells[0].children[0].rows[0]
  var iCell = 0

  for (i=giFirstDay ; i < 7 ; i++)
  {
    goDayTitleRow.cells[iCell++].innerText = gaDayNames[giDayLength][i]
  }
 
  for (i=0; i < giFirstDay; i++)
  {
    goDayTitleRow.cells[iCell++].innerText = gaDayNames[giDayLength][i]
  }
}

//------------------------------------------------------------------------
//
//  Function:  fnUpdateMonthSelect
//
//  Synopsis:  When the month changes, this function is called to select
//             the correct month in the month select control.
//
//  Arguments: none
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnUpdateMonthSelect()
{
  goMonthSelect.options[ giMonth - 1 ].selected = true
}

//------------------------------------------------------------------------
//
//  Function:  fnBuildMonthSelect
//
//  Synopsis:  When the calendar is created, this function inserts the 
//             month values into the select control and selects the 
//             current month.
//
//  Arguments: none
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnBuildMonthSelect()
{
  var newMonthSelect

  newMonthSelect = element.document.createElement("SELECT")
  goMonthSelect.parentElement.replaceChild(newMonthSelect, goMonthSelect)
  goMonthSelect = newMonthSelect

  for (i=0 ; i < 12; i++)
  {
    e = element.document.createElement("OPTION")
    e.text = gaMonthNames[giMonthLength][i]
    goMonthSelect.options.add(e)
  }

  goMonthSelect.options[ giMonth - 1 ].selected = true
  goMonthSelect.attachEvent("onchange", fnMonthSelectOnChange)
}

//------------------------------------------------------------------------
//
//  Function:  fnMonthSelectOnChange
//
//  Synopsis:  When the a_user changes the month using the month select 
//             control, this function handles the onSelectChange event
//             to update the date.
//
//  Arguments: none
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnMonthSelectOnChange()
{
  iMonth = goMonthSelect.selectedIndex + 1
  fnSetDate(giDay, iMonth, giYear)
}

//------------------------------------------------------------------------
//
//  Function:  fnUpdateYearSelect
//
//  Synopsis:  When the year changes, this function is called to select
//             the correct year in the year select control.
//
//  Arguments: none
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnUpdateYearSelect()
{
  goYearSelect.options[ giYear - giMinYear ].selected = true
}

//------------------------------------------------------------------------
//
//  Function:  fnBuildYearSelect
//
//  Synopsis:  When the calendar is created, this function inserts the 
//             year values into the select control and selects the 
//             current year.
//
//  Arguments: none
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnBuildYearSelect()
{
  var newYearSelect
  newYearSelect = element.document.createElement("SELECT")
  goYearSelect.parentElement.replaceChild(newYearSelect, goYearSelect)
  goYearSelect = newYearSelect

  for (i=giMinYear; i <= giMaxYear; i++)
  {
    e = element.document.createElement("OPTION")
    e.text = i
    goYearSelect.options.add(e)
  }

  goYearSelect.options[ giYear - giMinYear ].selected = true
  goYearSelect.attachEvent("onchange", fnYearSelectOnChange)
}

//------------------------------------------------------------------------
//
//  Function:  fnYearSelectOnChange
//
//  Synopsis:  When the a_user changes the year using the year select 
//             control, this function handles the onSelectChange event
//             to update the date.
//
//  Arguments: none
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnYearSelectOnChange()
{
  iYear = goYearSelect.selectedIndex + giMinYear
  fnSetDate(giDay, giMonth, iYear)
}

//------------------------------------------------------------------------
//
//  Function:  fnCheckLeapYear
//
//  Synopsis:  When the year changes, this function must be called to 
//             ensure that February has the correct count for the number
//             of days.
//
//  Arguments: year
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnCheckLeapYear(iYear)
{
  gaMonthDays[1] = (((!(iYear % 4)) && (iYear % 100) ) || !(iYear % 400)) ? 29 : 28
}

//------------------------------------------------------------------------
//
//  Function:  fnFillInCells
//
//  Synopsis:  This method works through the table and sets the day and
//             style needed.
//
//  Arguments: none
//
//  Returns:   none
//
//  Notes:     none
//
//------------------------------------------------------------------------

function fnFillInCells()
{
  var iDayCell = 0
  var iLastMonthIndex, iNextMonthIndex
  var iLastMonthTotalDays

  var iStartDay

  fnCheckLeapYear(giYear)

  iLastMonthDays = gaMonthDays[ ((giMonth - 1 == 0) ? 12 : giMonth - 1) - 1]
  iNextMonthDays = gaMonthDays[ ((giMonth + 1 == 13) ? 1 : giMonth + 1) - 1]

  iLastMonthYear = (giMonth == 1)  ? giYear - 1 : giYear
  iLastMonth     = (giMonth == 1)  ? 12         : giMonth - 1 
  iNextMonthYear = (giMonth == 12) ? giYear + 1 : giYear
  iNextMonth     = (giMonth == 12) ? 1          : giMonth + 1 

  var oDate = new Date(giYear, (giMonth - 1), 1)

  iStartDay = oDate.getDay() - giFirstDay
  if (iStartDay < 1) iStartDay += 7
  iStartDay = iLastMonthDays - iStartDay + 1

  for (i = iStartDay ; i <= iLastMonthDays  ; i++ , iDayCell++)
  {
     gaDayCell[iDayCell].innerText = i
     if (gaDayCell[iDayCell].className != 'OffDay_' + uniqueID)
     gaDayCell[iDayCell].className = 'OffDay_' + uniqueID

     gaDayCell[iDayCell].day = i
     gaDayCell[iDayCell].month = iLastMonth
     gaDayCell[iDayCell].year = iLastMonthYear
  }

  giStartDayIndex = iDayCell

⌨️ 快捷键说明

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