source: trunk/FACT++/www/shift/calendar.js@ 13748

Last change on this file since 13748 was 13748, checked in by tbretz, 12 years ago
Improved the messages in case of a logout.
File size: 25.3 KB
Line 
1/**********************************************************************
2* Calendar JavaScript [DOM] v3.11 by Michael Loesler *
3************************************************************************
4* Copyright (C) 2005-09 by Michael Loesler, http//derletztekick.com *
5* *
6* *
7* This program is free software; you can redistribute it and/or modify *
8* it under the terms of the GNU General Public License as published by *
9* the Free Software Foundation; either version 3 of the License, or *
10* (at your option) any later version. *
11* *
12* This program is distributed in the hope that it will be useful, *
13* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15* GNU General Public License for more details. *
16* *
17* You should have received a copy of the GNU General Public License *
18* along with this program; if not, see <http://www.gnu.org/licenses/> *
19* or write to the *
20* Free Software Foundation, Inc., *
21* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22* *
23 **********************************************************************/
24/*
25function logout()
26{
27 var xmlHttp = new XMLHttpRequest();
28 xmlHttp.open('POST', "calendar.php?logout=1", true);
29 xmlHttp.onload = function ()
30 {
31 if (xmlHttp.status!=200)
32 {
33 alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
34 return;
35 }
36
37 alert("Logout successful!");
38 };
39
40 xmlHttp.send();
41}
42*/
43function resize()
44{
45 var table = document.getElementById("table");
46
47 var W = window.innerWidth;
48 var H = window.innerHeight;
49
50 table.style.width =W+"px";
51 table.style.height=H+"px";
52}
53
54var institutes= ["User", "EPFL", "ETHZ", "ISDC", "UNIDO", "UNIGE", "UNIWUE" ];
55
56function CalendarJS()
57{
58 this.now = new Date();
59 this.dayname = ["Mo","Tu","We","Th","Fr","Sa","So"];
60 this.monthname = ["January","February","March","April","May","June","July","August","September","October","November","December"];
61 this.tooltip = ["previous month","next month","current date","last year","next year"];
62 this.monthCell = document.createElement("th");
63 this.tableHead = null;
64 this.tableFoot = null;
65 this.parEl = null;
66
67 this.init = function( id, initDate )
68 {
69 this.now = initDate ? initDate : new Date();
70 this.date = this.now.getDate();
71 this.month = this.mm = this.now.getMonth();
72 this.year = this.yy = this.now.getFullYear();
73 this.monthCell.appendChild(document.createTextNode( this.monthname[this.mm]+"\u00a0"+this.yy ));
74
75 this.tableHead = this.createTableHead();
76 this.tableFoot = this.createTableFoot();
77
78 this.parEl = document.getElementById( id );
79 this.show();
80 this.show();
81
82 if (!initDate)
83 this.checkDate();
84 };
85
86 this.checkDate = function()
87 {
88 var self = this;
89 var today = new Date();
90
91 if (this.date != today.getDate())
92 {
93 this.tableHead = this.createTableHead();
94 this.tableFoot = this.createTableFoot();
95
96 this.date = today.getDate();
97 if (this.mm == this.month && this.yy == this.year)
98 this.switchMonth("current");
99
100 this.month = today.getMonth();
101 if (this.mm == this.month && this.yy == this.year)
102 this.switchMonth("current");
103
104 this.year = today.getFullYear();
105 if (this.mm == this.month && this.yy == this.year)
106 this.switchMonth("current");
107 }
108 window.setTimeout(function() { self.checkDate(); }, Math.abs(new Date(this.year, this.month, this.date, 24, 0, 0)-this.now));
109 },
110
111 this.removeElements = function( Obj )
112 {
113 while( Obj.childNodes.length > 0)
114 Obj.removeChild(Obj.lastChild);
115
116 return Obj;
117 };
118
119 this.show = function()
120 {
121 this.parEl = this.removeElements( this.parEl );
122 this.monthCell.firstChild.replaceData(0, this.monthCell.firstChild.nodeValue.length, this.monthname[this.mm]+"\u00a0"+this.yy);
123
124 var table = document.createElement("table");
125 table.id = "table";
126
127 this.parEl.appendChild( table );
128
129 table.appendChild( this.tableHead );
130 table.appendChild( this.tableFoot );
131
132 table.appendChild( this.createTableBody(window.innerHeight-table.offsetHeight) );
133
134 resize();
135 };
136
137 this.createTableFoot = function()
138 {
139 var tfoot = document.createElement("tfoot");
140
141 var tr = document.createElement("tr");
142 var td = document.createElement("td");
143 td.height = "1%";
144 td.colSpan = 7;
145 td.style.padding="3px 3px";
146 tfoot.appendChild(tr);
147 tr.appendChild(td);
148 var table = document.createElement("table");
149 table.width="100%";
150 td.appendChild(table);
151 tr = document.createElement("tr");
152 table.appendChild(tr);
153 for (var i=0; i<institutes.length; i++)
154 {
155 td = document.createElement("td");
156 td.width=100/institutes.length+"%";
157 td.setAttribute("style", "text-align:center;font-size:1em;border:solid #112A5D 2px;padding:3px 3px;");
158 td.changeUser = this.changeUser;
159 td.onclick = function(e) { this.changeUser(); }
160 td.appendChild(document.createTextNode(institutes[i]));
161 tr.appendChild(td);
162
163 if (i==0)
164 td.style.backgroundColor = "yellow";
165 }
166 document.getElementById("body").setAttribute("data-user", institutes[0]);
167
168
169 tr = document.createElement("tr");
170 td = document.createElement("td");
171 td.colSpan = 7;
172 td.style.paddingLeft = "0px";
173 td.style.paddingTop = "0px";
174 td.height = "1%";
175 var form = document.createElement("form");
176 var input = document.createElement("textarea");
177 input.overflow = "auto";
178 input.wrap = "virtual";
179 input.id = "comment";
180 input.value = "enter comment here";
181 input.style.color = "#888";
182 input.style.width = "100%";
183 input.rows = 5;
184 input.title = "Enter a comment. Click somewhere in the calender to store the comment.";
185 input.onchange = function() { pushComment(); };
186 input.onfocus = function() { if (input.value=="enter comment here" && input.style.color!="black") input.value=""; input.style.color="black"; };
187 input.onblur = function() { input.style.color="#888"; if (input.value=="") input.value="enter comment here"; };
188 form.appendChild(input);
189 td.appendChild( form );
190 tr.appendChild( td );
191 tfoot.appendChild(tr);
192
193 tr = document.createElement("tr");
194
195 var td = document.createElement("td");
196 td.height="1%";
197 td.colSpan=7;
198 tr.appendChild(td);
199
200 var tab = document.createElement("table");
201 var tr2 = document.createElement("tr");
202 tab.width="100%";
203 tab.cellSpacing=0;
204 tab.cellPadding=0;
205 tab.style.borderWidth = 0;
206 tab.style.fontSize = "1.5em";
207 tab.style.marginBottom = "2px";
208 td.appendChild(tab);
209 tab.appendChild(tr2);
210
211 var tm = this.getCell( "td", this.timeTrigger(), "clock" );
212 tm.style.whiteSpace="nowrap";
213 tm.style.paddingLeft = "0px";
214 tm.style.width="33%";
215 tr2.appendChild( tm );
216
217 var self = this;
218 window.setInterval(function() { tm.firstChild.nodeValue = self.timeTrigger(); }, 500);
219
220 var td = document.createElement("td");
221 td.style.width="33%";
222 td.style.textAlign="center";
223 var a = document.createElement("a");
224 a.href = "overview.png";
225 a.style.whiteSpace="nowrap";
226 a.appendChild(document.createTextNode("click here for help"));
227 td.appendChild(a);
228 tr2.appendChild( td );
229
230 td = this.getCell( "td", "logout", "logout");
231 td.style.width="33%";
232 td.onclick = function(e) { logout(); }
233 td.style.paddingRight = "0px";
234 tr2.appendChild( td );
235
236 tfoot.appendChild( tr );
237
238 return tfoot;
239 }
240
241 this.createTableHead = function()
242 {
243 var thead = document.createElement("thead");
244 thead.style.height="1%";
245 var tr = document.createElement("tr");
246 var th = this.getCell( "th", "\u00AB", "prev_month" );
247
248 th.rowSpan = 2;
249 th.Instanz = this;
250 th.onclick = function() { this.Instanz.switchMonth("prev"); };
251 th.title = this.tooltip[0];
252
253 try { th.style.cursor = "pointer"; } catch(e){ th.style.cursor = "hand"; }
254 tr.appendChild( th );
255
256 this.monthCell.Instanz = this;
257 this.monthCell.rowSpan = 2;
258 this.monthCell.colSpan = 4;
259 this.monthCell.onclick = function() { this.Instanz.switchMonth("current"); };
260 this.monthCell.title = this.tooltip[2];
261
262 try { this.monthCell.style.cursor = "pointer"; } catch(e){ this.monthCell.style.cursor = "hand"; }
263 tr.appendChild( this.monthCell );
264
265 th = this.getCell( "th", "\u00BB", "next_month" );
266 th.rowSpan = 2;
267 th.Instanz = this;
268 th.onclick = function() { this.Instanz.switchMonth("next"); };
269 th.title = this.tooltip[1];
270
271 try { th.style.cursor = "pointer"; } catch(e){ th.style.cursor = "hand"; }
272 tr.appendChild( th );
273
274 th = this.getCell( "th", "\u02c4", "prev_year" );
275 th.Instanz = this;
276 th.onclick = function() { this.Instanz.switchMonth("prev_year"); };
277 th.title = this.tooltip[3];
278
279 try { th.style.cursor = "pointer"; } catch(e){ th.style.cursor = "hand"; }
280 tr.appendChild( th );
281
282 thead.appendChild( tr );
283
284 tr = document.createElement("tr");
285 th = this.getCell( "th", "\u02c5", "next_year" );
286 th.Instanz = this;
287 th.onclick = function() { this.Instanz.switchMonth("next_year"); };
288 th.title = this.tooltip[4];
289
290 try { th.style.cursor = "pointer"; } catch(e){ th.style.cursor = "hand"; }
291 tr.appendChild( th );
292
293 thead.appendChild( tr );
294
295 tr = document.createElement('tr');
296 for (var i=0; i<this.dayname.length; i++)
297 {
298 var th = this.getCell("th", this.dayname[i], "weekday" );
299 th.width=100/7+"%";
300 tr.appendChild( th );
301 }
302
303 thead.appendChild( tr );
304
305 return thead;
306 },
307
308 this.createTableBody = function(height)
309 {
310 var dayspermonth = [31,28,31,30,31,30,31,31,30,31,30,31];
311 var sevendaysaweek = 0;
312 var begin = new Date(this.yy, this.mm, 1);
313 var firstday = begin.getDay()-1;
314 if (firstday < 0)
315 firstday = 6;
316 if ((this.yy%4==0) && ((this.yy%100!=0) || (this.yy%400==0)))
317 dayspermonth[1] = 29;
318
319 var tbody = document.createElement("tbody");
320 var tr = document.createElement('tr');
321
322 tbody.height="100%";
323
324 var height="";//"20%";//100/8+"%";
325
326 if (firstday == 0)
327 {
328 for (var i=0; i<this.dayname.length; i++)
329 {
330 var prevMonth = (this.mm == 0)?11:this.mm-1;
331 var td = this.getCell( "td", dayspermonth[prevMonth]-6+i, "last_month" );
332 td.style.height=height;
333 tr.appendChild( td );
334 }
335 tbody.appendChild( tr );
336 tr = document.createElement('tr');
337 }
338
339 for (var i=0; i<firstday; i++, sevendaysaweek++)
340 {
341 var prevMonth = (this.mm == 0)?11:this.mm-1;
342 var td = this.getCell( "td", dayspermonth[prevMonth]-firstday+i+1, "last_month" );
343 td.style.height=height;
344 tr.appendChild( td );
345 }
346
347 for (var i=1; i<=dayspermonth[this.mm]; i++, sevendaysaweek++)
348 {
349 if (this.dayname.length == sevendaysaweek)
350 {
351 tbody.appendChild( tr );
352 tr = document.createElement('tr');
353 sevendaysaweek = 0;
354 }
355
356 var td = null;
357 if (i==this.date && this.mm==this.month && this.yy==this.year && (sevendaysaweek == 5 || sevendaysaweek == 6))
358 td = this.getCell( "td", i, "today weekend" );
359 else
360 if (i==this.date && this.mm==this.month && this.yy==this.year)
361 td = this.getCell( "td", i, "today" );
362 else
363 if (sevendaysaweek == 5 || sevendaysaweek == 6)
364 td = this.getCell( "td", i, "weekend" );
365 else
366 td = this.getCell( "td", i, null);
367
368 td.setDate = this.setDate;
369 td.chooseDate = this.chooseDate;
370 td.dd = i;
371 td.mm = this.mm;
372 td.yy = this.yy;
373 td.id = this.mm+"-"+i;
374 td.title = "Click to select this date.";
375
376 td.style.height=height;
377
378 td.onclick = function(e) {
379 this.chooseDate();
380 };
381
382 var sp = document.createElement("span");
383 sp.appendChild(document.createTextNode("*"));
384 sp.style.color="darkred";
385 sp.style.display="none";
386 td.appendChild(sp);
387
388 tr.appendChild( td );
389 }
390
391 var daysNextMonth = 1;
392 for (var i=sevendaysaweek; i<this.dayname.length; i++)
393 tr.appendChild( this.getCell( "td", daysNextMonth++, "next_month" ) );
394
395 tbody.appendChild( tr );
396
397 while (tbody.getElementsByTagName("tr").length<6) {
398 tr = document.createElement('tr');
399 for (var i=0; i<this.dayname.length; i++)
400 {
401 var td = this.getCell( "td", daysNextMonth++, "next_month" );
402 td.style.height=height;
403 tr.appendChild( td );
404 }
405 tbody.appendChild( tr );
406 }
407
408 requestAll(this.yy, this.mm);
409 requestAllComments(this.yy, this.mm);
410 if (this.year==this.yy && this.month==this.mm)
411 requestComment(this.year, this.month, this.date);
412 else
413 {
414 var c = document.getElementById("comment");
415 c.color="#888";
416 c.value="enter comment here";
417 }
418
419 return tbody;
420 };
421
422 this.getCalendarWeek = function(j,m,t)
423 {
424 var cwDate = this.now;
425 if (!t)
426 {
427 j = cwDate.getFullYear();
428 m = cwDate.getMonth();
429 t = cwDate.getDate();
430 }
431 cwDate = new Date(j,m,t);
432
433 var doDat = new Date(cwDate.getTime() + (3-((cwDate.getDay()+6) % 7)) * 86400000);
434 cwYear = doDat.getFullYear();
435
436 var doCW = new Date(new Date(cwYear,0,4).getTime() + (3-((new Date(cwYear,0,4).getDay()+6) % 7)) * 86400000);
437 cw = Math.floor(1.5+(doDat.getTime()-doCW.getTime())/86400000/7);
438 return cw;
439 };
440
441 function request(td)
442 {
443 var user = document.getElementById("body").getAttribute("data-user");
444 var uri = "calendar.php?toggle&y="+td.yy+"&m="+td.mm+"&d="+td.dd;
445 if (user!="User")
446 uri += "&u="+user;
447
448 var xmlHttp = new XMLHttpRequest();
449 xmlHttp.open('POST', uri, true);
450 xmlHttp.onload = function ()
451 {
452 if (xmlHttp.status!=200)
453 {
454 alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
455 return;
456 }
457
458 var lines = xmlHttp.responseText.split('\n');
459 if (lines.length==0)
460 return;
461
462 while (td.childNodes.length>2)
463 td.removeChild(td.lastChild);
464
465 for (var i=0; i<lines.length; i++)
466 {
467 var x = lines[i].split('\t');
468 if (x.length!=2)
469 continue;
470
471 var div = document.createElement("div");
472 div.style.fontWeight="normal";
473 div.appendChild(document.createTextNode(x[1]));
474 td.appendChild(div);
475
476 for (var j=0; j<institutes.length; j++)
477 if (x[1]==institutes[j])
478 {
479 div.className += " institute";
480 break;
481 }
482 }
483
484 if (td.childNodes.length>2)
485 td.className += " enabled";
486 else
487 td.className = td.className.replace(/enabled/g, "");
488 };
489
490 xmlHttp.send();
491 }
492
493 function logout()
494 {
495 var xmlHttp = new XMLHttpRequest();
496 xmlHttp.open('POST', "calendar.php?logout", true);
497 xmlHttp.onload = function ()
498 {
499 if (xmlHttp.status!=401)
500 {
501 alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
502 return;
503 }
504
505 alert(xmlHttp.statusText);
506 };
507
508 xmlHttp.send();
509 }
510
511 function pushComment()
512 {
513 var c = document.getElementById("comment");
514
515 var y = c.getAttribute("data-y");
516 var m = c.getAttribute("data-m");
517 var d = c.getAttribute("data-d");
518 var v = c.value;
519
520 var uri = "calendar.php?y="+y+"&m="+m+"&d="+d+"&c="+encodeURIComponent(v);
521
522 var xmlHttp = new XMLHttpRequest();
523 xmlHttp.open('POST', uri, true);
524 xmlHttp.onload = function()
525 {
526 if (xmlHttp.status!=200)
527 {
528 alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
529 return;
530 }
531
532 alert("Comment inserted successfully.");
533
534 var td = document.getElementById(m+"-"+d);
535 alert(td.childNodes[1]+"/"+v);
536 if (v=="")
537 {
538 td.childNodes[1].style.display="none";
539 td.title="Click to select this date.";
540 }
541 else
542 {
543 td.childNodes[1].style.display="";
544 td.title=v;
545 }
546
547 };
548
549 xmlHttp.send();
550 }
551
552 function requestComment(yy, mm, dd)
553 {
554 var c = document.getElementById("comment");
555
556 var y = c.getAttribute("data-y");
557 var m = c.getAttribute("data-m");
558 var d = c.getAttribute("data-d");
559
560 if (y==yy && m==mm && d==dd)
561 return;
562
563 var uri = "calendar.php?comment&y="+yy+"&m="+mm+"&d="+dd;
564 var xmlHttp = new XMLHttpRequest();
565 xmlHttp.open('POST', uri, true);
566 xmlHttp.onload = function ()
567 {
568 if (xmlHttp.status!=200)
569 {
570 alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]");
571 return;
572 }
573
574 var td = document.getElementById(mm+"-"+dd);
575
576 c.color="#888";
577 if (xmlHttp.responseText=="")
578 {
579 c.value="enter comment here";
580 td.childNodes[1].style.display="none";
581 td.title="";
582 }
583 else
584 {
585 c.value = xmlHttp.responseText;
586 td.childNodes[1].style.display="";
587 td.title=xmlHttp.responseText;
588 }
589
590 c.setAttribute("data-y", yy);
591 c.setAttribute("data-m", mm);
592 c.setAttribute("data-d", dd);
593 };
594
595 xmlHttp.send();
596 }
597
598 var xmlReqAll = null;
599 function requestAll(yy, mm)
600 {
601 if (xmlReqAll)
602 xmlReqAll.abort();
603
604 var uri = "calendar.php?y="+yy+"&m="+mm;
605
606 xmlReqAll = new XMLHttpRequest();
607 xmlReqAll.open('POST', uri, true);
608 xmlReqAll.onload = function ()
609 {
610 if (xmlReqAll.status!=200)
611 {
612 alert("ERROR - HTTP request: "+xmlReqAll.statusText+" ["+xmlReqAll.status+"]");
613 return;
614 }
615
616 var lines = xmlReqAll.responseText.split('\n');
617 if (lines.length==0)
618 return;
619
620 for (var i=0; i<lines.length; i++)
621 {
622 var x = lines[i].split('\t');
623 if (x.length!=2)
624 continue;
625
626 var td = document.getElementById(mm+"-"+x[0]);
627
628 var div = document.createElement("div");
629 div.style.fontWeight="normal";
630 div.appendChild(document.createTextNode(x[1]));
631 td.appendChild(div);
632
633 for (var j=0; j<institutes.length; j++)
634 if (x[1]==institutes[j])
635 {
636 div.className += " institute";
637 break;
638 }
639
640 td.className += " enabled";
641 }
642 };
643
644 xmlReqAll.send();
645 }
646
647 var xmlReqCom = null;
648 function requestAllComments(yy, mm)
649 {
650 if (xmlReqCom)
651 xmlReqCom.abort();
652
653 var uri = "calendar.php?comment&y="+yy+"&m="+mm;
654 xmlReqCom = new XMLHttpRequest();
655 xmlReqCom.open('POST', uri, true);
656 xmlReqCom.onload = function ()
657 {
658 if (xmlReqCom.status!=200)
659 {
660 alert("ERROR - HTTP request: "+xmlReqCom.statusText+" ["+xmlReqCom.status+"]");
661 return;
662 }
663
664 if (xmlReqCom.responseText<4)
665 return;
666
667 var pos = 6;
668
669 while (pos<xmlReqCom.responseText.length)
670 {
671 var len = parseInt(xmlReqCom.responseText.substr(pos-6, 4), 10);
672 var dd = parseInt(xmlReqCom.responseText.substr(pos-2, 2), 10);
673 var com = xmlReqCom.responseText.substr(pos, len);
674 pos += len+6;
675
676 if (com!="")
677 {
678 var td = document.getElementById(mm+"-"+dd);
679 td.childNodes[1].style.display="";
680 td.title=com;
681 }
682 }
683 };
684
685 xmlReqCom.send();
686 }
687
688 this.setDate = function()
689 {
690 request(this);
691 };
692
693 this.changeUser = function()
694 {
695 var sib = this.nextSibling;
696 while (sib)
697 {
698 sib.style.backgroundColor = "";
699 sib = sib.nextSibling;
700 }
701
702 sib = this.previousSibling;
703 while (sib)
704 {
705 sib.style.backgroundColor = "";
706 sib = sib.previousSibling;
707 }
708
709 this.style.backgroundColor = "yellow";
710
711 document.getElementById("body").setAttribute("data-user", this.firstChild.textContent);
712 };
713
714 this.chooseDate = function()
715 {
716 while (document.getElementsByClassName("choosen")[0])
717 {
718 var e = document.getElementsByClassName("choosen")[0];
719 e.title = "Click to select this date.";
720 e.className = e.className.replace(/choosen/g, "");
721 e.onclick = function() {
722 this.chooseDate();
723 };
724 }
725
726 this.className += " choosen";
727 this.title = "Click again to add or remove your name.";
728
729 requestComment(this.yy, this.mm, this.dd);
730
731 this.onclick = function() {
732 this.setDate();
733 };
734 };
735
736 this.timeTrigger = function()
737 {
738 var now = new Date();
739 var ss = (now.getSeconds()<10)?"0"+now.getSeconds():now.getSeconds();
740 var mm = (now.getMinutes()<10)?"0"+now.getMinutes():now.getMinutes();
741 var hh = (now.getHours() <10)?"0"+now.getHours() :now.getHours();
742
743 var kw = "KW" + this.getCalendarWeek(this.year, this.month, this.date);
744 var str = hh+":"+mm+":"+ss+"\u00a0["+kw+"]";
745 return str;
746 };
747
748 this.getCell = function(tag, str, cssClass)
749 {
750 var El = document.createElement( tag );
751 El.appendChild(document.createTextNode( str ));
752 if (cssClass != null)
753 El.className = cssClass;
754 return El;
755 },
756
757 this.switchMonth = function( s )
758 {
759 switch (s)
760 {
761 case "prev":
762 this.yy = (this.mm == 0) ? this.yy-1 : this.yy;
763 this.mm = (this.mm == 0) ? 11 : this.mm-1;
764 break;
765
766 case "next":
767 this.yy = (this.mm == 11) ? this.yy+1 : this.yy;
768 this.mm = (this.mm == 11) ? 0 : this.mm+1;
769 break;
770
771 case "prev_year":
772 this.yy = this.yy-1;
773 break;
774
775 case "next_year":
776 this.yy = this.yy+1;
777 break;
778
779 case "current":
780 this.yy = this.year;
781 this.mm = this.month;
782 break;
783 }
784 this.show();
785 }
786}
787
788var DOMContentLoaded = false;
789function addContentLoadListener (func)
790{
791 if (document.addEventListener)
792 {
793 var DOMContentLoadFunction = function ()
794 {
795 window.DOMContentLoaded = true;
796 func();
797 };
798
799 document.addEventListener("DOMContentLoaded", DOMContentLoadFunction, false);
800 }
801
802 var oldfunc = (window.onload || new Function());
803
804 window.onload = function ()
805 {
806 if (!window.DOMContentLoaded)
807 {
808 oldfunc();
809 func();
810 }
811 };
812}
813
814addContentLoadListener( function() {
815new CalendarJS().init("calendar");
816//new CalendarJS().init("calendar", new Date(2009, 1, 15));
817} );
Note: See TracBrowser for help on using the repository browser.