diff --git a/static/quiz_item.coffee b/static/quiz_item.coffee index 414acfc..bfa4ad7 100644 --- a/static/quiz_item.coffee +++ b/static/quiz_item.coffee @@ -1,5 +1,6 @@ linearMode = false -linearCount = 0; +linearCount = 0 +selection = null refreshQuestion = () -> if(sessionStorage.getItem('user_items')) @@ -18,12 +19,14 @@ refreshQuestion = () -> $('#answer').addClass('hidden'); $('#answer').text(selection['answer']); input_element = document.getElementById('kana'); + $("#question-image").hide() if(selection['item_type'] == 'radical') $("#kana").attr("placeholder", "Meaning") document.body.style.backgroundColor = "deepskyblue"; wanakana.unbind(input_element); if(selection['question'].indexOf('http') >= 0) $("#question-image").attr("src", selection['question']); + $("#question-image").show() else $("#question-area").text(selection['question']); else @@ -100,7 +103,7 @@ $("#submit-answer").click (e) -> input_answer = document.getElementById('kana').value; if($("#kana").hasClass("correct")) refreshQuestion(); - else if($('#answer').text().split(/[,\.]/g).map((x) -> x.trim()).indexOf(input_answer) != -1) + else if(selection['answer'].split(/[,\.]/g).map((x) -> x.trim()).indexOf(input_answer) != -1) $("#kana").addClass("correct").removeClass("wrong"); else $("#kana").addClass("wrong").removeClass("correct").val('') diff --git a/static/quiz_item.js b/static/quiz_item.js index 9aea6b5..ffb1432 100644 --- a/static/quiz_item.js +++ b/static/quiz_item.js @@ -1,13 +1,15 @@ // Generated by CoffeeScript 1.10.0 (function() { - var filterQuestions, getItemTypeFilters, getSrsTypeFilters, linearCount, linearMode, refreshQuestion, toggleQuizMode, updateQuizItemStats; + var filterQuestions, getItemTypeFilters, getSrsTypeFilters, linearCount, linearMode, refreshQuestion, selection, toggleQuizMode, updateQuizItemStats; linearMode = false; linearCount = 0; + selection = null; + refreshQuestion = function() { - var input_element, items, selection; + var input_element, items; if (sessionStorage.getItem('user_items')) { items = JSON.parse(sessionStorage.getItem('user_items')); if (linearMode) { @@ -26,12 +28,14 @@ $('#answer').addClass('hidden'); $('#answer').text(selection['answer']); input_element = document.getElementById('kana'); + $("#question-image").hide(); if (selection['item_type'] === 'radical') { $("#kana").attr("placeholder", "Meaning"); document.body.style.backgroundColor = "deepskyblue"; wanakana.unbind(input_element); if (selection['question'].indexOf('http') >= 0) { - return $("#question-image").attr("src", selection['question']); + $("#question-image").attr("src", selection['question']); + return $("#question-image").show(); } else { return $("#question-area").text(selection['question']); } @@ -149,7 +153,7 @@ input_answer = document.getElementById('kana').value; if ($("#kana").hasClass("correct")) { return refreshQuestion(); - } else if ($('#answer').text().split(/[,\.]/g).map(function(x) { + } else if (selection['answer'].split(/[,\.]/g).map(function(x) { return x.trim(); }).indexOf(input_answer) !== -1) { return $("#kana").addClass("correct").removeClass("wrong");