diff --git a/src/commandModel.js b/src/commandModel.js index cb33ed61..91a7e624 100644 --- a/src/commandModel.js +++ b/src/commandModel.js @@ -38,15 +38,18 @@ var Command = Backbone.Model.extend({ }, addWarning: function(msg) { - this.set('warnings', this.get('warnings').push(msg)); + this.get('warnings').push(msg); + // change numWarnings so the change event fires. This is bizarre -- Backbone can't + // detect if an array changes, so adding an element does nothing + this.set('numWarnings', this.get('numWarnings') ? this.get('numWarnings') + 1 : 1); }, getFormattedWarnings: function() { if (!this.get('warnings').length) { return ''; } - - return '
' + this.get('warnings').join('
') + '
'; + var i = ''; + return '' + i + this.get('warnings').join('
' + i) + '
'; }, initialize: function() { diff --git a/src/commandViews.js b/src/commandViews.js index 8f8b2f8e..8dea1e40 100644 --- a/src/commandViews.js +++ b/src/commandViews.js @@ -67,9 +67,14 @@ var CommandPromptView = Backbone.View.extend({ this.index = -1; // split commands on semicolon - _.each(value.split(';'), _.bind(function(command) { + _.each(value.split(';'), _.bind(function(command, index) { command = command.replace(/^(\s+)/, ''); command = command.replace(/(\s+)$/, ''); + + if (index > 0 && !command.length) { + return; + } + this.addToCollection(command); }, this)); }, @@ -140,7 +145,7 @@ var CommandView = Backbone.View.extend({ { resultType: '', result: '', - warnings: '' + formattedWarnings: this.model.getFormattedWarnings() }, this.model.toJSON() ); @@ -169,7 +174,6 @@ var CommandLineHistoryView = Backbone.View.extend({ }, addWarning: function(msg) { - console.log('here', arguments); var err = new Warning({ msg: msg }); @@ -183,8 +187,20 @@ var CommandLineHistoryView = Backbone.View.extend({ }, scrollDown: function() { - var el = $('#commandLineHistory')[0]; - el.scrollTop = el.scrollHeight; + // if commandDisplay is ever bigger than #terminal, we need to + // add overflow-y to terminal and scroll down + var cD = $('#commandDisplay')[0]; + var t = $('#terminal')[0]; + + if ($(t).hasClass('scrolling')) { + t.scrollTop = t.scrollHeight; + return; + } + if (cD.clientHeight > t.clientHeight) { + $(t).css('overflow-y', 'scroll'); + $(t).addClass('scrolling'); + t.scrollTop = t.scrollHeight; + } }, addOne: function(command) { diff --git a/src/index.html b/src/index.html index 8b0c2b61..d67f12e7 100644 --- a/src/index.html +++ b/src/index.html @@ -62,7 +62,7 @@ diff --git a/src/style/main.css b/src/style/main.css index cdb9688f..a5c5cd24 100644 --- a/src/style/main.css +++ b/src/style/main.css @@ -171,12 +171,17 @@ div.controls div.box.flex1 div.plus { /* Command Line */ -p.commandLine, p.commandLineResult { +p.commandLine, div.commandLineResult { opacity: 1; font-size: 16px; margin: 0px; } +p.commandLine div.commandLineWarnings p i.icon-exclamation-point { + color: yellow; + margin-right: 5px; +} + p.commandLine span.icons { float: right; }