/********************************************************************** * Calendar JavaScript [DOM] v3.11 by Michael Loesler * ************************************************************************ * Copyright (C) 2005-09 by Michael Loesler, http//derletztekick.com * * * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, see * * or write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * * **********************************************************************/ /* function logout() { var xmlHttp = new XMLHttpRequest(); xmlHttp.open('POST', "calendar.php?logout=1", true); xmlHttp.onload = function () { if (xmlHttp.status!=200) { alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]"); return; } alert("Logout successful!"); }; xmlHttp.send(); } */ function resize() { var table = document.getElementById("table"); var W = window.innerWidth; var H = window.innerHeight; table.style.width =W+"px"; table.style.height=H+"px"; } var institutes= ["User", "EPFL", "ETHZ", "ISDC", "UNIDO", "UNIGE", "UNIWUE" ]; function CalendarJS() { this.now = new Date(); this.dayname = ["Mo","Tu","We","Th","Fr","Sa","So"]; this.monthname = ["January","February","March","April","May","June","July","August","September","October","November","December"]; this.tooltip = ["previous month","next month","current date","last year","next year"]; this.monthCell = document.createElement("th"); this.tableHead = null; this.tableFoot = null; this.parEl = null; this.init = function( id, initDate ) { this.now = initDate ? initDate : new Date(); this.date = this.now.getDate(); this.month = this.mm = this.now.getMonth(); this.year = this.yy = this.now.getFullYear(); this.monthCell.appendChild(document.createTextNode( this.monthname[this.mm]+"\u00a0"+this.yy )); this.tableHead = this.createTableHead(); this.tableFoot = this.createTableFoot(); this.parEl = document.getElementById( id ); this.show(); if (!initDate) this.checkDate(); }; this.checkDate = function() { var self = this; var today = new Date(); if (this.date != today.getDate()) { this.tableHead = this.createTableHead(); this.tableFoot = this.createTableFoot(); this.date = today.getDate(); if (this.mm == this.month && this.yy == this.year) this.switchMonth("current"); this.month = today.getMonth(); if (this.mm == this.month && this.yy == this.year) this.switchMonth("current"); this.year = today.getFullYear(); if (this.mm == this.month && this.yy == this.year) this.switchMonth("current"); } window.setTimeout(function() { self.checkDate(); }, Math.abs(new Date(this.year, this.month, this.date, 24, 0, 0)-this.now)); }, this.removeElements = function( Obj ) { while( Obj.childNodes.length > 0) Obj.removeChild(Obj.lastChild); return Obj; }; this.show = function() { this.parEl = this.removeElements( this.parEl ); this.monthCell.firstChild.replaceData(0, this.monthCell.firstChild.nodeValue.length, this.monthname[this.mm]+"\u00a0"+this.yy); var table = document.createElement("table"); table.id = "table"; this.parEl.appendChild( table ); table.appendChild( this.tableHead ); table.appendChild( this.tableFoot ); table.appendChild( this.createTableBody(window.innerHeight-table.offsetHeight) ); resize(); }; this.createTableFoot = function() { var tfoot = document.createElement("tfoot"); var tr = document.createElement("tr"); var td = document.createElement("td"); td.height = "1%"; td.colSpan = 7; td.style.padding="3px 3px"; tfoot.appendChild(tr); tr.appendChild(td); var table = document.createElement("table"); table.width="100%"; td.appendChild(table); tr = document.createElement("tr"); table.appendChild(tr); for (var i=0; i2) td.removeChild(td.lastChild); for (var i=0; i2) td.className += " enabled"; else td.className = td.className.replace(/enabled/g, ""); }; xmlHttp.send(); } function logout() { var xmlHttp = new XMLHttpRequest(); xmlHttp.open('POST', "calendar.php?logout", true); xmlHttp.onload = function () { if (xmlHttp.status!=200) { alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]"); return; } }; xmlHttp.send(); } function pushComment() { var c = document.getElementById("comment"); var y = c.getAttribute("data-y"); var m = c.getAttribute("data-m"); var d = c.getAttribute("data-d"); var v = c.value; var uri = "calendar.php?y="+y+"&m="+m+"&d="+d+"&c="+encodeURIComponent(v); var xmlHttp = new XMLHttpRequest(); xmlHttp.open('POST', uri, true); xmlHttp.onload = function() { if (xmlHttp.status!=200) { alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]"); return; } alert("Comment inserted successfully."); var td = document.getElementById(m+"-"+d); alert(td.childNodes[1]+"/"+v); if (v=="") { td.childNodes[1].style.display="none"; td.title="Click to select this date."; } else { td.childNodes[1].style.display=""; td.title=v; } }; xmlHttp.send(); } function requestComment(yy, mm, dd) { var c = document.getElementById("comment"); var y = c.getAttribute("data-y"); var m = c.getAttribute("data-m"); var d = c.getAttribute("data-d"); if (y==yy && m==mm && d==dd) return; var uri = "calendar.php?comment&y="+yy+"&m="+mm+"&d="+dd; var xmlHttp = new XMLHttpRequest(); xmlHttp.open('POST', uri, true); xmlHttp.onload = function () { if (xmlHttp.status!=200) { alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]"); return; } var td = document.getElementById(mm+"-"+dd); c.color="#888"; if (xmlHttp.responseText=="") { c.value="enter comment here"; td.childNodes[1].style.display="none"; td.title=""; } else { c.value = xmlHttp.responseText; td.childNodes[1].style.display=""; td.title=xmlHttp.responseText; } c.setAttribute("data-y", yy); c.setAttribute("data-m", mm); c.setAttribute("data-d", dd); }; xmlHttp.send(); } function requestAll(yy, mm) { var uri = "calendar.php?y="+yy+"&m="+mm; var xmlHttp = new XMLHttpRequest(); xmlHttp.open('POST', uri, true); xmlHttp.onload = function () { if (xmlHttp.status!=200) { alert("ERROR - HTTP request: "+xmlHttp.statusText+" ["+xmlHttp.status+"]"); return; } var lines = xmlHttp.responseText.split('\n'); if (lines.length==0) return; for (var i=0; i