var RSSRequestObject = false; // XMLHttpRequest Object var Backend = false; if (form.calendars.options[Item].value == 'cal1') { Backend = 'feeds/calendar1feed.php'; } elseif (form.calendars.options[Items].value == 'cal2') { Backend = 'feeds/calendar2feed.php'; } elseif (form.calendars.options[Items].value == 'cal3') { Backend = 'feeds/calendar3feed.php'; } else { Backend = 'feeds/calendar1feed.php'; } //var Backend = 'feeds/calendar1feed.php'; // Backend url window.setInterval("update_timer()", 1200000); // update the data every 20 mins if (window.XMLHttpRequest) // try to create XMLHttpRequest RSSRequestObject = new XMLHttpRequest(); if (window.ActiveXObject) // if ActiveXObject use the Microsoft.XMLHTTP RSSRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); /* * onreadystatechange function */ function ReqChange() { // If data received correctly if (RSSRequestObject.readyState==4) { // if data is valid if (RSSRequestObject.responseText.indexOf('invalid') == -1) { // Parsing Feeds var node = RSSRequestObject.responseXML.documentElement; var content = ''; // Get the calendar title - uncomment next two lines if you want it to show up var title = node.getElementsByTagName('title').item(0).firstChild.data; var content = '
' + title + '
'; // Browse events var items = node.getElementsByTagName('entry'); var itemTimePrev = new Date(); itemTimePrev.setTime(0000); if (items.length == 0) { content += ''; } else { content += ' '; } // Display the result document.getElementById("gcalajax").innerHTML = content; // Tell the reader the everything is done document.getElementById("status").innerHTML = "Done."; } else { // Tell the reader that there was error requesting data document.getElementById("status").innerHTML = "
Error requesting data.
"; } Hide('status'); } } /* * Time Format - Month */ function getMonthName(dateObject) { var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); return(m_names[dateObject.getUTCMonth()-1]); //Array starts at 0, getMonth starts at 1 } /* * Time Format - Hour */ function getTimeFormatted(dateObject) { var hours = dateObject.getUTCHours(); var minutes = dateObject.getUTCMinutes(); var ampm = "AM"; if (hours > 12){ hours = hours - 12; ampm = "PM";} if (hours == 0) {hours = 12;} if (hours == 12){ampm = 'PM'} if (minutes < 10){minutes = "0" + minutes;} var formattedTime = hours + ':' + minutes + ' ' + ampm; return (formattedTime); } /* * Main AJAX RSS reader request */ function RSSRequest() { // change the status to requesting data document.getElementById("status").innerHTML = "Requesting data ..."; // Prepare the request RSSRequestObject.open("GET", Backend, true); // Set the onreadystatechange function RSSRequestObject.onreadystatechange = ReqChange; // Send RSSRequestObject.send(null); } /* * Timer */ function update_timer() { RSSRequest(); } function Hide(id){ var el = GetObject(id); //if(el.style.display=="none") //el.style.display=''; //else el.style.display='none'; } function GetObject(id){ var el = document.getElementById(id); return(el); }