Straight and simple as google says..
- Interect with Desktop
- Use gears local server for caching.
- Store data in offline mode and synchronize when online.
Last thing is seems most interesting to me.. I can use the webpages even if i am not connected to internet. Thats cool. I used an webapp that uses google gears http://www.rememberthemilk.com for this purpose.
[ Lightweight database on client Side ]
Gears uses SQLite for database support. And its secured, because a web application cannot access data outside of its domain. More importantly it supports fulltext search.
Using this Database API is very Simple Only two classes Database and ResultSet. Using this api is so simple i cant help copying the code. :D
// db is instance of Database
var db = google.gears.factory.create('beta.database');
db.open('my-database');
// rs is Instance of ResultSet
var rs = db.execute('select * from TestTable order by Timestamp desc');
while (rs.isValidRow()) {
alert(rs.field(0) + '@' + rs.field(1));
rs.next();
}
Its simple :). This feature is actually for storing user data in offline mode and when user is online, this information has to be synchronized. Still i am not clear enough about how synchronization should be done.
[ Another most interesting feature : LocalServer. ]
Pages and files/resources can be served in offline mode from Localserver. When localServer is configured to serve some url, it caches those files/resources with urls. Each time that url is requested localserver servers those resources/files without sending actual server request. Thats one cool thing.
How does Localserver know which urls to cache?A manifest file is used to tell the urls and version info of the urls. Local server gets the manifest file each time. And update resource from urls if it doesn't have the latest version.
[ Using Google Gears in your page. ]
* Install Google gears first http://gears.google.com/
* Download this script gear_init.js
* Include this script in the page
=: First thing you should in your page is check whether this pc has google gears installed.
if (!window.google) {
alert("gear is not here!");
location.href = "http://gears.google.com/?action=install&return=http://yoursite.com";
}
=: How do you get the api implementation of Gears? Gears provides an Factory for this.
This is how you will get the LocalServer to cache files.
var localServer = google.gears.factory.create("beta.localserver");
And get the database..
var databae = google.gears.factory.create("beta.database");
Using these localserver and database is simple and i am not going to present them... google documented them good enough.
[ Other supports from Gears]
There are other supports like httpRequest, Timer. But they are not new in Javascript programming. Actually these are implemented to be used from Gears WorkerPool
For "Interect with Desktop" They should have said file access feature..
Because their implementation gives two feature.
- Can create shortcut in pc file system.
- get a file content from the pc files system. File content is served in Blob format.
Oh here is one thing new here "Blob". That's an implementation by Google Gear.
Javascript itself doesn't have Blob support. Blob can be passed into, and returned by, a variety of Gears methods.
Other cool things in Google Gears are GeoLocation & Workerpool API. Hope to give a demonstration on those soon..