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