announcing the vortex.offline library (v0.1)

with the release of Adobe's AIR and Microsoft's Silverlight combined with the continued advances in javascript libraries like dojo and Prototype, the line between desktop app and web app continues to get blurrier. one of the major disadvantages that web apps have had against traditional desktop applications is that web apps only work, well, when you are on the web.

with the release of Google Gears came the promise of web applications that could work offline just as well as they could online. i have been interested in this topic for some time, so i immediately started playing with this new tool and realized it was pretty slick. after using some of the better javascript libraries out there now though, it felt like the Gears api was a little 'raw'. i started working on a wrapper library to make development of offline applications even easier to get started with. i saw a post on Ajaxian a while back that talked about how the dojo framework (and specifically Brad Neuberg) were working on porting their offline storage solution to use Gears, and it was eerily similar to what i had been working on as well.

looking over the dojo implementation, it seemed as though Brad had already done most of the work i was working on as well. the only downside i had at that time was that my current client's project was implemented using Ext, not dojo. instead of having to include the entire dojo framework along with the Ext framework, i decided that my offline library could be used as a nice, small, library-independent add-on. i polished it up and now it is what you see here.

the library is self-contained in a single javascript file, vortex_offline.js. like dojo, it supports an offline module as well as a generic storage module. to start using it, it can be as simple as a single line of javascript:


vortex.offline.init("My Application Name");


that's it! behind the scenes, the code will scan the page to find all of the resources required (including images, css, other .js file, etc) and cache them using the Gears LocalServer object. the library exposes several events that you can hook into, such as when the network status changes. there is also a syncing system that lets you record actions while offline and replay them back when the network is connected again.

the library also contains a generic storage module that can be used independently of the offline module (although it is still obviously dependent on Gears behind the scenes). objects can be easily saved and retrieved using commands like:


vortex.storage.put(key, val);
vortex.storage.get(key);


under the covers, the objects are serialzied to json and stored in the local Gears database.

the debug version of the vortex_offline.js file included in the .zip is fully commented and shows the additional methods available for both modules. the minified version weighs in at just under 10k, including the json parser that you can swap out if you are already using another one. a sample application will be posted up shortly...

[download .zip file]