diff options
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(); |