From 297716189ad1574ae1aaf8b53faa2991fe1fe87d Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Mon, 26 Oct 2015 19:30:50 -0400 Subject: [PATCH] write to console --- css/main.css | 9 ++++--- js/menus/otherUI/Console.js | 54 +++++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/css/main.css b/css/main.css index 44df274c..ef4fa64a 100644 --- a/css/main.css +++ b/css/main.css @@ -581,12 +581,15 @@ label { border-radius: 0; } #consoleOutput{ - min-height:35px; - background-color: #ddd; - opacity: 0.9; + min-height:42px; + background-color: rgba(255,255,255,0.8); border: 2px solid #bdc3c7; border-bottom-width: 0; border-top-width: 0; overflow: auto; resize: vertical; + padding: 10px 20px; + font-family: Courier, monospace; + font-size: 13px; + line-height: 25px; } \ No newline at end of file diff --git a/js/menus/otherUI/Console.js b/js/menus/otherUI/Console.js index dfe2f7ca..15f14a37 100644 --- a/js/menus/otherUI/Console.js +++ b/js/menus/otherUI/Console.js @@ -15,8 +15,14 @@ define(['jquery', 'underscore', 'backbone', 'appState'], function($, _, Backbone initialize: function(){ + _.bindAll(this, "_onKeyUp"); + $(document).bind('keyup', {}, this._onKeyUp); + this.listenTo(appState, "change:consoleIsVisible", this._setVisibility); - this._setWidth(); + this.listenTo(appState, "change:menuIsVisible", function(){ + this._setWidth(false); + }); + this._setWidth(false); this._setVisibility(); }, @@ -28,16 +34,54 @@ define(['jquery', 'underscore', 'backbone', 'appState'], function($, _, Backbone }, _setVisibility: function(){ - if (appState.get("consoleIsVisible")) this.show(); - else this.hide(); + if (appState.get("consoleIsVisible")) this._show(); + else this._hide(); + }, + + write: function(string){ + this._writeOutput(string + "<br/>"); + }, + + warn: function(string){ + }, - show: function(){ + error: function(string){ + + }, + + _writeOutput: function(html){ + var $output = $("#consoleOutput"); + var height = $output.height(); + $output.append(html); + $output.height(height); + $output.scrollTop($output.scrollTop()+$output.innerHeight()); + }, + + _show: function(){ this.$el.fadeIn(); }, - hide: function(){ + _hide: function(){ this.$el.fadeOut(); + }, + + _onKeyUp: function(e){ + var $input = $("#consoleInput"); + if ($input.is(":focus")){ +// if (e.keyCode == 38) $output.val(this.model.getPrevHistElem()); +// else if (e.keyCode == 40) $output.val(this.model.getNewerHistElem()); + if (e.keyCode == 13) this._enterCommand($input); + } else { + } + }, + + _enterCommand: function($input){ +// var command = $input.val(); + var command = "nice try, this doesn't work yet :)"; + $input.val(""); + this.write(command); + $input.focus(); } }); -- GitLab