0

I need help writing javascript (jquery?) for a web app to save a set of images to an IndexedDB and then load them into an html page.

I have two html pages, img.html that is just a listing of images in this format:

'image-id','base64-image'

and index.html, my main page that includes a series of image tags in this format:

<img name="imglist" id="image-id" img-src="">

I'd like the user to be able to click a button to load all of the images from img.html into IndexedDB and then click another button to read the images from IndexedDB and insert them into the appropriate image tag in index.html (the 'image-id' in img.html corresponds to the appropriate img tag id in index.html).

Also, is it possible to set a cookie (or some other method) that will cause the DB to be erased after a certain time period? I'd like to be able to force the user to re-load the images from the server about once a week.

I'm not great with javascript or indexeddb, so any help or examples would be great.

artmem
  • 353
  • 6
  • 16
  • 4
    So basically, you'd like for someone else to do the code for you. From what you posted, you apparently got the logic figured out. What have you *tried* to code so far? – N.B. Feb 09 '12 at 15:48
  • @N.B. I have a .js page based on this tutorial http://www.html5rocks.com/en/tutorials/indexeddb/todo/ which you can see here: http://nd75.com/test/test.js A stripped down version of my html page is here http://nd75.com/test/test.html (these pages don't work, the entire site isn't online). With what I have currently, the buttons in the html page don't do anything when clicked. – artmem Feb 09 '12 at 22:31

1 Answers1

0

See the article titled Storing images and files in IndexedDB.

N.B. I just posted a similar question here, though it concerns the particular case of a cross-site request. If your requests are on the same site, the link above should be a perfect example for you to work by.

Community
  • 1
  • 1
Yuval
  • 3,207
  • 32
  • 45