On mySimon: Holiday Gifts for Him
BNET Business Network:
BNET
TechRepublic
ZDNet

May 30th, 2007

Sprinkle Ajax with some scouring powder by Google Gears

Posted by Ed Burnette @ 6:38 pm

Categories: AJAX, Community, General, Google, Programming, Scripting

Tags: Google Inc., AJAX, Ed Burnette, Ed Burnette

In Focus » See more posts on: Google Development

Google asked me if I wanted to be in on an embargoed news release item earlier today and I said no. Companies never give you enough information in those things, so if you write something early to be the first to post, you end up missing a feature, leaving something out, or having to go back and re-write the article. At least their embargo times are measured in hours instead of weeks, unlike Sun. But I digress…

Google has announced a nice way to support online and offline web-based applications with the same code using Google Gears. Gears originally had the code name “scour” leading to all sorts of puns in the code and mailing lists with “scouring powder” and so forth. And they say geeks have no sense of humor. I think of it as more of a “holy hand-grenade”.

Anyway, the way it works is the user has to install (”ding ding whoop whoop whoop!” I can hear the alarm bells going off already, but wait, it’s only 700K and there are no scary questions so pipe down)… ahem. As I was saying, the user installs a little browser plug-in which does three things, no more, no less. Four shalt thou not count, nor either count thou two, excepting that thou then proceed to three. Five is right out. (Hmm, maybe I should lay off the cough medicine). Those three features are:

LocalServer LocalServer
Cache and serve application resources (HTML, JavaScript, images, etc.) locally
Database Database
Store data locally in a fully-searchable relational database
WorkerPool WorkerPool
Make your web applications more responsive by performing resource-intensive operations asynchronously

Forget cookies. Can you say SQL? I knew you could. Here’s a snippet of JavaScript that runs a SQL query inside your browser to access a database on your local machine:

   var rs = db.execute('select * from Demo order by Timestamp desc');
   var index = 0;
   while (rs.isValidRow()) {
      recentPhrases[index] = rs.field(0);
      ++index;
      rs.next();
   }
   rs.close();

I took out the error handling but you can see the whole sample on the Google Gears site, or go here for a demo. It’s cross-browser, and cross-platform. And, oh yeah, open source (BSD license; not sure why that picked that instead of the Apache license Greg is so fond of).

Can’t talk now, gotta go play some more with Google Gears. Meanwhile, install Gears for yourself, and check out the Samples and Tools zip. Whether you’re doing battle with network latency, dealing with occasionally connected users, or putting the nail in that old fashioned office suite with your killer Ajax apps, Gears may be just the armament you need. Google Reader has already been fitted with it - will Mail and Docs and Spreadsheets be far behind? So go now, and “lobbest thou thy Holy Hand Grenade of Antioch towards thou foe, who being naughty in my sight, shall snuff it.

Ed BurnetteEd Burnette is a professional developer and author of several articles and books about computing including Hello, Android: Introducing Google's Mobile Development Platform, 2nd Edition. For disclosure of Ed's industry affiliations, click here or to view his full profile click here.

Email Ed Burnette

Subscribe to Dev Connection via Email alerts or RSS.

  • Talkback
  • Most Recent of 6 Talkback(s)
License choice
Yes, we prefer the Apache License and that is the default choice for all software that we release. In certain cases, however, we select other licenses. That typically happens when our software is intended to be combined with something else, then we'll choose that target's license.... (Read the rest)
Posted by: gstein67 Posted on: 06/04/07 You are currently: a Guest | | Terms of Use
Got any of that cough medicine to share, Ed?  morchant | 05/31/07
I wave my WebParts at you!  markandbeck | 05/31/07
Vorpal Rabbit or Tettle the Timid Turtle  agarillon | 05/31/07
Security?  Resuna | 05/31/07
With SQLite, the complete database is stored in a single file, so, you only  DonnieBoy | 05/31/07
License choice  gstein67 | 06/04/07

What do you think?

SponsoredWhite Papers, Webcasts, and Downloads

advertisement

Recent Entries

Premier Vendor Content Whitepapers, webcasts & resources from our Power Center Sponsors

Archives

Favorite Links

ZDNet Blogs

White Papers, Webcasts, and Downloads

SmartPlanet

Click Here