<%
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
'''' ''''
"' Calendar Version 1.0 '"
"' by Xinsoft, 2004-10-22 '"
"' Blogchina.com & chinalabs.com '"
'''' ''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
Class Calendar
Public Lang
Public Dateval
Public Prevylink,nextylink
Public Prevmlink,nextmlink
"" "Temp Var
Private Pweekdaystext
"' HTML Parameters
Public Linkstyleclass
Public Table_class
Public Table_width
Public Table_bgcolor
Public Table_title_style
Public Table_title_bgcolor
Private Table_title_text
Public Tdbgcolor_light
Public Tdbgcolor_dark
Public Tdbgcolor_gray
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
''''
"' Meta functions
''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
Private Sub Print (str)
Response.Write Str & VBCRLF
End Sub
Private Sub Echo (str)
Response.Write Str
End Sub
Private Sub Echopara (str, Val)
If "" <> "" &val Then Response.Write "" & str & "=" "& Val &" ""
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
''''
"' HTML functions
''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
Private Sub Printtablehead
Echo "<table"
Echopara "Class", Table_class
Echopara "width", table_width
Echopara "bgcolor", Table_bgcolor
Echo "cellspacing=" "1" "cellpadding=" "1" ""
Echo "align=" "Center" ""
Echo "border=" "0" ""
Print "><tbody>"
End Sub
Private Sub Printtabletail
Print ""
Echo "</tbody></table>"
End Sub
Private Sub Printtabletitle
Print "<tr>"
Echo "<TD"
Echopara "Style", Table_title_style
Echopara "bgcolor", Table_title_bgcolor
Echopara "colspan", "7"
Echo ">"
Echo "<b>" & Table_title_text & "</b>"
Print "</td>"
Print "</tr>"
End Sub
Private Sub Setweekdaystext_chs ()
Pweekdaystext (0) = "Day"
Pweekdaystext (1) = "One"
Pweekdaystext (2) = "Two"
Pweekdaystext (3) = "three"
Pweekdaystext (4) = "Four"
Pweekdaystext (5) = "Five"
Pweekdaystext (6) = "Six"
End Sub
Private Sub Setweekdaystext_enu ()
Pweekdaystext (0) = "Su"
Pweekdaystext (1) = "M"
Pweekdaystext (2) = "Tu"
Pweekdaystext (3) = "W"
Pweekdaystext (4) = "Th"
Pweekdaystext (5) = "F"
Pweekdaystext (6) = "Sa"
End Sub
Private Sub Setweekdaystext ()
Select Case Lang
Case "CHS": Setweekdaystext_chs
Case "ENU": Setweekdaystext_enu
Case Else:setweekdaystext_enu
End Select
End Sub
Private function Monthtext_chs (monthval)
Dim STR
If monthval<10 Then
Str= "0" &monthval
Else
Str=monthval
End If
MONTHTEXT_CHS=STR & "Month"
End Function
Private function Monthtext_enu (monthval)
Select Case "" &monthval
Case "1": monthtext_enu= "January"
Case "2": monthtext_enu= "February"
Case "3": monthtext_enu= "March"
Case "4": monthtext_enu= "April"
Case "5": monthtext_enu= "may"
Case "6": monthtext_enu= "June"
Case "7": monthtext_enu= "July"
Case "8": monthtext_enu= "August"
Case "9": monthtext_enu= "September"
Case "Ten": monthtext_enu= "October"
Case "One": monthtext_enu= "November"
Case "a": monthtext_enu= "December"
End Select
End Function
Private function Monthtext (monthval)
Select Case Lang
Case "CHS": Monthtext=monthtext_chs (Monthval)
Case Else:monthtext=monthtext_enu (Monthval)
End Select
End Function
Private function Yeartext (yearval)
Select Case Lang
Case "CHS": Yeartext=yearval & "Year"
Case Else:yeartext=yearval
End Select
End Function
Private Sub Settable_title_text ()
Dim Monthval
Monthval=month (Dateval)
Dim Yeartext
Yeartext=year (Dateval)
Select Case Lang
Case "CHS": yeartext=yeartext& "Year"
Case Else:yeartext=yeartext
End Select
Dim Daytext
Daytext=day (Dateval)
If 10>daytext Then daytext= "0" & Daytext
Select Case Lang
Case "CHS": Table_title_text=monthtext_chs (Monthval)
Case Else:table_title_text=monthtext_enu (Monthval)
End Select
Select Case Lang
Case "CHS": Table_title_text=yeartext & Table_title_text & Daytext & "Day"
Case Else:table_title_text=table_title_text & "' & Day (Dateval) &", "& Yeartext
End Select
End Sub
Private Sub Printweekdaystr ()
Dim I
Print "<tr>"
For I=0 to 6
Echo "<TD"
Echopara "Align", "center"
Echopara "valign", "Middle"
Echopara "bgcolor", Tdbgcolor_dark
Echo ">"
Select Case Lang
Case "CHS": Echo pweekdaystext (i)
Case "ENU": Echo "<b>" & Pweekdaystext (i) & "</b>"
Case Else:echo "<b>" & Pweekdaystext (i) & "</b>"
End Select
Echo "</td>"
Next
Print "</tr>"
End Sub
Private Sub Printymchooser ()
Dim M,y
M=month (Dateval)
Y=year (Dateval)
Print "<tr>"
Echo "<TD"
Echopara "Align", "center"
Echopara "valign", "Middle"
Echopara "bgcolor", Tdbgcolor_dark
Echopara "colspan", "7"
Echo ">"
"' Year chooser
Echo "<a"
Echopara "Class", Linkstyleclass
Echopara "href", Prevylink
Echo ">"
Echo "<span style=" "Font-family:webdings" ">3</span></a><b>" & Yeartext (Y) & "</b > "
Echo "<a"
Echopara "Class", Linkstyleclass
Echopara "href", Nextylink
Echo "</td>"
Echo "<span style=" "Font-family:webdings" ">4</span></a>"
Echo ""
"" "Month Chooser
Echo "<a"
Echopara "Class", Linkstyleclass
Echopara "href", Prevmlink
Echo ">"
Echo "<span style=" "Font-family:webdings" ">3</span></a><b>" & Monthtext (M) & "</b > "
Echo "<a"
Echopara "Class", Linkstyleclass
Echopara "href", Nextmlink
Echo "</td>"
Echo "<span style=" "Font-family:webdings" ">4</span></a>"
Print "</tr>"
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
''''
"" "Date functions
''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
Private Cury,curm,curd
Private Curm_begindateval,curm_enddateval
Private Curm_dayscount
Private Curm_beginweekday,curm_endweekday
Private curm_begin_leftdays,curm_end_rightdays
Private Curm_tdcount,curm_lines
Private cellarray,cellx,celly
Public itemdate
Public Itemtext
Public Itemlink
Public ITEMBG
Public Function idx2d_1d (x,y)
Idx2d_1d=cellx*y+x-curm_begin_leftdays
If idx2d_1d<0 Then Idx2d_1d=-1
If Idx2d_1d>=curm_dayscount Then idx2d_1d=-2
End Function
Private Sub Initdatepara ()
Cury=year (Dateval)
Curm=month (Dateval)
Curd=day (Dateval)
curm_begindateval=cury& "-" &curM& "-1"
Curm_enddateval=dateadd ("M", 1, Curm_begindateval)
Curm_enddateval=dateadd ("D", -1, Curm_enddateval)
Curm_dayscount=datediff ("D", Curm_begindateval, Curm_enddateval) +1
Curm_beginweekday =weekday (curm_begindateval, 1)
Curm_endweekday =weekday (curm_enddateval, 1)
Curm_begin_leftdays =curm_beginweekday-1
Curm_end_rightdays =7-curm_endweekday
Curm_tdcount=curm_dayscount + curm_begin_leftdays + curm_end_rightdays
Curm_lines =CURM_TDCOUNT/7
Cellx=7
Celly=curm_lines
ReDim Cellarray (cellx,celly)
ReDim itemdate (Curm_dayscount)
ReDim Itemtext (Curm_dayscount)
ReDim Itemlink (Curm_dayscount)
ReDim ITEMBG (Curm_dayscount)
Dim I,j
For I=0 to Curm_dayscount-1
Itemdate (i) =cury& "-" &curM& "-" &cstr (i+1)
Itemtext (i) =cstr (i+1)
Itemlink (i) = ""
ITEMBG (i) =tdbgcolor_light
If curd=i+1 Then ITEMBG (i) =tdbgcolor_gray
Next
End Sub
Property Let Date (g)
Dateval=g
Initdatepara
End Property
Private Sub Printdaytds ()
Dim I,j
Dim x
For I=0 to CellY-1
Print "<tr>"
For J=0 to CellX-1
X=IDX2D_1D (J,i)
Echo "<TD"
Echopara "Style", "FONT-SIZE:9PX;" Font-family:sans-serif "
Echopara "Align", "center"
Echopara "valign", "Middle"
If x>=0 Then
Echopara "bgcolor", ITEMBG (x)
Else
Echopara "bgcolor", "#ffffff"
End If
Echo ">"
If x>=0 Then
If "" = "" &itemlink (x) Then
Echo x+1
Else
Echo "<a"
Echopara "href", Itemlink (x)
Echopara "Class", Linkstyleclass
Echo ">"
Echo x+1
Echo "</a>"
End If
Else
Echo "End If
Print "</td>"
Next
Print "</tr>"
Next
End Sub
Private Sub Class_Initialize
Lang= "CHS"
Dateval=now
Initdatepara
Prevylink= ""
Nextylink= ""
Prevmlink= ""
Nextmlink= ""
linkstyleclass= "Calendar"
Table_class= "Cabox"
Table_width= "180"
Table_bgcolor= "#c8ccc8"
Table_title_style= "FONT-SIZE:9PX; COLOR: #ffffff; Font-family:sans-serif "
Table_title_bgcolor= "#d56324"
tdbgcolor_light= "#ffffff"
Tdbgcolor_dark = "#f0f0f0"
Tdbgcolor_gray = "#efefef"
ReDim Pweekdaystext (7)
Setweekdaystext
End Sub
Private Sub Class_Terminate
End Sub
Public Sub Exec ()
Printtablehead
Settable_title_text
Printtabletitle
Printweekdaystr
Printdaytds
Printymchooser
Printtabletail
End Sub
End Class
%>
echo ............. I'm sweating.