Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Hey onion2k,

Thanks very much for the feedback.

I will look into using localStorage, this has also been mentioned in another comment. Have you experience with this yourself?

I'll have a google around, are there any drawback with that approach you can think of?

Thanks again for the feedback, it's really appreciated!



Yes, I've used localStorage. It's supported well across all the main browsers, it's reasonably quick, and it'll store more than enough data for your app. It's really just a case of doing (assuming you include JSON2.js);

  var ls = window.localStorage;
  var config = JSON.parse(ls.getItem('config')); //load the config

  ls.setItem('config', JSON.stringify(config)); //save the config
That's pretty much it. You'll need to protect against the config not being there, but that's just a matter of using a default empty object if config is null.


Thanks a lot for this, it's really helpful to get an idea of how this would be used.

How would you suggest this is used then?

People have the option to save a file or to localStorage?

Or should it just do it in the background without people knowing or maybe it's set as a config option?

You opinion on this is really appreciated so thanks again!


In a few things I've made that use it I do it in the background so state is maintained between sessions (load the data during initialisation, save it on any state change). It's important to inform the user that it's storing things locally, and include a UI element that allows the user to clear all the data easily, and possibly let users switch storage off (for shared computers). I use it in mobile things so that's not really a problem for me.


hey onion2k,

this insight is really appreciated as it will really help to improve tyto. How would you suggest maybe showing this information to the user? a modal or pop up? or something less intrusive just like a spinner when it saves? Or should there be some intro that asks the user if localStorage is ok to be used? Maybe a disappearing banner? then a button could easily be added to the header for removing said data maybe.

I guess I will really need to assess how many buttons make their way into the header really. What's you opinion on drop buttons or maybe some of the actions being icon buttons and some text plus icons? I'm just thinking of screen real estate and the responsive element.

on mobile I would like the traditional hidden menu I think when it comes to it.

Thanks for the insight and feedback again, it's really appreciated.


>> It's supported well across all the main browsers

IE < 8 does not support localStorage. May not be an issue depending on your target user-base.


hey niyazpk!

Thanks for the heads up!

I'd hoped to avoid older browsers as burdening myself with the stress of backwards compatibility in my spare time doesn't seem too appealing. However, in saying that, if there was demand I would be more than happy to investigate. I use mac so I tend not to encounter IE too much if I can help it.

Thanks again for your input!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: