Friday, June 22nd, 2007
Base diving with Gears
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:
-
-
GSpreadsheet.load("pSYwzniwpzSFnt8Ix3ohQQA", { index: 'firstname' }, function(gs) {
-
// display all
-
document.getElementById("displayall").innerHTML = gs.displayAll();
-
-
// show one
-
var row = gs.select('Bob');
-
document.getElementById("onebyindex").innerHTML = row.email;
-
-
// show by row number
-
row = gs.select(1);
-
document.getElementById("onebyrownum").innerHTML = row.email;
-
-
// display one row
-
document.getElementById("displayrow").innerHTML = gs.displayRow('Bob');
-
});
-













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