Cleanup of saving/loading process

This commit is contained in:
jdescottes
2013-10-10 00:06:11 +02:00
parent 564f74265a
commit 55e3607ecc
5 changed files with 125 additions and 84 deletions

View File

@ -2,7 +2,11 @@
var ns = $.namespace('pskl.controller');
ns.PiskelController = function (piskel) {
this.setPiskel(piskel);
if (piskel) {
this.setPiskel(piskel);
} else {
throw 'A piskel instance is mandatory for instanciating PiskelController';
}
};
ns.PiskelController.prototype.setPiskel = function (piskel) {
@ -187,14 +191,4 @@
ns.PiskelController.prototype.load = function (data) {
this.deserialize(JSON.stringify(data));
};
ns.PiskelController.prototype.deserialize = function (jsonStr) {
try {
var piskel = pskl.utils.Serializer.deserializePiskel(jsonStr);
this.setPiskel(piskel);
} catch (e) {
console.error('Failed to deserialize');
console.error(e.stack);
}
};
})();