MrQwest

Bull In A China Shop

So I wrote about my little CoffeeApp a while ago. I also mentioned that I wanted to improve it with offline storage. I soon became aware of the DOM Storage specs whizzing around like sessionStorage & localStorage.

Like a bull in a china shop, I read a brief description of localStorage – “Store data offline across multiple sessions” – and thought perfect! That’s exactly what I need.

I’ve had some spare time over the last week to mess around with v2 and have spent a lot of time researching localStorage. Bookmarking a lot of links to read up & tackle the problem.

I’ve just realised that localStorage isn’t as fully featured as first hoped. It can store a key & a value. Just one value.

CoffeeApp at the moment stores the drink, quantity and date.

Time to start researching the Client-Side Database Storage spec…

Idiot.

edit:

It seems a shame to waste the localStorage research though so I will knock up an example or two in the coming weeks & post here along with a list of links which have helped!

edit (again):

Maybe I was too hasty. I’ve just been reading a page over at Sencha called ‘The HTML5 Family – Web Storage’ and it highlights that yes, you can only store one value, but that’s one value at a time.

Perhaps you’d try the following: –

localStorage.setItem("Drink", "tea")

That would set the drink as Tea.. obviously… But – and I should have picked up on this – you can set multiple items per call.. so you’d put: —

localStorage.setItem("Drink", "tea")
localStorage.setItem("Date", "201006151403")

That long string at the end there, that’s the date broken down like this > 2010(year) 06(month) 15(day) 14(hour) 03(minute)… A bit anal, but hey – who doesn’t like stats huh?

So localStorage will should work! Fingers crossed!


Why not be the first to comment?

Textile Help

You must preview your comment before submitting.

Previously:

Next:

Search

Hire Me