jjxiao / parchment

Automatically exported from code.google.com/p/parchment
GNU General Public License v2.0
0 stars 0 forks source link

Client-side storage should be cross-browser #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, Parchment uses DOM Storage's globalStorage to save persistent
client-side data, but this is only supported by Firefox 2+ and isn't in the
HTML 5 standard anymore.  Ideally we should use an abstraction layer like
PersistJS to have cross-browser support here:

  http://pablotron.org/software/persist-js/

Original issue reported on code.google.com by var...@gmail.com on 24 May 2008 at 3:50

GoogleCodeExporter commented 9 years ago

Original comment by var...@gmail.com on 27 May 2008 at 3:36

GoogleCodeExporter commented 9 years ago
We may want to even support a fallback that saves the game to server-side 
storage, if
available and the client browser has no mechanisms to save the game.

Original comment by var...@gmail.com on 27 May 2008 at 3:39

GoogleCodeExporter commented 9 years ago
Another option is to have the saved game just be a hash parameter on the URL 
that
changes as the user plays the game; that way a bookmark will literally mark 
where the
player is in the game when they made the bookmark.  It's ultimately really just 
a
question of how massive save files can get, and/or how ugly we're willing to 
let them be.

Original comment by var...@gmail.com on 29 May 2008 at 12:29

GoogleCodeExporter commented 9 years ago
The changes in r46 may resolve this.

Original comment by var...@gmail.com on 31 May 2008 at 7:00

GoogleCodeExporter commented 9 years ago
No one's complained about the r46 changes, so need for cross-browser client-side
storage is now low.  Changing priority accordingly.

Original comment by var...@gmail.com on 4 Jun 2008 at 1:35

GoogleCodeExporter commented 9 years ago
Attaching a patch that Damien Neil sent me; here's his description of it:

I'm attaching a patch to Parchment which adds support for saving games with
PersistJS.  (I'm not including the persist.js file that it depends on; I assume 
you
know where to find it.)  I've tested the patch on Safari 3.1.1 and OS X Firefox 
3.0.

This patch enables multiple named saved games, with a prompt before 
saving/restoring.
 The name "url" is special-cased to use the old URL-location-based method of saving.

Since PersistJS requires a callback to fetch data, I've reworked the Zui onSave 
and
onRestore methods to pass status back via a callback.  I also reworked 
EngineRunner
to pull some overly-duplicated code into _pause and _resume methods.

Original comment by var...@gmail.com on 23 Jun 2008 at 6:38

Attachments:

GoogleCodeExporter commented 9 years ago
I've been working on a Dojo Storage singleton at
http://code.google.com/p/dojo-storage/. Dojo Storage seems to be better 
supported,
and gets updated. PersistJS hasn't been since it was released... however it's 
very
big, 360KB+ with 11 files. I've been working on cutting out the parts of Dojo 
that
aren't needed and combining the rest into one file, and I've got it down to 
31.2KB
now. Even though I know more can be done, It's definitely useable.

However before adding it to Parchment I would like to finish the library system 
I
started at
http://composure-if.googlecode.com/svn/branches/parchment/src/parchment/library.
js
The idea is for the loading and storing of games and savefiles to be done 
through one
central place.

Original comment by curiousdannii on 11 Feb 2009 at 4:47

GoogleCodeExporter commented 9 years ago
There's now a jQuery plugin, and I think this would be preferable to all of the 
above
options :)
http://code.google.com/p/jquery-jstore/

Original comment by curiousdannii on 3 Apr 2009 at 10:08

GoogleCodeExporter commented 9 years ago
I'll probably end up writing my own... they're all just too complicated.

Original comment by curiousdannii on 10 May 2009 at 11:46

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Browsers that support native DOM storage:
IE8: 909
Firefox >= 2: 8700
Safari >= 526: 700ish
Total: 10309

Browsers that don't support native DOM storage:
IE <= 7: 1438
Firefox 1.x: 11
Chrome (all?): 1387
Safari > 526: 130ish
Opera (all?): 430ish
Total: 3396

So about 75% of all Parchment users have native DOM storage. I think Chrome and 
Opera
will very quickly add support too.

Based on the stats, I don't think it's worth adding Flash storage support too. 
If
someone else wanted to, that's fine, but I won't bother. The large majority of 
our
users are using modern browsers, so we should cater to them. :)

Original comment by curiousdannii on 18 Sep 2009 at 1:56

GoogleCodeExporter commented 9 years ago
Started work in the library branch.

Unfortunately localStorage doesn't always work for file:, so flash is still 
needed. Also, IndexedDB will be used if the browser has it.

Original comment by curiousdannii on 11 Dec 2011 at 4:31