diff --git a/src/git.js b/src/git.js index ac4ecbab..5cfd3c17 100644 --- a/src/git.js +++ b/src/git.js @@ -81,6 +81,15 @@ GitEngine.prototype.exportTree = function() { 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) { // first clear everything this.removeAll(); @@ -90,6 +99,10 @@ GitEngine.prototype.loadTree = function(tree) { this.reloadGraphics(); }; +GitEngine.prototype.loadTreeFromString = function(treeString) { + this.loadTree(JSON.parse(unescape(treeString))); +}; + GitEngine.prototype.instantiateFromTree = function(tree) { // now we do the loading part var createdSoFar = {};