Skip to content

Commit

Permalink
fixed saving and loading again.
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Aug 16, 2014
1 parent b413b3f commit d25222c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
32 changes: 15 additions & 17 deletions js/atc.js
@@ -1,25 +1,23 @@
;(function(){
ATC = function(args){

/* Load all arguments. */

if(args !== undefined)
for(key in args)
this[key] = args[key];

/* Constructors are capitalized methods. */

var isConstructor = function(method){
return method[0] === method[0].toUpperCase();
}

/* Create new objects from all constructors if not given as arguments. */
};

this.configure = function(args){
if(args !== undefined)
for(key in args)
this[key] = args[key];

for(obj in this)
if(isConstructor(obj)){
var instance = obj.charAt(0).toLowerCase() + obj.slice(1);
if(!this.hasOwnProperty(instance))
this[instance] = new this[obj]();
}
for(obj in this)
if(isConstructor(obj)){
var instance = obj.charAt(0).toLowerCase() + obj.slice(1);
if(!this.hasOwnProperty(instance))
this[instance] = new this[obj]();
}
};

this.configure(args);
};
})(undefined);
6 changes: 3 additions & 3 deletions js/save.js
@@ -1,9 +1,9 @@
;(function(localStorage, ATC){
;(function(window, ATC){

var retrieveLocally = function(atc){
var atc = new ATC(JSON.parse(localStorage.getItem("atc"))),
editor = ace.edit("editor");
atc.configure(JSON.parse(localStorage.getItem("atc")));

var editor = ace.edit("editor");
editor.setValue(atc.text || "");
editor.moveCursorTo(0, 0);
};
Expand Down

0 comments on commit d25222c

Please sign in to comment.