print tree string and load from string

This commit is contained in:
Peter Cottle 2012-10-25 15:37:13 -07:00
parent fcee1fa321
commit 5272cfea47

View file

@ -81,6 +81,15 @@ GitEngine.prototype.exportTree = function() {
return totalExport; return totalExport;
}; };
GitEngine.prototype.printTree = function() {
var str = escape(JSON.stringify(this.exportTree()));
return str;
};
GitEngine.prototype.printAndCopyTree = function() {
window.prompt('Copy the tree string below', this.printTree());
};
GitEngine.prototype.loadTree = function(tree) { GitEngine.prototype.loadTree = function(tree) {
// first clear everything // first clear everything
this.removeAll(); this.removeAll();
@ -90,6 +99,10 @@ GitEngine.prototype.loadTree = function(tree) {
this.reloadGraphics(); this.reloadGraphics();
}; };
GitEngine.prototype.loadTreeFromString = function(treeString) {
this.loadTree(JSON.parse(unescape(treeString)));
};
GitEngine.prototype.instantiateFromTree = function(tree) { GitEngine.prototype.instantiateFromTree = function(tree) {
// now we do the loading part // now we do the loading part
var createdSoFar = {}; var createdSoFar = {};