summaryrefslogtreecommitdiff
path: root/js/codeq/prolog.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq/prolog.js')
-rw-r--r--js/codeq/prolog.js41
1 files changed, 24 insertions, 17 deletions
diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js
index 3d34423..ea4c9b2 100644
--- a/js/codeq/prolog.js
+++ b/js/codeq/prolog.js
@@ -284,28 +284,35 @@ 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({
+
+ codeq.throttle(
+ codeq.comms.sendTest({
'program': editor.getDoc().getValue(),
'problem_id': problemDef.id
- })
- .then(function (data) {
- if (data.code === 0) {
- hinter.handle(data.hints);
- }
- else {
- terminal.append(data.message + '\n', 'error');
- }
- })
- .fail(commError)
- .fin(function () {
- editor.setOption('readOnly', false);
- terminal.inputEnable();
- jqBtnTest.ladda('stop');
- })
- .done();
+ }),
+ timeout)
+ .then(function (data) {
+ if (data.code === 0) {
+ hinter.handle(data.hints);
+ }
+ else {
+ terminal.append(data.message + '\n', 'error');
+ }
+ })
+ .fail(commError)
+ .fin(function () {
+ editor.setOption('readOnly', false);
+ terminal.inputEnable();
+ jqBtnTest.ladda('stop');
+ })
+ .done();
});
codeq.comms.loadProblem(problemDef.id).done();