Fixed a broken image icon showing in some browsers where the placeholder for potential images was.

This commit is contained in:
neviyn 2016-01-19 20:47:58 +00:00
parent eba6c19f6e
commit 6c298c2c08
2 changed files with 13 additions and 6 deletions

View File

@ -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('')

View File

@ -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");