| 119 |
ghuddy |
1 |
// calendar
|
|
|
2 |
|
|
|
3 |
var weekend = [0,6];
|
|
|
4 |
var weekendColor = "#e0e0e0";
|
|
|
5 |
var fontface = "tahoma,sans-serif";
|
|
|
6 |
var fontsize = 2;
|
|
|
7 |
|
|
|
8 |
var gNow = new Date();
|
|
|
9 |
var ggWinCal;
|
|
|
10 |
isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
|
|
|
11 |
isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
|
|
|
12 |
|
|
|
13 |
Calendar.Months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
|
14 |
|
|
|
15 |
// Non-Leap year Month days..
|
|
|
16 |
Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
|
17 |
// Leap year Month days..
|
|
|
18 |
Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
|
19 |
|
|
|
20 |
function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
|
|
|
21 |
if ((p_month == null) && (p_year == null)) return;
|
|
|
22 |
|
|
|
23 |
if (p_WinCal == null)
|
|
|
24 |
this.gWinCal = ggWinCal;
|
|
|
25 |
else
|
|
|
26 |
this.gWinCal = p_WinCal;
|
|
|
27 |
|
|
|
28 |
if (p_month == null) {
|
|
|
29 |
this.gMonthName = null;
|
|
|
30 |
this.gMonth = null;
|
|
|
31 |
this.gYearly = true;
|
|
|
32 |
} else {
|
|
|
33 |
this.gMonthName = Calendar.get_month(p_month);
|
|
|
34 |
this.gMonth = new Number(p_month);
|
|
|
35 |
this.gYearly = false;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
this.gYear = p_year;
|
|
|
39 |
this.gFormat = p_format;
|
|
|
40 |
this.gBGColor = "white";
|
|
|
41 |
this.gFGColor = "black";
|
|
|
42 |
this.gTextColor = "black";
|
|
|
43 |
this.gHeaderColor = "black";
|
|
|
44 |
this.gReturnItem = p_item;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
Calendar.get_month = Calendar_get_month;
|
|
|
48 |
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
|
|
|
49 |
Calendar.calc_month_year = Calendar_calc_month_year;
|
|
|
50 |
Calendar.print = Calendar_print;
|
|
|
51 |
|
|
|
52 |
function Calendar_get_month(monthNo) {
|
|
|
53 |
return Calendar.Months[monthNo];
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
function Calendar_get_daysofmonth(monthNo, p_year) {
|
|
|
57 |
/*
|
|
|
58 |
Check for leap year ..
|
|
|
59 |
1.Years evenly divisible by four are normally leap years, except for...
|
|
|
60 |
2.Years also evenly divisible by 100 are not leap years, except for...
|
|
|
61 |
3.Years also evenly divisible by 400 are leap years.
|
|
|
62 |
*/
|
|
|
63 |
if ((p_year % 4) == 0) {
|
|
|
64 |
if ((p_year % 100) == 0 && (p_year % 400) != 0)
|
|
|
65 |
return Calendar.DOMonth[monthNo];
|
|
|
66 |
|
|
|
67 |
return Calendar.lDOMonth[monthNo];
|
|
|
68 |
} else
|
|
|
69 |
return Calendar.DOMonth[monthNo];
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
function Calendar_calc_month_year(p_Month, p_Year, incr) {
|
|
|
73 |
/*
|
|
|
74 |
Will return an 1-D array with 1st element being the calculated month
|
|
|
75 |
and second being the calculated year
|
|
|
76 |
after applying the month increment/decrement as specified by 'incr' parameter.
|
|
|
77 |
'incr' will normally have 1/-1 to navigate thru the months.
|
|
|
78 |
*/
|
|
|
79 |
var ret_arr = new Array();
|
|
|
80 |
|
|
|
81 |
if (incr == -1) {
|
|
|
82 |
// B A C K W A R D
|
|
|
83 |
if (p_Month == 0) {
|
|
|
84 |
ret_arr[0] = 11;
|
|
|
85 |
ret_arr[1] = parseInt(p_Year) - 1;
|
|
|
86 |
}
|
|
|
87 |
else {
|
|
|
88 |
ret_arr[0] = parseInt(p_Month) - 1;
|
|
|
89 |
ret_arr[1] = parseInt(p_Year);
|
|
|
90 |
}
|
|
|
91 |
} else if (incr == 1) {
|
|
|
92 |
// F O R W A R D
|
|
|
93 |
if (p_Month == 11) {
|
|
|
94 |
ret_arr[0] = 0;
|
|
|
95 |
ret_arr[1] = parseInt(p_Year) + 1;
|
|
|
96 |
}
|
|
|
97 |
else {
|
|
|
98 |
ret_arr[0] = parseInt(p_Month) + 1;
|
|
|
99 |
ret_arr[1] = parseInt(p_Year);
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
return ret_arr;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
function Calendar_print() {
|
|
|
107 |
ggWinCal.print();
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
function Calendar_calc_month_year(p_Month, p_Year, incr) {
|
|
|
111 |
/*
|
|
|
112 |
Will return an 1-D array with 1st element being the calculated month
|
|
|
113 |
and second being the calculated year
|
|
|
114 |
after applying the month increment/decrement as specified by 'incr' parameter.
|
|
|
115 |
'incr' will normally have 1/-1 to navigate thru the months.
|
|
|
116 |
*/
|
|
|
117 |
var ret_arr = new Array();
|
|
|
118 |
|
|
|
119 |
if (incr == -1) {
|
|
|
120 |
// B A C K W A R D
|
|
|
121 |
if (p_Month == 0) {
|
|
|
122 |
ret_arr[0] = 11;
|
|
|
123 |
ret_arr[1] = parseInt(p_Year) - 1;
|
|
|
124 |
}
|
|
|
125 |
else {
|
|
|
126 |
ret_arr[0] = parseInt(p_Month) - 1;
|
|
|
127 |
ret_arr[1] = parseInt(p_Year);
|
|
|
128 |
}
|
|
|
129 |
} else if (incr == 1) {
|
|
|
130 |
// F O R W A R D
|
|
|
131 |
if (p_Month == 11) {
|
|
|
132 |
ret_arr[0] = 0;
|
|
|
133 |
ret_arr[1] = parseInt(p_Year) + 1;
|
|
|
134 |
}
|
|
|
135 |
else {
|
|
|
136 |
ret_arr[0] = parseInt(p_Month) + 1;
|
|
|
137 |
ret_arr[1] = parseInt(p_Year);
|
|
|
138 |
}
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
return ret_arr;
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
// This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
|
|
|
145 |
new Calendar();
|
|
|
146 |
|
|
|
147 |
Calendar.prototype.getMonthlyCalendarCode = function() {
|
|
|
148 |
var vCode = "";
|
|
|
149 |
var vHeader_Code = "";
|
|
|
150 |
var vData_Code = "";
|
|
|
151 |
|
|
|
152 |
// Begin Table Drawing code here..
|
|
|
153 |
vCode = vCode + "<TABLE BORDER=1 BGCOLOR=\"" + this.gBGColor + "\">";
|
|
|
154 |
|
|
|
155 |
vHeader_Code = this.cal_header();
|
|
|
156 |
vData_Code = this.cal_data();
|
|
|
157 |
vCode = vCode + vHeader_Code + vData_Code;
|
|
|
158 |
|
|
|
159 |
vCode = vCode + "</TABLE>";
|
|
|
160 |
|
|
|
161 |
return vCode;
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
Calendar.prototype.show = function() {
|
|
|
165 |
var vCode = "";
|
|
|
166 |
|
|
|
167 |
this.gWinCal.document.open();
|
|
|
168 |
|
|
|
169 |
// Setup the page...
|
|
|
170 |
this.wwrite("<html>");
|
|
|
171 |
this.wwrite("<head><title>Calendar</title>");
|
|
|
172 |
this.wwrite("</head>");
|
|
|
173 |
|
|
|
174 |
this.wwrite("<body " +
|
|
|
175 |
"link=\"" + this.gLinkColor + "\" " +
|
|
|
176 |
"vlink=\"" + this.gLinkColor + "\" " +
|
|
|
177 |
"alink=\"" + this.gLinkColor + "\" " +
|
|
|
178 |
"text=\"" + this.gTextColor + "\">");
|
|
|
179 |
this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2><B>");
|
|
|
180 |
this.wwriteA(this.gMonthName + " " + this.gYear);
|
|
|
181 |
this.wwriteA("</B><BR>");
|
|
|
182 |
|
|
|
183 |
// Show navigation buttons
|
|
|
184 |
var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
|
|
|
185 |
var prevMM = prevMMYYYY[0];
|
|
|
186 |
var prevYYYY = prevMMYYYY[1];
|
|
|
187 |
|
|
|
188 |
var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
|
|
|
189 |
var nextMM = nextMMYYYY[0];
|
|
|
190 |
var nextYYYY = nextMMYYYY[1];
|
|
|
191 |
|
|
|
192 |
this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
|
|
|
193 |
this.wwrite("[<A HREF=\"" +
|
|
|
194 |
"javascript:window.opener.Build(" +
|
|
|
195 |
"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +
|
|
|
196 |
");" +
|
|
|
197 |
"\"><<<\/A>]</TD><TD ALIGN=center>");
|
|
|
198 |
this.wwrite("[<A HREF=\"" +
|
|
|
199 |
"javascript:window.opener.Build(" +
|
|
|
200 |
"'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
|
|
|
201 |
");" +
|
|
|
202 |
"\"><<\/A>]</TD><TD ALIGN=center>");
|
|
|
203 |
this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
|
|
|
204 |
this.wwrite("[<A HREF=\"" +
|
|
|
205 |
"javascript:window.opener.Build(" +
|
|
|
206 |
"'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
|
|
|
207 |
");" +
|
|
|
208 |
"\">><\/A>]</TD><TD ALIGN=center>");
|
|
|
209 |
this.wwrite("[<A HREF=\"" +
|
|
|
210 |
"javascript:window.opener.Build(" +
|
|
|
211 |
"'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +
|
|
|
212 |
");" +
|
|
|
213 |
"\">>><\/A>]</TD></TR></TABLE><BR>");
|
|
|
214 |
|
|
|
215 |
// Get the complete calendar code for the month..
|
|
|
216 |
vCode = this.getMonthlyCalendarCode();
|
|
|
217 |
this.wwrite(vCode);
|
|
|
218 |
|
|
|
219 |
this.wwrite("</font></body></html>");
|
|
|
220 |
this.gWinCal.document.close();
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
Calendar.prototype.showY = function() {
|
|
|
224 |
var vCode = "";
|
|
|
225 |
var i;
|
|
|
226 |
var vr, vc, vx, vy; // Row, Column, X-coord, Y-coord
|
|
|
227 |
var vxf = 285; // X-Factor
|
|
|
228 |
var vyf = 200; // Y-Factor
|
|
|
229 |
var vxm = 10; // X-margin
|
|
|
230 |
var vym; // Y-margin
|
|
|
231 |
if (isIE) vym = 75;
|
|
|
232 |
else if (isNav) vym = 25;
|
|
|
233 |
|
|
|
234 |
this.gWinCal.document.open();
|
|
|
235 |
|
|
|
236 |
this.wwrite("<html>");
|
|
|
237 |
this.wwrite("<head><title>Calendar</title>");
|
|
|
238 |
this.wwrite("<style type='text/css'>\n<!--");
|
|
|
239 |
for (i=0; i<12; i++) {
|
|
|
240 |
vc = i % 3;
|
|
|
241 |
if (i>=0 && i<= 2) vr = 0;
|
|
|
242 |
if (i>=3 && i<= 5) vr = 1;
|
|
|
243 |
if (i>=6 && i<= 8) vr = 2;
|
|
|
244 |
if (i>=9 && i<= 11) vr = 3;
|
|
|
245 |
|
|
|
246 |
vx = parseInt(vxf * vc) + vxm;
|
|
|
247 |
vy = parseInt(vyf * vr) + vym;
|
|
|
248 |
|
|
|
249 |
this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
|
|
|
250 |
}
|
|
|
251 |
this.wwrite("-->\n</style>");
|
|
|
252 |
this.wwrite("</head>");
|
|
|
253 |
|
|
|
254 |
this.wwrite("<body " +
|
|
|
255 |
"link=\"" + this.gLinkColor + "\" " +
|
|
|
256 |
"vlink=\"" + this.gLinkColor + "\" " +
|
|
|
257 |
"alink=\"" + this.gLinkColor + "\" " +
|
|
|
258 |
"text=\"" + this.gTextColor + "\">");
|
|
|
259 |
this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");
|
|
|
260 |
this.wwrite("Year : " + this.gYear);
|
|
|
261 |
this.wwrite("</B><BR>");
|
|
|
262 |
|
|
|
263 |
// Show navigation buttons
|
|
|
264 |
var prevYYYY = parseInt(this.gYear) - 1;
|
|
|
265 |
var nextYYYY = parseInt(this.gYear) + 1;
|
|
|
266 |
|
|
|
267 |
this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
|
|
|
268 |
this.wwrite("[<A HREF=\"" +
|
|
|
269 |
"javascript:window.opener.Build(" +
|
|
|
270 |
"'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
|
|
|
271 |
");" +
|
|
|
272 |
"\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
|
|
|
273 |
this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
|
|
|
274 |
this.wwrite("[<A HREF=\"" +
|
|
|
275 |
"javascript:window.opener.Build(" +
|
|
|
276 |
"'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
|
|
|
277 |
");" +
|
|
|
278 |
"\">>><\/A>]</TD></TR></TABLE><BR>");
|
|
|
279 |
|
|
|
280 |
// Get the complete calendar code for each month..
|
|
|
281 |
var j;
|
|
|
282 |
for (i=11; i>=0; i--) {
|
|
|
283 |
if (isIE)
|
|
|
284 |
this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
|
|
|
285 |
else if (isNav)
|
|
|
286 |
this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
|
|
|
287 |
|
|
|
288 |
this.gMonth = i;
|
|
|
289 |
this.gMonthName = Calendar.get_month(this.gMonth);
|
|
|
290 |
vCode = this.getMonthlyCalendarCode();
|
|
|
291 |
this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
|
|
|
292 |
this.wwrite(vCode);
|
|
|
293 |
|
|
|
294 |
if (isIE)
|
|
|
295 |
this.wwrite("</DIV>");
|
|
|
296 |
else if (isNav)
|
|
|
297 |
this.wwrite("</LAYER>");
|
|
|
298 |
}
|
|
|
299 |
|
|
|
300 |
this.wwrite("</font><BR></body></html>");
|
|
|
301 |
this.gWinCal.document.close();
|
|
|
302 |
}
|
|
|
303 |
|
|
|
304 |
Calendar.prototype.wwrite = function(wtext) {
|
|
|
305 |
this.gWinCal.document.writeln(wtext);
|
|
|
306 |
}
|
|
|
307 |
|
|
|
308 |
Calendar.prototype.wwriteA = function(wtext) {
|
|
|
309 |
this.gWinCal.document.write(wtext);
|
|
|
310 |
}
|
|
|
311 |
|
|
|
312 |
Calendar.prototype.cal_header = function() {
|
|
|
313 |
var vCode = "";
|
|
|
314 |
|
|
|
315 |
vCode = vCode + "<TR>";
|
|
|
316 |
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sun</B></FONT></TD>";
|
|
|
317 |
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mon</B></FONT></TD>";
|
|
|
318 |
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Tue</B></FONT></TD>";
|
|
|
319 |
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Wed</B></FONT></TD>";
|
|
|
320 |
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Thu</B></FONT></TD>";
|
|
|
321 |
vCode = vCode + "<TD WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Fri</B></FONT></TD>";
|
|
|
322 |
vCode = vCode + "<TD WIDTH='16%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sat</B></FONT></TD>";
|
|
|
323 |
vCode = vCode + "</TR>";
|
|
|
324 |
|
|
|
325 |
return vCode;
|
|
|
326 |
}
|
|
|
327 |
|
|
|
328 |
Calendar.prototype.cal_data = function() {
|
|
|
329 |
var vDate = new Date();
|
|
|
330 |
vDate.setDate(1);
|
|
|
331 |
vDate.setMonth(this.gMonth);
|
|
|
332 |
vDate.setFullYear(this.gYear);
|
|
|
333 |
|
|
|
334 |
var vFirstDay=vDate.getDay();
|
|
|
335 |
var vDay=1;
|
|
|
336 |
var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
|
|
|
337 |
var vOnLastDay=0;
|
|
|
338 |
var vCode = "";
|
|
|
339 |
|
|
|
340 |
/*
|
|
|
341 |
Get day for the 1st of the requested month/year..
|
|
|
342 |
Place as many blank cells before the 1st day of the month as necessary.
|
|
|
343 |
*/
|
|
|
344 |
|
|
|
345 |
vCode = vCode + "<TR>";
|
|
|
346 |
for (i=0; i<vFirstDay; i++) {
|
|
|
347 |
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'> </FONT></TD>";
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
// Write rest of the 1st week
|
|
|
351 |
for (j=vFirstDay; j<7; j++) {
|
|
|
352 |
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +
|
|
|
353 |
"<A HREF='#' " +
|
|
|
354 |
"onClick=\"self.opener.document." + this.gReturnItem + ".value='" +
|
|
|
355 |
this.format_data(vDay) +
|
|
|
356 |
"';window.close();\">" +
|
|
|
357 |
this.format_day(vDay) +
|
|
|
358 |
"</A>" +
|
|
|
359 |
"</FONT></TD>";
|
|
|
360 |
vDay=vDay + 1;
|
|
|
361 |
}
|
|
|
362 |
vCode = vCode + "</TR>";
|
|
|
363 |
|
|
|
364 |
// Write the rest of the weeks
|
|
|
365 |
for (k=2; k<7; k++) {
|
|
|
366 |
vCode = vCode + "<TR>";
|
|
|
367 |
|
|
|
368 |
for (j=0; j<7; j++) {
|
|
|
369 |
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +
|
|
|
370 |
"<A HREF='#' " +
|
|
|
371 |
"onClick=\"self.opener.document." + this.gReturnItem + ".value='" +
|
|
|
372 |
this.format_data(vDay) +
|
|
|
373 |
"';window.close();\">" +
|
|
|
374 |
this.format_day(vDay) +
|
|
|
375 |
"</A>" +
|
|
|
376 |
"</FONT></TD>";
|
|
|
377 |
vDay=vDay + 1;
|
|
|
378 |
|
|
|
379 |
if (vDay > vLastDay) {
|
|
|
380 |
vOnLastDay = 1;
|
|
|
381 |
break;
|
|
|
382 |
}
|
|
|
383 |
}
|
|
|
384 |
|
|
|
385 |
if (j == 6)
|
|
|
386 |
vCode = vCode + "</TR>";
|
|
|
387 |
if (vOnLastDay == 1)
|
|
|
388 |
break;
|
|
|
389 |
}
|
|
|
390 |
|
|
|
391 |
// Fill up the rest of last week with proper blanks, so that we get proper square blocks
|
|
|
392 |
for (m=1; m<(7-j); m++) {
|
|
|
393 |
if (this.gYearly)
|
|
|
394 |
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) +
|
|
|
395 |
"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'> </FONT></TD>";
|
|
|
396 |
else
|
|
|
397 |
vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) +
|
|
|
398 |
"><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
|
|
|
399 |
}
|
|
|
400 |
|
|
|
401 |
return vCode;
|
|
|
402 |
}
|
|
|
403 |
|
|
|
404 |
Calendar.prototype.format_day = function(vday) {
|
|
|
405 |
var vNowDay = gNow.getDate();
|
|
|
406 |
var vNowMonth = gNow.getMonth();
|
|
|
407 |
var vNowYear = gNow.getFullYear();
|
|
|
408 |
|
|
|
409 |
if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
|
|
|
410 |
return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
|
|
|
411 |
else
|
|
|
412 |
return (vday);
|
|
|
413 |
}
|
|
|
414 |
|
|
|
415 |
Calendar.prototype.write_weekend_string = function(vday) {
|
|
|
416 |
var i;
|
|
|
417 |
|
|
|
418 |
// Return special formatting for the weekend day.
|
|
|
419 |
for (i=0; i<weekend.length; i++)
|
|
|
420 |
{
|
|
|
421 |
if (vday == weekend[i])
|
|
|
422 |
return (" BGCOLOR=\"" + weekendColor + "\"");
|
|
|
423 |
}
|
|
|
424 |
|
|
|
425 |
return "";
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
Calendar.prototype.format_data = function(p_day) {
|
|
|
429 |
var vData;
|
|
|
430 |
var vMonth = 1 + this.gMonth;
|
|
|
431 |
vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
|
|
|
432 |
var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
|
|
|
433 |
var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
|
|
|
434 |
var vY4 = new String(this.gYear);
|
|
|
435 |
var vY2 = new String(this.gYear.substr(2,2));
|
|
|
436 |
var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
|
|
|
437 |
|
|
|
438 |
switch (this.gFormat) {
|
|
|
439 |
case "MM\/DD\/YYYY" :
|
|
|
440 |
vData = vMonth + "\/" + vDD + "\/" + vY4;
|
|
|
441 |
break;
|
|
|
442 |
case "MM\/DD\/YY" :
|
|
|
443 |
vData = vMonth + "\/" + vDD + "\/" + vY2;
|
|
|
444 |
break;
|
|
|
445 |
case "MM-DD-YYYY" :
|
|
|
446 |
vData = vMonth + "-" + vDD + "-" + vY4;
|
|
|
447 |
break;
|
|
|
448 |
case "MM-DD-YY" :
|
|
|
449 |
vData = vMonth + "-" + vDD + "-" + vY2;
|
|
|
450 |
break;
|
|
|
451 |
|
|
|
452 |
case "DD\/MON\/YYYY" :
|
|
|
453 |
vData = vDD + "\/" + vMon + "\/" + vY4;
|
|
|
454 |
break;
|
|
|
455 |
case "DD\/MON\/YY" :
|
|
|
456 |
vData = vDD + "\/" + vMon + "\/" + vY2;
|
|
|
457 |
break;
|
|
|
458 |
case "DD-MON-YYYY" :
|
|
|
459 |
vData = vDD + "-" + vMon + "-" + vY4;
|
|
|
460 |
break;
|
|
|
461 |
case "DD-MON-YY" :
|
|
|
462 |
vData = vDD + "-" + vMon + "-" + vY2;
|
|
|
463 |
break;
|
|
|
464 |
|
|
|
465 |
case "DD\/MONTH\/YYYY" :
|
|
|
466 |
vData = vDD + "\/" + vFMon + "\/" + vY4;
|
|
|
467 |
break;
|
|
|
468 |
case "DD\/MONTH\/YY" :
|
|
|
469 |
vData = vDD + "\/" + vFMon + "\/" + vY2;
|
|
|
470 |
break;
|
|
|
471 |
case "DD-MONTH-YYYY" :
|
|
|
472 |
vData = vDD + "-" + vFMon + "-" + vY4;
|
|
|
473 |
break;
|
|
|
474 |
case "DD-MONTH-YY" :
|
|
|
475 |
vData = vDD + "-" + vFMon + "-" + vY2;
|
|
|
476 |
break;
|
|
|
477 |
|
|
|
478 |
case "DD\/MM\/YYYY" :
|
|
|
479 |
vData = vDD + "\/" + vMonth + "\/" + vY4;
|
|
|
480 |
break;
|
|
|
481 |
case "DD\/MM\/YY" :
|
|
|
482 |
vData = vDD + "\/" + vMonth + "\/" + vY2;
|
|
|
483 |
break;
|
|
|
484 |
case "DD-MM-YYYY" :
|
|
|
485 |
vData = vDD + "-" + vMonth + "-" + vY4;
|
|
|
486 |
break;
|
|
|
487 |
case "DD-MM-YY" :
|
|
|
488 |
vData = vDD + "-" + vMonth + "-" + vY2;
|
|
|
489 |
break;
|
|
|
490 |
|
|
|
491 |
default :
|
|
|
492 |
vData = vMonth + "\/" + vDD + "\/" + vY4;
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
return vData;
|
|
|
496 |
}
|
|
|
497 |
|
|
|
498 |
function Build(p_item, p_month, p_year, p_format) {
|
|
|
499 |
var p_WinCal = ggWinCal;
|
|
|
500 |
gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);
|
|
|
501 |
|
|
|
502 |
// Customize your Calendar here..
|
|
|
503 |
gCal.gBGColor="white";
|
|
|
504 |
gCal.gLinkColor="black";
|
|
|
505 |
gCal.gTextColor="black";
|
|
|
506 |
gCal.gHeaderColor="#004080";
|
|
|
507 |
|
|
|
508 |
// Choose appropriate show function
|
|
|
509 |
if (gCal.gYearly) gCal.showY();
|
|
|
510 |
else gCal.show();
|
|
|
511 |
}
|
|
|
512 |
|
|
|
513 |
function show_calendar() {
|
|
|
514 |
/*
|
|
|
515 |
p_month : 0-11 for Jan-Dec; 12 for All Months.
|
|
|
516 |
p_year : 4-digit year
|
|
|
517 |
p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
|
|
|
518 |
p_item : Return Item.
|
|
|
519 |
*/
|
|
|
520 |
|
|
|
521 |
p_item = arguments[0];
|
|
|
522 |
if (arguments[1] == null)
|
|
|
523 |
p_month = new String(gNow.getMonth());
|
|
|
524 |
else
|
|
|
525 |
p_month = arguments[1];
|
|
|
526 |
if (arguments[2] == "" || arguments[2] == null)
|
|
|
527 |
p_year = new String(gNow.getFullYear().toString());
|
|
|
528 |
else
|
|
|
529 |
p_year = arguments[2];
|
|
|
530 |
if (arguments[3] == null)
|
|
|
531 |
p_format = "DD\/MM\/YYYY";
|
|
|
532 |
else
|
|
|
533 |
p_format = arguments[3];
|
|
|
534 |
|
|
|
535 |
vWinCal = window.open("", "Calendar",
|
|
|
536 |
"width=250,height=250,status=no,resizable=no,top=200,left=200");
|
|
|
537 |
vWinCal.opener = self;
|
|
|
538 |
ggWinCal = vWinCal;
|
|
|
539 |
|
|
|
540 |
Build(p_item, p_month, p_year, p_format);
|
|
|
541 |
}
|
|
|
542 |
/*
|
|
|
543 |
Yearly Calendar Code Starts here
|
|
|
544 |
*/
|
|
|
545 |
function show_yearly_calendar(p_item, p_year, p_format) {
|
|
|
546 |
// Load the defaults..
|
|
|
547 |
if (p_year == null || p_year == "")
|
|
|
548 |
p_year = new String(gNow.getFullYear().toString());
|
|
|
549 |
if (p_format == null || p_format == "")
|
|
|
550 |
p_format = "MM/DD/YYYY";
|
|
|
551 |
|
|
|
552 |
var vWinCal = window.open("", "Calendar", "scrollbars=yes");
|
|
|
553 |
vWinCal.opener = self;
|
|
|
554 |
ggWinCal = vWinCal;
|
|
|
555 |
|
|
|
556 |
Build(p_item, null, p_year, p_format);
|
|
|
557 |
}
|
|
|
558 |
|