diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-02-23 17:48:01 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-02-24 13:10:46 +0100 |
commit | fc90c0dd2d03a4e842a5f4df546da868850d9657 (patch) | |
tree | 49655e07741c4e57d57e137f7ddc7a2a14af4b36 /js/codeq/python.js | |
parent | 1dd4d473bb136c607eeea3a2d655b3f56e5aeee8 (diff) |
Ensure a ~1 second delay before displaying test results
Diffstat (limited to 'js/codeq/python.js')
-rw-r--r-- | js/codeq/python.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/js/codeq/python.js b/js/codeq/python.js index f2b0184..2ea960a 100644 --- a/js/codeq/python.js +++ b/js/codeq/python.js @@ -240,12 +240,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ } }); jqBtnTest.on('click', function () { + // random timeout before returning results to the user, helps + // maintain the illusion + var timeout = 500 + Math.random() * 1000; + editor.setOption('readOnly', true); + terminal.inputDisable(); jqBtnTest.ladda('start'); - codeq.comms.sendTest({ - 'program': editor.getDoc().getValue(), - 'problem_id': problemDef.id - }) + + codeq.throttle( + codeq.comms.sendTest({ + 'program': editor.getDoc().getValue(), + 'problem_id': problemDef.id + }), + timeout) .then(function (data) { if (data.code === 0) { hinter.handle(data.hints); @@ -257,6 +265,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ .fail(commError) .fin(function () { editor.setOption('readOnly', false); + terminal.inputEnable(); jqBtnTest.ladda('stop'); }) .done(); |