nick1n / nicholast.fm

Last.fm Stat Utility Web App
https://nicholast.fm
21 stars 1 forks source link

Make localStorage module #49

Open nick1n opened 11 years ago

nick1n commented 11 years ago

Needs to:

nick1n commented 10 years ago

Testing out localStorage and events has shown that IE8 will need to attach events to the document object while all other browsers need to add an event listener to the window object, so will need some sort of code like:

if (window.addEventListener) {
  $(window).bind('storage', function() {...});
} else {
  $(document).bind('storage', function() {...});
}

Also, in at least IE8 & 9, the storage event is called in all open instances of the site, so I will need to make sure it doesn't do anything when its the same tab that was editing the localStorage item. And, IE8's onstorage event object doesn't have a 'key' property.

nick1n commented 10 years ago

Initial commit of the Storage module Added basic unit tests for the Storage module commit 3107becaf23d378cf4dbd87a9a22244ae05f7401

nick1n commented 10 years ago

About the task with handling multiple tabs at once, I was thinking having some sort of lock variable in localstorage to indicate to other tabs if they should wait for another process in a different tab before executing their's, also have some sort of timestamp with it so if that timestamp gets out dated it will unlock localstorage and start its execution, so even if a tab that locked it gets closed or it something else another tab won't deadlock.