From e6542fa00ef2b471a6a5eb43f0314cf8628b410a Mon Sep 17 00:00:00 2001 From: HelderSepu Date: Mon, 20 Jun 2016 22:05:15 -0400 Subject: [PATCH] Prevent scrolling on initial challenge run - Add additional parameter to function displayTestResults Correction to errors: Line exceeds the maximum line length of 80 max-len Do not scroll on JS challenges --- client/commonFramework/display-test-results.js | 8 ++++++-- client/commonFramework/end.js | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/client/commonFramework/display-test-results.js b/client/commonFramework/display-test-results.js index a925b3b213..0647384c87 100644 --- a/client/commonFramework/display-test-results.js +++ b/client/commonFramework/display-test-results.js @@ -1,6 +1,6 @@ window.common = (function({ $, common = { init: [] }}) { - common.displayTestResults = function displayTestResults(data = []) { + common.displayTestResults = function displayTestResults(data = [], down) { $('#testSuite').children().remove(); $('#testSuite').fadeIn('slow'); data.forEach(({ err = false, text = '' }) => { @@ -21,7 +21,11 @@ window.common = (function({ $, common = { init: [] }}) { `) .appendTo($('#testSuite')); }); - $('#scroll-locker').animate({ scrollTop: $(document).height() }, 'slow'); + if (down) { + $('#scroll-locker').animate( + { scrollTop: $(document).height() }, 'slow' + ); + } return data; }; diff --git a/client/commonFramework/end.js b/client/commonFramework/end.js index 1a841de50c..1a8ae7be86 100644 --- a/client/commonFramework/end.js +++ b/client/commonFramework/end.js @@ -110,7 +110,7 @@ $(document).ready(function() { return common.updateOutputDisplay('' + err); } common.updateOutputDisplay(output); - common.displayTestResults(tests); + common.displayTestResults(tests, true); if (solved) { common.showCompletion(); } @@ -140,7 +140,7 @@ $(document).ready(function() { } return common.updateOutputDisplay('' + err); } - common.displayTestResults(tests); + common.displayTestResults(tests, false); return null; }, ({ err }) => { @@ -164,7 +164,7 @@ $(document).ready(function() { return common.updateOutputDisplay('' + err); } common.codeStorage.updateStorage(challengeName, originalCode); - common.displayTestResults(tests); + common.displayTestResults(tests, false); return null; }, (err) => {