From fcba5f41240e61f845f35769814e11b4666590a6 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 6 Jan 2016 10:57:55 +0100 Subject: Don't check if you cannot parse --- public/js/hebrewparsetrainer.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/public/js/hebrewparsetrainer.js b/public/js/hebrewparsetrainer.js index dc838c7..bbaf2d9 100644 --- a/public/js/hebrewparsetrainer.js +++ b/public/js/hebrewparsetrainer.js @@ -16,6 +16,19 @@ * along with this program. If not, see . */ $(document).ready(function(){ + // http://stackoverflow.com/a/4399433/1544337 + jQuery.fn.shake = function(intShakes, intDistance, intDuration) { + this.each(function() { + $(this).css("position","relative"); + for (var x=1; x<=intShakes; x++) { + $(this).animate({left:(intDistance*-1)}, (intDuration/intShakes)/4) + .animate({left:intDistance}, (intDuration/intShakes)/2) + .animate({left:0}, (intDuration/intShakes)/4); + } + }); + return this; + }; + var audio_positive = new Audio('public/audio/positive.wav'); var audio_negative = new Audio('public/audio/negative.wav'); @@ -202,6 +215,11 @@ $(document).ready(function(){ function checkInput() { var answer = processInput(); + if (!answer && $('#trainer-input-'+input_count).val() != '') { + $('#trainer-input-'+input_count).shake(2, 12, 300); + return false; + } + for (var i in correct_answers) { var correct_answer = correct_answers[i]; if (JSON.stringify(answer) == JSON.stringify(correct_answer)) { -- cgit v1.2.3