Fixed whitespace issue when checking input against answer.

This commit is contained in:
neviyn 2015-10-05 15:48:57 +01:00
parent a8a141f3df
commit bb1a6e15ec
2 changed files with 4 additions and 1 deletions

View File

@ -44,10 +44,12 @@ $(document).keypress (e) ->
$("#submit-answer").click (e) ->
e.preventDefault();
answers = $('#answer').text().split(/[,\.]/g);
answers = $.map(answers, (x) -> )
input_answer = document.getElementById('kana').value;
if($("#kana").hasClass("correct"))
refreshQuestion();
else if($('#answer').text().split(/[,\.]/g).indexOf(input_answer) != -1)
else if($('#answer').text().split(/[,\.]/g).map((x) -> x.trim()).indexOf(input_answer) != -1)
$("#kana").addClass("correct").removeClass("wrong");
else
$("#kana").addClass("wrong").removeClass("correct").val('')

View File

@ -44,5 +44,6 @@
</div>
</div>
</div>
<script src="{{ url_for('static', filename='wanakana.min.js')}}"></script>
<script defer src="{{ url_for('static', filename='quiz_item.js')}}"></script>
{% endblock %}