diff --git a/static/quiz_item.coffee b/static/quiz_item.coffee index 8a2e037..ed7d58d 100644 --- a/static/quiz_item.coffee +++ b/static/quiz_item.coffee @@ -41,12 +41,16 @@ getSrsTypeFilters = () -> srs_levels = ['burnedcheck','enlightencheck','mastercheck','gurucheck','apprenticecheck'] return (document.getElementById(s).value for s in srs_levels when document.getElementById(s).checked).toString() +getItemTypeFilters = () -> + item_types = ['radicalcheck', 'kanjicheck', 'vocabcheck'] + return (document.getElementById(s).value for s in item_types when document.getElementById(s).checked).toString() + filterQuestions = () -> sessionStorage.removeItem('user_items') sessionStorage.removeItem('radical_count') sessionStorage.removeItem('kanji_count') sessionStorage.removeItem('vocabulary_count') - target_url = "/user_items?level_range=" + $('#filter-input').val() + "&item_state=" + getSrsTypeFilters() + target_url = "/user_items?level_range=" + $('#filter-input').val() + "&item_state=" + getSrsTypeFilters() + "&item_types=" + getItemTypeFilters() $.ajax url: target_url, dataType: 'json', @@ -55,7 +59,6 @@ filterQuestions = () -> document.getElementById('filter-input').value = '' $('#error-text').text(e['error']) $('#error-area').show(); - filterQuestions() else sessionStorage.setItem('user_items', JSON.stringify(e['item_list'])) sessionStorage.setItem('radical_count', e['radical_count']) diff --git a/static/quiz_item.js b/static/quiz_item.js index 4013ff7..34388c8 100644 --- a/static/quiz_item.js +++ b/static/quiz_item.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript 1.10.0 (function() { - var filterQuestions, getSrsTypeFilters, refreshQuestion, updateQuizItemStats; + var filterQuestions, getItemTypeFilters, getSrsTypeFilters, refreshQuestion, updateQuizItemStats; refreshQuestion = function() { var input_element, items, selection; @@ -65,13 +65,29 @@ })()).toString(); }; + getItemTypeFilters = function() { + var item_types, s; + item_types = ['radicalcheck', 'kanjicheck', 'vocabcheck']; + return ((function() { + var i, len, results; + results = []; + for (i = 0, len = item_types.length; i < len; i++) { + s = item_types[i]; + if (document.getElementById(s).checked) { + results.push(document.getElementById(s).value); + } + } + return results; + })()).toString(); + }; + filterQuestions = function() { var target_url; sessionStorage.removeItem('user_items'); sessionStorage.removeItem('radical_count'); sessionStorage.removeItem('kanji_count'); sessionStorage.removeItem('vocabulary_count'); - target_url = "/user_items?level_range=" + $('#filter-input').val() + "&item_state=" + getSrsTypeFilters(); + target_url = "/user_items?level_range=" + $('#filter-input').val() + "&item_state=" + getSrsTypeFilters() + "&item_types=" + getItemTypeFilters(); return $.ajax({ url: target_url, dataType: 'json', @@ -79,8 +95,7 @@ if (e.hasOwnProperty('error')) { document.getElementById('filter-input').value = ''; $('#error-text').text(e['error']); - $('#error-area').show(); - return filterQuestions(); + return $('#error-area').show(); } else { sessionStorage.setItem('user_items', JSON.stringify(e['item_list'])); sessionStorage.setItem('radical_count', e['radical_count']); diff --git a/templates/quiz.html b/templates/quiz.html index d14d395..6c504af 100644 --- a/templates/quiz.html +++ b/templates/quiz.html @@ -1,7 +1,7 @@ {% extends "layout.html" %} {% block content %} -{% set srs_levels = [ ('burned', 'Burned'), ('enlighten', 'Enlightened'), ('master', 'Master'), -('guru', 'Guru'), ('apprentice', 'Apprentice') ] -%} +{% set srs_levels = ['burned', 'enlighten', 'master', 'guru', 'apprentice'] -%} +{% set item_types = ['radical', 'kanji', 'vocab'] %}