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 linearMode = false
linearCount = 0; linearCount = 0
selection = null
refreshQuestion = () -> refreshQuestion = () ->
if(sessionStorage.getItem('user_items')) if(sessionStorage.getItem('user_items'))
@ -18,12 +19,14 @@ refreshQuestion = () ->
$('#answer').addClass('hidden'); $('#answer').addClass('hidden');
$('#answer').text(selection['answer']); $('#answer').text(selection['answer']);
input_element = document.getElementById('kana'); input_element = document.getElementById('kana');
$("#question-image").hide()
if(selection['item_type'] == 'radical') if(selection['item_type'] == 'radical')
$("#kana").attr("placeholder", "Meaning") $("#kana").attr("placeholder", "Meaning")
document.body.style.backgroundColor = "deepskyblue"; document.body.style.backgroundColor = "deepskyblue";
wanakana.unbind(input_element); wanakana.unbind(input_element);
if(selection['question'].indexOf('http') >= 0) if(selection['question'].indexOf('http') >= 0)
$("#question-image").attr("src", selection['question']); $("#question-image").attr("src", selection['question']);
$("#question-image").show()
else else
$("#question-area").text(selection['question']); $("#question-area").text(selection['question']);
else else
@ -100,7 +103,7 @@ $("#submit-answer").click (e) ->
input_answer = document.getElementById('kana').value; input_answer = document.getElementById('kana').value;
if($("#kana").hasClass("correct")) if($("#kana").hasClass("correct"))
refreshQuestion(); 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"); $("#kana").addClass("correct").removeClass("wrong");
else else
$("#kana").addClass("wrong").removeClass("correct").val('') $("#kana").addClass("wrong").removeClass("correct").val('')

View File

@ -1,13 +1,15 @@
// Generated by CoffeeScript 1.10.0 // Generated by CoffeeScript 1.10.0
(function() { (function() {
var filterQuestions, getItemTypeFilters, getSrsTypeFilters, linearCount, linearMode, refreshQuestion, toggleQuizMode, updateQuizItemStats; var filterQuestions, getItemTypeFilters, getSrsTypeFilters, linearCount, linearMode, refreshQuestion, selection, toggleQuizMode, updateQuizItemStats;
linearMode = false; linearMode = false;
linearCount = 0; linearCount = 0;
selection = null;
refreshQuestion = function() { refreshQuestion = function() {
var input_element, items, selection; var input_element, items;
if (sessionStorage.getItem('user_items')) { if (sessionStorage.getItem('user_items')) {
items = JSON.parse(sessionStorage.getItem('user_items')); items = JSON.parse(sessionStorage.getItem('user_items'));
if (linearMode) { if (linearMode) {
@ -26,12 +28,14 @@
$('#answer').addClass('hidden'); $('#answer').addClass('hidden');
$('#answer').text(selection['answer']); $('#answer').text(selection['answer']);
input_element = document.getElementById('kana'); input_element = document.getElementById('kana');
$("#question-image").hide();
if (selection['item_type'] === 'radical') { if (selection['item_type'] === 'radical') {
$("#kana").attr("placeholder", "Meaning"); $("#kana").attr("placeholder", "Meaning");
document.body.style.backgroundColor = "deepskyblue"; document.body.style.backgroundColor = "deepskyblue";
wanakana.unbind(input_element); wanakana.unbind(input_element);
if (selection['question'].indexOf('http') >= 0) { if (selection['question'].indexOf('http') >= 0) {
return $("#question-image").attr("src", selection['question']); $("#question-image").attr("src", selection['question']);
return $("#question-image").show();
} else { } else {
return $("#question-area").text(selection['question']); return $("#question-area").text(selection['question']);
} }
@ -149,7 +153,7 @@
input_answer = document.getElementById('kana').value; input_answer = document.getElementById('kana').value;
if ($("#kana").hasClass("correct")) { if ($("#kana").hasClass("correct")) {
return refreshQuestion(); return refreshQuestion();
} else if ($('#answer').text().split(/[,\.]/g).map(function(x) { } else if (selection['answer'].split(/[,\.]/g).map(function(x) {
return x.trim(); return x.trim();
}).indexOf(input_answer) !== -1) { }).indexOf(input_answer) !== -1) {
return $("#kana").addClass("correct").removeClass("wrong"); return $("#kana").addClass("correct").removeClass("wrong");