Fixed WK link url generation for radicals.

This commit is contained in:
neviyn 2016-01-20 20:57:26 +00:00
parent d0dfdee06c
commit bcc9fd08c7
2 changed files with 5 additions and 5 deletions

View File

@ -29,6 +29,7 @@ refreshQuestion = () ->
$("#question-image").show() $("#question-image").show()
else else
$("#question-area").text(selection['question']); $("#question-area").text(selection['question']);
document.getElementById('view-on-wk').href ="https://www.wanikani.com/radicals/" + selection['answer']
else else
if(selection['item_type'] == 'kanji') if(selection['item_type'] == 'kanji')
document.body.style.backgroundColor = "deeppink"; document.body.style.backgroundColor = "deeppink";
@ -41,8 +42,7 @@ refreshQuestion = () ->
else else
$("#kana").attr("placeholder", "かな") $("#kana").attr("placeholder", "かな")
wanakana.bind(input_element); wanakana.bind(input_element);
urlForType = if selection['item_type'] == 'radical' then 'radicals' else selection['item_type'] document.getElementById('view-on-wk').href ="https://www.wanikani.com/" + selection['item_type'] + "/" + selection['question']
document.getElementById('view-on-wk').href ="https://www.wanikani.com/" + urlForType + "/" + selection['question']
updateQuizItemStats = () -> updateQuizItemStats = () ->
$('#radical-num').text(sessionStorage.getItem('radical_count')); $('#radical-num').text(sessionStorage.getItem('radical_count'));

View File

@ -9,7 +9,7 @@
selection = null; selection = null;
refreshQuestion = function() { refreshQuestion = function() {
var input_element, items, urlForType; 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) {
@ -39,6 +39,7 @@
} else { } else {
$("#question-area").text(selection['question']); $("#question-area").text(selection['question']);
} }
return document.getElementById('view-on-wk').href = "https://www.wanikani.com/radicals/" + selection['answer'];
} else { } else {
if (selection['item_type'] === 'kanji') { if (selection['item_type'] === 'kanji') {
document.body.style.backgroundColor = "deeppink"; document.body.style.backgroundColor = "deeppink";
@ -53,9 +54,8 @@
$("#kana").attr("placeholder", "かな"); $("#kana").attr("placeholder", "かな");
wanakana.bind(input_element); wanakana.bind(input_element);
} }
return document.getElementById('view-on-wk').href = "https://www.wanikani.com/" + selection['item_type'] + "/" + selection['question'];
} }
urlForType = selection['item_type'] === 'radical' ? 'radicals' : selection['item_type'];
return document.getElementById('view-on-wk').href = "https://www.wanikani.com/" + urlForType + "/" + selection['question'];
} }
}; };