var selKeybInput;var wordLen;$(document).ready(function(){$.getWords2 = function(id){selKeybInput = document.getElementById('word');$.get('/exercises.php?getWord=2', {'dictionary_id': id}, function(data){$('.message').hide();var data = eval(data);setExercises2(data);});};function setExercises2(data){$('#exercise1, #exercise2, #exercise3').hide();if (data.result == 'end'){$('#mesEnd').animate({'opacity': 'show'}, 500);$('#mark').html('0/0');$('#stat').html(data.count+'/'+data.count+' (100%)');}else if (data.result == 'empty'){$('#mesEmpty').animate({'opacity': 'show'}, 500);$('#mark').html('0/0');$('#stat').html('0/0 (100%)');}else{$('#exercise2, #hintBox').show();wordLen = data.size;$('#word_id').val(data.id);$('#word_translate').text(data.translate);$('#word_desc').text(data.desc);$('#mark').text(data.mark);$('#stat').text(data.stat);$('#word').val('').focus();$('#hint').removeAttr('disabled');$('#wordLen').html(wordLen);var s = '';for (i=0; i<wordLen; i++) s += '*';$('#word_hint').html(s);}};$('#form').submit(function(){var word = $('#word').val();if (word){$.get('/exercises.php', {'word_id': $('#word_id').val(), 'word': word, 'dictionary_id': $('#dictionary').val()}, function(data){var data = eval(data);if (data.result == 'error'){$('#word').addClass('error').delay(500, function(){$(this).removeClass('error');});}else{$('#word').addClass('true').delay(500, function(){$(this).removeClass('true');setExercises2(data);});}});}return false;});$('#hint').click(function(){$.get('/exercises.php?hint2', {'word_id': $('#word_id').val()}, function(html){if (html){$('#word_hint').text(html);$('#hintBox').hide();$('#word').focus();}});$(this).attr('disabled', 'disabled'); });$('#word').bind('keyup', function(){$.countLen();});$.countLen = function(){var len = wordLen - $('#word').val().length;$('#wordLen').html(len);if (len <0) $('#hintBox').addClass('red');else $('#hintBox').removeClass('red');};});
