Solves #451 explain permalink and import tree now, and add command

This commit is contained in:
Peter Cottle 2018-01-07 16:56:13 -08:00
parent f872840544
commit c1854a0d96
4 changed files with 19 additions and 1 deletions

View file

@ -125,7 +125,8 @@ var regexMap = {
'importLevelNow': /^importLevelNow($|\s)/,
'import tree': /^import +tree$/,
'import level': /^import +level$/,
'undo': /^undo($|\s)/
'undo': /^undo($|\s)/,
'share permalink': /^share( +permalink)?$/
};
var getAllCommands = function() {

View file

@ -223,6 +223,16 @@ var Sandbox = Backbone.View.extend({
});
},
sharePermalink: function(command, deferred) {
var treeJSON = JSON.stringify(this.mainVis.gitEngine.exportTree());
var url =
'https://learngitbranching.js.org/?NODEMO&command=importTreeNow%20' + escape(treeJSON);
command.setResult(
intl.todo('Here is a link to the current state of the tree: ') + url
);
command.finishWith(deferred);
},
resetSolved: function(command, deferred) {
LevelActions.resetLevelsSolved();
command.addWarning(
@ -253,6 +263,7 @@ var Sandbox = Backbone.View.extend({
'importTreeNow': this.importTreeNow,
'import level': this.importLevel,
'importLevelNow': this.importLevelNow,
'share permalink': this.sharePermalink,
};
var method = commandMap[command.get('method')];