Skip to content
Snippets Groups Projects
Commit 1e8a0614 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

save script

parent bbb44f83
No related branches found
No related tags found
No related merge requests found
......@@ -596,4 +596,13 @@ label {
.consoleWarning {
color: orange;
}
.consoleComment {
color: darkgray;
}
#saveConsole {
height: 42px;
border-bottom-width: 0;
border-radius: 0;
}
\ No newline at end of file
......@@ -131,7 +131,10 @@
<div id="console">
<div>
<div id="consoleOutput"></div>
<input id="consoleInput" value="" placeholder="Type Command" class="form-control" type="text">
<div class="input-group">
<input id="consoleInput" value="" aria-describedby="consoleSaveScript" placeholder="Type Command" class="form-control" type="text">
<span class="input-group-addon btn btn-defualt" id="consoleSaveScript">Save Script</span>
</div>
</div>
</div>
<div id="menuWrapper"><div id="menuHeader"></div><div id="menuContent"></div></div>
......
......@@ -10,7 +10,7 @@ define(['jquery', 'underscore', 'backbone', 'appState'], function($, _, Backbone
el: "#console",
events: {
"click #consoleSaveScript": "_saveScript"
},
initialize: function(){
......@@ -42,12 +42,16 @@ define(['jquery', 'underscore', 'backbone', 'appState'], function($, _, Backbone
return appState.get("consoleIsVisible");
},
write: function(string){
this._writeOutput(string + "<br/>");
write: function(string){//for commands
this._writeOutput(string + "<br>");
},
log: function(string){//for comments
this._writeOutput("<span class='consoleComment'>" + string + "</span><br>");
},
warn: function(string){
this._writeOutput("<span class='consoleWarning'>" + string + "</span><br/>");
this._writeOutput("<span class='consoleWarning'>" + string + "</span><br>");
},
error: function(string){
......@@ -89,7 +93,25 @@ define(['jquery', 'underscore', 'backbone', 'appState'], function($, _, Backbone
// var command = $input.val();
var command = "nice try, this doesn't work yet :)";
$input.val("");
this.write(command);
this.log(command);
},
_saveScript: function(e){
e.preventDefault();
var self = this;
require(['fileSaver'], function(fileSaver){
fileSaver.saveConsoleScript(self.getConsoleData());
})
},
getConsoleData: function(){
var data = $("#consoleOutput").html().split("<br>");
data.pop();//last line is ""
var commands = []
_.each(data, function(line, index){
if (line.substr(0,5) != "<span") commands.push(line);
});
return commands.join('\n');
}
});
......
......@@ -140,6 +140,10 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
});
}
function saveConsoleScript(data){
saveData(data, "script", "js");
}
return {//return public methods
// save: save,
......@@ -150,6 +154,7 @@ define(['underscore', 'fileSaverLib', 'lattice', 'materials', 'ribbon', 'menuWra
// saveAssembler: saveAssembler,
loadFile: loadFile,
saveSequences: saveSequences,
saveSTL: saveSTL
saveSTL: saveSTL,
saveConsoleScript: saveConsoleScript
}
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment