Local Storage
Monkey Forums/Monkey Code/Local Storage
| ||
Grab the files and plop them in your modules directory to use : http://www.moofoo.net/monkey/moofoo.rar * This also includes the Async Module Currently only supporting Flash & HTML5.. etc..etc.. This module enables you to store information to the devices local storage system. The data is stored and access using a key based system. Import moofoo.localstorage Global lclStorage:localStorage = New localStorage() lclStorage.save("testkey", "Test String") Print lclStorage.load("testkey") lclStorage.remove("testkey") Print "**"+lclStorage.load("testkey") |
| ||
This looks cool Tim, nice one. |
| ||
Interesting (tested with FF4 and Chrome9) I checked your code and the one provided by mojo for SaveState: mojo's code doesnt' work under FF4 Your code moofooLocalStorage.prototype.save = function( key, data){ localStorage.setItem( "moofooLocalStorage@"+key, data ); }; mojo- gxtkApp.prototype.SaveState=function( state ){ localStorage.setItem( "gxtkapp@... ); } edit: there is some problem with code-box; there is NO \ after @ The only - apparent to me - difference is in the 'key' name (your is user-defined, the mojo's one id linked with the URL. |
| ||
Sure - mojo allows you to save a single state per application (document.URL is the app title) . My Code allows many different saves per application. If it does not work in pre-release versions of software then don't worry about it - local storage is probably off by default to prevent breakages. |
| ||
Updateding to include expiry times so that localStorage can be used as a simple time based cache. |
| ||
No idea why I'm wasting time on Flash - what a cad! |
| ||
flash is the most lucrative target imo. Monkey has a long way to go to make the flash target viable and every little mod helps. |
| ||
Hi, You should include something like document.url in the key or all apps will see the same data. |
| ||
Hmm, my understanding was that localstorage is already domain specific. Obviously that's different for non-web-based apps.. |
| ||
You could still have two monkey apps hosted on the same domain. |
| ||
Hi, I remember having this problem when getting AppState going - may only be on some browsers - and munging with document.URL solved it. |
| ||
Hello, It slipped my mind that there WILL be *many* monkey apps on portals! How bad am I!! Wouldn't want all BigPortal.com HTML5 games sharing each others data! I will correct my errors - bye! Tim. |
| ||
Uh, 5 years ago... still. I don't understand, how munging mith document.URL would prevent other apps from reading the files, if that is indeed possible. I am sure this feature is not by design, but a bug/vulnerability of early html5 implementations. |