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

📄 calendar.asp

📁 一个用jsp 编写的个人主页网站哦。希望对大家有所帮助啊
💻 ASP
字号:
<%@ Language=VBScript %>
<%  Option Explicit %>
<% 
    Function FormatStr(String)
      ' Replaces a double carrige return with a paragraph break
      ' a single carrige return with a break rule and CHR(13) with nothing
      String = Replace(String, CHR(13), "")
      String = Replace(String, CHR(10) & CHR(10), "</P><P>")
      String = Replace(String, CHR(10), "<BR>")
      FormatStr = String
    End Function

' ---------- Page Variables ----------
    Const intCharToShow = 19		' The number of characters shown in each day
    Const bolEditable   = True		' If the calendar is editable or not (Can be tied into password verification)

    Dim dtToday 			' Today's Date
    Dim dtCurrentDate			' The current date
    Dim aCalendarDays(42)		' Array of possible calendar dates
    Dim iFirstDayOfMonth		' The first day of the month
    Dim iDaysInMonth	 		' The number of days in the month
    Dim iColumns, iRows	, iDay, iWeek	' The numer of columns and rows in the table, and counters to print them
    Dim objConn, strConn, strSQL, objRS ' Database Variables
    Dim counter 			' Loop counter
    Dim strNextMonth, strPrevMonth	' The next and previous month dates
    Dim dailyMsg			' The message for the day
    Dim dtOnDay				' The current day being displayed by the loops
    Dim strPage				' The link that each day takes you too

' ---------- Variable Definitions ----------
    dtToday 	  = Date()

    If Request("currentDate") <> "" Then
      dtCurrentDate = Request("currentDate")
    Else
      dtCurrentDate = dtToday
    End If

    iFirstDayOfMonth = DatePart("w", DateSerial(Year(dtCurrentDate), Month(dtCurrentDate), 1))
    iDaysInMonth = DatePart("d", DateSerial(Year(dtCurrentDate), Month(dtCurrentDate)+1, 1-1))

    For counter = 1 to iDaysInMonth
      aCalendarDays(counter + iFirstDayOfMonth - 1) = counter
    Next

    iColumns = 7
    iRows    = 6 - Int((42 - (iFirstDayOfMonth + iDaysInMonth)) / 7)

    strPrevMonth = Server.URLEncode(DateAdd("m", -1, dtCurrentDate))
    strNextMonth = Server.URLEncode(DateAdd("m",  1, dtCurrentDate))

' ---------- Drawing the Calendar ----------
%>

<HTML>
<HEAD>
  <TITLE>Caledar - <%= MonthName(Month(dtCurrentDate)) & " " & Year(dtCurrentDate) %></TITLE>
  <STYLE TYPE="text/css">
    <!--
    BODY 	    {background-color: #ffffff; text-align: center; font-size: 12px; font-family: Verdana;margin-left: 0px;margin-top: 0px;}
    A 		    {text-decoration: none;}
    A:active 	    {color: #000000;}
    A:visited 	    {color: #000000;}
    A:link 	    {color: #000000;}
    A:hover 	    {color: #D80E0E;}
    .blackBacking   {background-color: #cccccc;}
    .names 	    {background-color: #ffffff; font-size: 13px; color: #000000; text-decoration: none; text-align:  center; font-family: Verdana; font-weight: bold;}
    .calendarBody   {background-color: #F2EBCB; font-size: 12px; color: #cccccc; text-decoration: none; text-align:  center; font-family: Verdana;}
    .calCurrentDay  {background-color: #cccccc; font-size: 11px; color: #ffffff;}
    .calOtherDay    {background-color: #ffffff; font-size: 11px; color: #cccccc;}
    .calNotDay	    {background-color: #ffffff; font-size: 11px; color: #cccccc;}
    .calFormMenu    {background-color: #ffffff; font-size: 13px; color: #000000;}
    -->
  </STYLE>
</HEAD>
<BODY>
  <FORM NAME="pageForm" ACTION="calendar.asp" METHOD="GET">
  <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 width=144>
    <TR>
      <TD CLASS="blackBacking">
	<TABLE CELLSPACING=1 CELLPADDING=1 BORDER=0>
  	  <TR>
  	    <TD CLASS="names" COLSPAN=7>
	      <A HREF="calendar.asp?currentDate=<%= strPrevMonth %>">&laquo;</A>
	      &nbsp;
	      <SELECT NAME="currentDate" CLASS="calFormMenu" onChange="pageForm.submit()">
	      <% For counter = 1 to 12 %>
	        <OPTION VALUE="<%= DateSerial(Year(dtCurrentDate), counter, 1) %>"<% If (DatePart("m", dtCurrentDate) = counter) Then Response.Write "SELECTED"%>><%=MonthName(counter)&""&Year(dtCurrentDate)%></OPTION>
	      <% Next %>
	      </SELECT>
	      &nbsp;
	      <A HREF="calendar.asp?currentDate=<%= strNextMonth %>">&raquo;</A> 
            </TD>
          </TR>
	  <!-- Writring the days of the week for headers -->
    <TR VALIGN="TOP" ALIGN="CENTER">
            <% For iDay = vbSunday To vbSaturday %>

            <% Next %>
    <td width="14%" class="names"> 日</td>
    <td width="14%" class="names"> 一</td>
    <td width="14%" class="names"> 二</td>
    <td width="14%" class="names"> 三</td>
    <td width="14%" class="names"> 四</td>
    <td width="14%" class="names"> 五</td>
    <td width="14%" class="names"> 六</td>
    </TR>
<%
    Set objConn = Server.CreateObject("ADODB.Connection")
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("../db/liyu_1984x.mdb") & ";Persist Security Info=False;"
    objConn.Open(strConn) 

    For iWeek = 1 To iRows
      Response.Write "<TR VALIGN=TOP>"
      For iDay = 1 To iColumns
	' Checks to see if there is a day this month on the date being written
	If aCalendarDays((iWeek-1)*7 + iDay) > 0 then
	  dtOnDay = DateSerial(Year(dtCurrentDate), Month(dtCurrentDate), aCalendarDays((iWeek-1)*7 + iDay))

	  ' Checks to see if the day being printed is today
	  If dtOnDay = dtToday Then
	    Response.Write "<TD CLASS='calCurrentDay'>"
 	  Else
   	    Response.Write "<TD CLASS='calOtherDay'>"
 	  End If

	  ' Checks for a message on the day being written
	  strSQL = "SELECT * FROM dairy WHERE dateandtime = #" & dtOnDay & "#"
	  Set objRS = objConn.Execute(strSQL)
	  If NOT objRS.EOF Then 
	    dailyMsg = "red"
  	    strPage = "<a href=# alt=有日记" & dtOnDay & ">"
	  Else 
	    dailyMsg = "#000000"
  	    strPage = ""
	  End If
	  Set objRS = Nothing

	  ' Checks to see if the message is too long to be displayed in the mini date box
          If (Trim(dailyMsg) = Trim(Left(dailyMsg, intCharToShow))) Then
	  Else 
	     dailyMsg = Trim(Left(dailyMsg, intCharToShow-4)) & " ..."
          End If

 	  Response.Write ("" & strPage & "&nbsp;<font color=" & FormatStr(dailyMsg) & ">" & aCalendarDays((iWeek-1)*7 + iDay) & "</font></a>")
	Else 
	  Response.Write ("<TD CLASS='calNotDay'>&nbsp;")
	End IF

	Response.Write "</TD>"
      Next
      Response.Write "</TR>"
    Next

    objConn.Close
    set objConn = Nothing
%>

</TABLE>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>

⌨️ 快捷键说明

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