Jump to content

HTML5 Abilities


anaylor01
 Share

Recommended Posts

I am writing an app that needs to get the current location and store it in a database and then calculate the distance between the first location that was saved to the database and the current location. It will also need to use the phones system clock. Can this be done using HTML5?

Link to comment
Share on other sites

depends.

 

HTML 5 is a composition of front end technology. If you want to create persistency between clients and sessions safely you need some server to store data.

 

For the frontend it looks a bit like this in javascript:

// store Item in browserlocalStorage.setItem("banana", "tasty!")// return value from browservar storedItem = localStorage.getItem("banana")

Here are more details: http://diveintohtml5.info/storage.html

Link to comment
Share on other sites

Like puritanner mentioned, it depends on what you like to achieve.

 

Accesing the system clock for retrieving the current time can be done via the browser implementation of the Date Object. Storing information for offline usage can be done via AppCache in combination with a web storage solution. Besides Local- or SessionStorage, you could also leverage a real database in form of IndexedDB with proper transactions. A former SQL based solution is deprecated and won't be supported by most clients.

 

If you like to keep the data synchronized beween multiple systems, you will need an additional server. This one won't be restrained by the different browsers and therefore be able to use SQL approaches as well.

Link to comment
Share on other sites

Just to note: If a user has no internet access, he won't be able to start your app at all :)

Stuff like localstorage or indexedDB are only useful when you have partial network disruptions and need to store data while the app is offline. When you come back online, you can re-sync with the server.

 

Storing data in a local DB or localstorage is unsafe. If the user decides to delete his browser cookies for whatever reason, all your data gets purged.

Link to comment
Share on other sites

Also support for IndexedDB isn't great at the moment, and is completely missing in some browsers, most notably Safari (even the desktop version of it). WebSQL is more widely supported at present, but it's been deprecated and eventually people will have to move to IndexedDB. Right now we're in a transition period, and if you want to support all browsers you have to support both types of technology.

 

Besides IndexedDB is asynchronous and far from reliable: for example, if you initiate a query to store data it may take some time (depending on the amount of data) and it could be that user closes the browser before it's complete, in which case it's never going to be completed.

 

The only web API that I know of that you can rely on to store data locally, is the FileSystem API (in persistent storage mode) which, unfortunately, is only supported by Chrome.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...