From 889d7562f924528c9ea036fec915d9a45e220953 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 21 Oct 2015 17:17:11 +0200 Subject: [PATCH] Show the input messages and set focus correct on input required. --- app/assets/javascripts/editor.js | 10 ++++++---- app/views/exercises/implement.html.slim | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 7ccff39d..3966f584 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -1160,7 +1160,7 @@ $(function() { } switch(msg.cmd) { case 'input': - showPrompt(); + showPrompt(msg); break; case 'write': printWebsocketOutput(msg); @@ -1249,11 +1249,13 @@ $(function() { executeWebsocketCommand(msg); }; - var showPrompt = function() { - if (prompt.isPresent() && prompt.hasClass('hidden')) { + var showPrompt = function(msg) { + var label = $('#prompt .input-group-addon'); + label.text(msg.data || label.data('prompt')); + if (prompt.isPresent() && prompt.hasClass('hidden')) { prompt.removeClass('hidden'); } - prompt.focus(); + $('#prompt input').focus(); } var hidePrompt = function() { diff --git a/app/views/exercises/implement.html.slim b/app/views/exercises/implement.html.slim index 80193cac..d01792d1 100644 --- a/app/views/exercises/implement.html.slim +++ b/app/views/exercises/implement.html.slim @@ -39,7 +39,7 @@ #output-col1 // todo set to full width if turtle isnt used #prompt.input-group.hidden - span.input-group-addon = t('exercises.editor.input') + span.input-group-addon data-prompt=t('exercises.editor.input') = t('exercises.editor.input') input#prompt-input.form-control type='text' span.input-group-btn button#prompt-submit.btn.btn-primary type="button" = t('exercises.editor.send')