Added serialization/deserialization capabilities

Two changes to Framesheet :
*  serialize : basic implementation using JSON.stringify
* deserialize : added method
This commit is contained in:
Julian Descottes 2012-08-29 00:57:55 +02:00
parent 629959e625
commit 4366fc42cc

View File

@ -19,10 +19,23 @@ var FrameSheetModel = (function() {
return true; // I'm always right dude
},
// Could be use to pass around model using long GET param (good enough for simple models) and
// Could be used to pass around model using long GET param (good enough for simple models) and
// do some temporary locastorage
serialize: function() {
throw "FrameSheet.serialize Not implemented"
return JSON.stringify(frames);
},
/**
* Load a framesheet from a string that might have been persisted in db / localstorage
* Overrides existing frames.
* @param {String} serialized
*/
deserializeFramesheet : function (serialized) {
try {
frames = eval(serialized);
} catch (e) {
throw "Could not load serialized framesheet." + e.getMessage()
}
},
addEmptyFrame: function() {