rollup stuff

This commit is contained in:
Peter Cottle 2012-11-03 11:53:25 -07:00
parent 866749bad5
commit 44322298ba
4 changed files with 35 additions and 3 deletions

View file

@ -39,6 +39,7 @@ var CommandPromptView = Backbone.View.extend({
events.on('processCommandFromEvent', this.addToCollection, this);
events.on('submitCommandValueFromEvent', this.submitValue, this);
events.on('rollupCommands', this.rollupCommands, this);
// hacky timeout focus
setTimeout(_.bind(function() {
@ -186,6 +187,22 @@ var CommandPromptView = Backbone.View.extend({
this.submitValue(value);
},
rollupCommands: function(numBack) {
var which = this.commands.toArray().slice(1, Number(numBack) + 1);
console.log(this.commands.toArray());
console.log(which);
var str = '';
_.each(which, function(commandEntry) {
str += commandEntry.get('text') + ';';
}, this);
console.log('the str', str);
var rolled = new CommandEntry({text: str});
this.commands.unshift(rolled);
Backbone.sync('create', rolled, function() { });
},
submitValue: function(value) {
// we should add if it's not a blank line and this is a new command...
// or if we edited the command