Hi Steve,

Yes, it's possible to do step 5 with Gears, using Javascript to change
the HTML content of the existing page.  Basically, your application
would detect that it was offline (in step 4), query the local SQLite
database instead of the remote database, and then use Javascript to
write the query results to the table without needing to reload the
page.  The more complex part of the program may actually be syncing
the local database with the server.  Here are some reference
materials:

Manipulating tables with Javascript:
http://w3schools.com/htmldom/dom_obj_table.asp

Sample Gears applications (GearPad may be the most relevant for you):
http://code.google.com/apis/gears/sample.html

GearsAJAXHelper - code from Google that might simplify this
considerably:
http://googleajaxsearchapi.blogspot.com/2008/02/gearsajaxhelper-use-google-gears-with.html

Here's an example of a Javascript function (from an app that I wrote)
that queries the local database and outputs the result into an
existing list element, without needing to reload the page:

function showQueued()
{
  var elm = getElementById('elQueue');
  elm.innerHTML = '';
  var rs = db.execute( 'select id, house, street, first from
people' );
  while( rs.isValidRow() ) {
    elm.innerHTML += '<li>' + rs.field(1) + ' ' + rs.field(2) + ', ' +
rs.field(3) + ' - <a href="javascript: void%200"
onclick="removeFromQueue(' + rs.field(0) + ')">Remove</a></li>';
    rs.next();
  }
  rs.close();
}

Hope this is helpful to you -- best of luck with your project!



On May 21, 3:14 am, Steve Patrick <[email protected]>
wrote:
> Hi Matt,
> The idea is to capture server's response when online and then, when
> offline, to query the local database (that is synchronized with
> server's database) and show captured file (exactly the same that was
> shown before, when online) BUT  with required new data.
> For example:
> 1. Client queries server for users, that for instance, live in US.
> Server responses and the client captures and shows the result.
> 2. The network goes down and the app works now offline
> 3. The client ,now, queries for users that live in France
> 4. The app detects offline mode and queries the local database that is
> synchronized.
> 5. The app shows the captured file in step 1 but showing the users
> that live in France, not in US
>
> Is it possible to do step 5 with Gears? How? Can I modify a captured
> HTML file and modify it to change the content of a table to show some
> different data?
>
> thanks for your help
>
> On 20 mayo, 21:56, Matt Penniman <[email protected]> wrote:
>
> > Hi Steve,
>
> > (disclaimer: I'm not a Google employee, just someone who's worked with
> > Gears)
>
> > I'm not entirely clear about the behavior you're looking for; what do
> > you want to modify when offline?  The HTML of the page (this is easy
> > to do with Javascript)?  Or the contents of images or banners (this is
> > not so easy)?  Could you give us an example of the kind of response
> > your application gives?
>
> > It's probably possible to make that response look the same whether the
> > user is online or offline, but there are several factors here...
>
> > Thanks,
> > Matt
>
> > On May 19, 10:59 am, Steve Patrick <[email protected]>
> > wrote:
>
> > > Hi everybody,think I need your help...
> > > I 've got an app that asks tha server for some information, then the
> > > server queries a database and responses the client with the required
> > > data. I would like to take my app offline, so my client now uses
> > > Gears:has a local database synchronized with server's database, so,
> > > when my app goes offline uses the local database and the app is able
> > > to show the information requested.
> > > That OK but, I want the user not to even realize that the app is
> > > working offline when disconnected. I mean,  when disconnected I want
> > > the same page look that when connected, not only getting requested
> > > data, I want the same colors, images, banners that appear when
> > > online...Is it possible to capture in aResourceStoreserver's
> > > response and  then, when offline, query my local database and
> > > automatically modify captured file with the new information to show?
> > > Is there any other way to do that?
> > > Thanks

Reply via email to