Friday, June 22nd, 2007

Base diving with Gears

Category: Articles, Gears, Google

Pamela Fox and I have published our first article in a series on Building Ajax Applications with Google APIs.

The first article is on Base diving with Google Gears.

We took Google Base and created a simple offline application that stores search results. We use the JSON API and store away the feeds in the local offline store.

To enable offline and online we created two implementations of the content interface. One reads from the local store, and grabs results when needed. The other keeps the search terms in a cookie, and always hits the GData store for its info.

In related news… GSpreadsheet wraps the Google Spreadsheet API. There is some really “interesting” code in there to handle getting the data back asynchronously, involving creating functions on the fly to use in the callback.

Using it looks like this:

javascript

  1. GSpreadsheet.load("pSYwzniwpzSFnt8Ix3ohQQA", { index: 'firstname' }, function(gs) {
  2.   // display all
  3.   document.getElementById("displayall").innerHTML = gs.displayAll();
  4.      
  5.   // show one
  6.   var row = gs.select('Bob');
  7.   document.getElementById("onebyindex").innerHTML = row.email;
  8.  
  9.   // show by row number
  10.   row = gs.select(1);
  11.   document.getElementById("onebyrownum").innerHTML = row.email;
  12.      
  13.   // display one row
  14.   document.getElementById("displayrow").innerHTML = gs.displayRow('Bob');
  15. });

Posted by Dion Almaer at 12:51 am
1 Comment

+++--
3.2 rating from 18 votes

1 Comment »

Comments feed TrackBack URI

…very cool, many thanks. I hope there are more to come.

Comment by Mark Holton — June 22, 2007

Leave a comment

You must be logged in to post a comment.