offline stuff

3 views
Skip to first unread message

Dirk Gorissen

unread,
Mar 24, 2012, 4:15:47 PM3/24/12
to taarifa-dev
Hi Guys,

Had a poke at the offline use stuff, this is just in case somebody
wants to take it forward tomorrow

* I added a basic taarifa.appcache file in the root which lists a
basic set of resources that should be cached for offline use. Should
be easy enough to extend with other URLs (see
http://www.html5rocks.com/en/tutorials/appcache/beginner/). This
should take care of the css/js/html templates. It probably makes sense
to add a cache updating function as well on some pages (e.g., so the
list of reports page is kept up to date in the cache)

* next is to write a javascript handler for every form submit action.
In there you check if you are online, if so: submit as normal, if not,
generate the html string that would be posted if we had a network, but
instead of posting it you save it to the localstorage object (probably
using something like perist.js) under a key that will probably be the
submission url. Additionally you make sure you have a listener
registered that gets called whenever the online/offline status
changes. When we change to online your listener then looks at the
localstorage object, and for every entry it does the post. Once an
entry is posted successfully it is removed from the storage object.

I think this should basically get everything working in offline mode.
The only other issue I am aware of is that the mapping widget will not
work in offline mode and this needs to be handled gracefully. As for
the list of reports you will only see the ones that were available
when you went offline.

Cheers
Dirk

--
Web: http://www.dirkgorissen.com
Twitter: https://twitter.com/elazungu

Mark Iliffe

unread,
Mar 25, 2012, 2:02:47 PM3/25/12
to taari...@googlegroups.com
Hi Dirk, Guys!

Firstly AWESOME!

With dealing with the map, I think we can just leave that until the next version, as nice as it would be to have it included. At the moment we only want the report submission to be cached, but how would listeners be added to dynamically generated forms?

Best,

Mark

Dirk Gorissen

unread,
Mar 27, 2012, 4:28:36 AM3/27/12
to taari...@googlegroups.com
Hi Guys,

Will try to revisit this and work on it some more, do let me know if
somebody else is / will be already doing so.

Cheers
Dirk

Reply all
Reply to author
Forward
0 new messages