Good catch, Ray! Thanks, Austin
On Wed, Mar 26, 2008 at 11:29 AM, Ray Baxter <[EMAIL PROTECTED]> wrote: > I don't use javascript, but the problems that you are seeing with the > order and display of events are because you have 39 events in your calendar, > created in order (at least approximately) from earliest event to latest > event and only 25 events are being returned in the queries that you are > making. When you query, and don't specify maxevents the default number of > events returned is 25. > > When you execute your original code, you receive the 25 last added, and > coincidentally latest in time, events. These events just happen to all occur > in this month and the future. > > When you add set the sortorder to ascending, you receive the 25 events > that are earliest in time, which all coincidentally occur before today. > > If you specify a larger value for maxevents, or limit your events to only > those events that occur in the currently displayed month if that works for > your application, you will have better results. > > Ray > > > CreativeLlama wrote: > > var calendarUrl = 'http://www.google.com/calendar/feeds/[EMAIL > PROTECTED]/public/full'; > > Here is the full code I'm using for getting the Google data. Maybe > it'll help. I am so appreciative. Thanks: > > > > <!-- Scripts for Google Calendar --> > <script type="text/javascript" src="http://www.google.com/jsapi? > key=ABQIAAAAuNSaa1AxpUwLQhcIE9YqgBQgCt9JjK4BaBX97-8b90ftWl1DexQbWCLHzcUjdELlx5VwP6YkS6Uf1w" > > <http://www.google.com/jsapi?key=ABQIAAAAuNSaa1AxpUwLQhcIE9YqgBQgCt9JjK4BaBX97-8b90ftWl1DexQbWCLHzcUjdELlx5VwP6YkS6Uf1w>></ > script> > > <script type="text/javascript"> > > <!--/* Loads the Google data JavaScript client library */google.load("gdata", > "1");function init() { > // init the Google data JS client library with an error handler > google.gdata.client.init(handleGDError); > // load the code.google.com developer calendar > loadDeveloperCalendar(); > } > /** * Loads the Google Developers Event Calendar */ > function loadDeveloperCalendar() { > loadCalendarByAddress('[EMAIL PROTECTED]'); > } > /** * Adds a leading zero to a single-digit number. Used for > displaying dates. */ > function padNumber(num) { > if (num <= 9) { > return "0" + num; > } > return num; > } > /** * Determines the full calendarUrl based upon the calendarAddress * > argument and calls loadCalendar with the calendarUrl value. * * @param > {string} calendarAddress is the email-style address for the calendar > */ > function loadCalendarByAddress(calendarAddress) { > var calendarUrl = 'http://www.google.com/calendar/feeds/' + > calendarAddress + '/public/full'; loadCalendar(calendarUrl); > } > /** * Uses Google data JS client library to retrieve a calendar feed > from the specified * URL. The feed is controlled by several query > parameters and a callback * function is called to process the feed > results. * * @param {string} calendarUrl is the URL for a public > calendar feed */ > function loadCalendar(calendarUrl) { > var service = new > google.gdata.calendar.CalendarService('gdata-js-client-samples- > simple'); > var query = newgoogle.gdata.calendar.CalendarEventQuery(calendarUrl); > query.setOrderBy('starttime'); > query.setSingleEvents(true); > service.getEventsFeed(query, listEvents, handleGDError); > } > /** * Callback function for the Google data JS client library to call > when an error * occurs during the retrieval of the feed. Details > available depend partly * on the web browser, but this shows a few > basic examples. In the case of * a privileged environment using > ClientLogin authentication, there may also * be an e.type attribute in > some cases. * * @param {Error} e is an instance of an Error */ > function handleGDError(e) { > document.getElementById('jsSourceFinal').setAttribute('style', > 'display:none'); > if (e instanceof Error) { > /* alert with the error line number, file and message */ > alert('Error at line ' + e.lineNumber + ' in ' + e.fileName + > '\n' + > 'Message: ' + e.message); > /* if available, output HTTP error code and status text */ > if (e.cause) { > var status = e.cause.status; > var statusText = e.cause.statusText; > alert('Root cause: HTTP error ' + status + ' with > status text of: ' > + statusText); > } > } > else { alert(e.toString()); } > } > /** * Callback function for the Google data JS client library to call > with a feed * of events retrieved. * * Creates an unordered list of > events in a human-readable form. This list of * events is added into > a div called 'events'. The title for the calendar is * placed in a > div called 'calendarTitle' * * @param {json} feedRoot is the root of > the feed, containing all entries */ > function listEvents(feedRoot) { > var entries = feedRoot.feed.getEntries(); > var len = entries.length; > //We then determine how many days are in the current month using PHP > var limit = 32; > > > for (var n = 1; n < limit; n++){ > > var e = String(n); > var eventDiv = document.getElementById(e); > if (eventDiv.childNodes.length > 0) { > eventDiv.removeChild(eventDiv.childNodes[0]); > } > /* create a new unordered list */ > var ul = document.createElement('ul'); > > /* set the calendarTitle div with the name of the calendar > document.getElementById('calendarTitle').innerHTML = "Calendar: " > +feedRoot.feed.title.$t; */ > > /* loop through each event in the feed */ > for (var i = 0; i < len; i++) { > var entry = entries[i]; > var title = entry.getTitle().getText(); > //var locations = entry.getLocations()[i].getValueString(); > var startDateTime = null; > var startJSDate = null; > var times = entry.getTimes(); > if (times.length > 0) { > startDateTime = times[0].getStartTime(); > startJSDate = startDateTime.getDate(); > } > var entryLinkHref = null; > if (entry.getHtmlLink() != null) { > entryLinkHref = entry.getHtmlLink().getHref(); > } > var dateString = ""; > > > //Get the month using PHP > var f = 3; > /* If the month that the user would > like to see and the month that the event occurs in are the same, write > out content */ > if (f == (startJSDate.getMonth() + 1)){ > > /* If the date that we're on in the loop and the date that the > event occurs in are the same, write out content */ > if (e == startJSDate.getDate()){ > /* Create a list element */ > var li = document.createElement('li'); > if (!startDateTime.isDateOnly()) { > <!-- Format to include AM/PM --> > var a_p = ""; > var eventStart = startJSDate.getHours(); > if(eventStart < 12){ > a_p = "AM"; > } > else{ > a_p = "PM"; > } > if (eventStart == 0){ > eventStart = 12; > } > if (eventStart > 12){ > eventStart = eventStart - 12; > } > dateString += eventStart + ":" + > padNumber(startJSDate.getMinutes()) + " " + a_p; > } > > /* if we have a link to the event, create an 'a' > element */ > if (entryLinkHref != null) { > entryLink = document.createElement('a'); > entryLink.setAttribute('href', entryLinkHref); > entryLink.setAttribute('target', '_blank'); > entryLink.setAttribute('className', 'event'); > > entryLink.appendChild(document.createTextNode(title)); > > entryLink.appendChild(document.createElement('br')); > /*if (locations != null){ > entryLink.appendChild(document.createTextNode(' > [ ' + dateString + > ' - ' + locations + ' ] ')); > }else {*/ > entryLink.appendChild(document.createTextNode(' > [ ' + dateString + > ' ] ')); > //} > li.appendChild(entryLink); > } > else { > li.appendChild(document.createTextNode(title + > ' - ' + > dateString)); > } > /* append the list item onto the unordered list */ > ul.appendChild(li); > var cid = n + 100; > var cellID = String(cid); > document.getElementById(cellID).className = > "fulleventcell"; > document.getElementById(cellID).style.cursor = > "pointer"; > } > } > > }//End the for loop for each event > > ul.setAttribute('className','events'); > eventDiv.appendChild(ul); > > }//End the for loop for each day of the month > }google.setOnLoadCallback(init); > //--> > > </script> > > <script type="text/javascript"> > loadCalendar('http://www.google.com/calendar/feeds/[EMAIL > PROTECTED]/public/full'); > </script> > > > > > On Mar 25, 6:04 pm, "Austin (Google)" <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> > wrote: > > > Hi, > > Setting the orderby and singleevents param should retrieve future events as > well, hmm, I am not sure why you are not getting future events. what is the > calendarUrl you are using? > > Thanks, > Austin > > On Mon, Mar 24, 2008 at 9:27 AM, CreativeLlama <[EMAIL PROTECTED]> <[EMAIL > PROTECTED]> > wrote: > > > > > > > > I'm trying to load ALL the Google calendar events into the calendar on > my site. The following code only displays events for this month and > the future, not all the events: > > > function loadCalendar(calendarUrl) { > var service = new > google.gdata.calendar.CalendarService('gdata-js-client-samples- > simple'); > var query = newgoogle.gdata.calendar.CalendarEventQuery(calendarUrl); > query.setOrderBy('starttime'); > query.setSingleEvents(true); > service.getEventsFeed(query, listEvents, handleGDError); > } > > > Also, I would like to order the events ascending, but if I add in the > line "query.setSortOrder('ascending');", then it gives me all the > events in the past. > > > Any suggestions? > > > Thanks.- Hide quoted text - > > > - Show quoted text - > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Calendar Data API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-calendar-help-dataapi?hl=en -~----------~----~----~----~------~----~------~--~---
