From 780f6a4fa60b823c639c43d5c8fa811b935352fe Mon Sep 17 00:00:00 2001 From: Hauke Klement Date: Fri, 27 Mar 2015 09:41:58 +0100 Subject: [PATCH] show flash message if permitted execution time is exceeded during test execution --- app/assets/javascripts/editor.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 33b57d8d..4187bb4a 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -394,10 +394,17 @@ $(function() { $('#results ul').first().html(''); $('.test-count .number').html(response.length); clearOutput(); + _.each(response, function(result, index) { printOutput(result, false, index); printScoringResult(result, index); }); + + if (_.some(response, function(result) { + return result.status === 'timeout'; + })) { + showTimeoutMessage(); + } }; var renderCode = function(event) { @@ -559,10 +566,7 @@ $(function() { var showStatus = function(output) { if (output.status === 'timeout') { - $.flash.danger({ - icon: ['fa', 'fa-clock-o'], - text: $('#editor').data('message-timeout') - }); + showTimeoutMessage(); } else if (output.stderr) { $.flash.danger({ icon: ['fa', 'fa-bug'], @@ -580,6 +584,13 @@ $(function() { $('a[data-toggle="tab"]').eq(index || 0).tab('show'); }; + var showTimeoutMessage = function() { + $.flash.danger({ + icon: ['fa', 'fa-clock-o'], + text: $('#editor').data('message-timeout') + }); + }; + var showWorkspaceTab = function(event) { event.preventDefault(); showTab(1);