Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    New Coder
    Join Date
    Nov 2012
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It worked.
    Last edited by RickP; 11-28-2012 at 07:51 PM.

  2. #17
    New Coder
    Join Date
    Nov 2012
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It fails when trying to add to localStorage the following deflated value:

    "‹®VÊLQ²:J9‰•©E@”¡£”œ_ZTœ
    2jc"

    I get "Invalid argument." Note there is a return character there so not sure if that's messing it up.

    This came from the string:

    "[{"id":"id","player":"player","course":"course"}]"


    Any ideas why that would be? Nothing in that string seems odd. It does work for some other strings I've done.

  3. #18
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,460
    Thanks
    11
    Thanked 600 Times in 580 Posts
    Quote Originally Posted by RickP View Post
    It fails when trying to add to localStorage the following deflated value:

    "‹®VÊLQ²:J9‰•©E@”¡£”œ_ZTœ
    2jc"

    I get "Invalid argument." Note there is a return character there so not sure if that's messing it up.

    This came from the string:

    "[{"id":"id","player":"player","course":"course"}]"


    Any ideas why that would be? Nothing in that string seems odd. It does work for some other strings I've done.
    ok. i looked into it.

    Firstly, "It" doesn't fail, this is an IE localStorage problem, not a string problem or an issue with my functions.

    my functions are fine in IE 6+



    it seems that IE, even IE10 has an issue with localStorage.
    this is a bug with IE's localStoage, not the code i posted, but i'll try to help anyway.

    in chrome and firefox, this is true:
    localStorage['temp']=unescape("%01");
    localStorage['temp']==unescape("%01")
    but in IE, it's false (9+10) or throws (7+8)

    so, we need to fix IE, and IE only, both the 8 and 9/10 branch. Fun!

    this alternate routine works on 8+9+10:

    Code:
    var code=deflate('[{"id":"id","player":"player","course":"course"}]');
    
    localStorage['_temp']=escape(code);
    inflate(unescape(localStorage['_temp']));
    you may want to use a custom save(key, value) function instead of just using localStorage[key]=value, so that you have a chance in your normal workflow to handle IE's specific needs. it's also a chance to bake-in a date and other machine-gathered meta about the stored values.

    just so there's no confusion to anyone reading this a year from now, one last time; the functions work in IE, localStorage has minor compat issues that require special handling.

    why IE can't localStorage all the chars possibilities i don't know, but i appreciate your pointing this out, it's good to know.
    Last edited by rnd me; 11-28-2012 at 09:28 PM.
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  4. #19
    New Coder
    Join Date
    Nov 2012
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Gotta love browser compatibility.

    Would it hurt any to call escape() and unescape() for all browsers?


    Thanks for finding this also.

  5. #20
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,460
    Thanks
    11
    Thanked 600 Times in 580 Posts
    Quote Originally Posted by RickP View Post
    Would it hurt any to call escape() and unescape() for all browsers?
    won't hurt, its just a waste of space...
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  6. #21
    New Coder
    Join Date
    Nov 2012
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I think I'll try it with escape() and unescape() for all browsers. Should still get some good compression savings, but it will make the code more manageable. Today it's IE that doesn't work, tomorrow it's something else. This compression is already way more savings than the plain data so it's a win/win I think.

    The one thing I hate about web programming are these browser specific things. Drives me nuts (can you tell I'm new to this )

  7. #22
    New Coder
    Join Date
    Nov 2012
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Library updated on front page:

    - Put library in .js inside zip file on first post

    - Added rnd_me's compression code to save space

    - Added Delete() function. Parameters are similar to the Query() function. First parameter is the table name, second parameter is a function. The function should return true on the records to be deleted.

    - Added Delete() function example to first post
    Last edited by RickP; 11-29-2012 at 05:56 AM.


 
Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •