Added Linear Mode which quizzes all items in order.
This commit is contained in:
parent
a94dee2d97
commit
441623a947
@ -1,6 +1,15 @@
|
||||
linearMode = false
|
||||
linearCount = 0;
|
||||
|
||||
refreshQuestion = () ->
|
||||
if(sessionStorage.getItem('user_items'))
|
||||
items = JSON.parse(sessionStorage.getItem('user_items'))
|
||||
if linearMode
|
||||
selection = items[linearCount]
|
||||
linearCount++
|
||||
if linearCount >= items.length # Wrap around
|
||||
linearCount = 0
|
||||
else
|
||||
selection = items[Math.floor(Math.random() * items.length)]
|
||||
$("#help-area").text('');
|
||||
$("#kana").removeClass("correct").val('');
|
||||
@ -70,8 +79,18 @@ $('#filter-form').submit( (e) ->
|
||||
e.preventDefault()
|
||||
filterQuestions()
|
||||
$('#modal-filter').modal('hide')
|
||||
linearCount = 0
|
||||
)
|
||||
|
||||
toggleQuizMode = () ->
|
||||
linearMode = !linearMode
|
||||
if linearMode
|
||||
$('#mode-toggle').text("Linear Mode")
|
||||
else
|
||||
linearCount = 0
|
||||
$('#mode-toggle').text("Random Mode")
|
||||
refreshQuestion()
|
||||
|
||||
$(document).keypress (e) ->
|
||||
if(e.which == 13)
|
||||
$("#submit-answer").click();
|
||||
@ -112,4 +131,5 @@ $('#success-area').find('button').click () ->
|
||||
$ ->
|
||||
$(document).ready ->
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
document.getElementById('mode-toggle').onclick = toggleQuizMode
|
||||
filterQuestions()
|
||||
|
@ -1,12 +1,24 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
(function() {
|
||||
var filterQuestions, getItemTypeFilters, getSrsTypeFilters, refreshQuestion, updateQuizItemStats;
|
||||
var filterQuestions, getItemTypeFilters, getSrsTypeFilters, linearCount, linearMode, refreshQuestion, toggleQuizMode, updateQuizItemStats;
|
||||
|
||||
linearMode = false;
|
||||
|
||||
linearCount = 0;
|
||||
|
||||
refreshQuestion = function() {
|
||||
var input_element, items, selection;
|
||||
if (sessionStorage.getItem('user_items')) {
|
||||
items = JSON.parse(sessionStorage.getItem('user_items'));
|
||||
if (linearMode) {
|
||||
selection = items[linearCount];
|
||||
linearCount++;
|
||||
if (linearCount >= items.length) {
|
||||
linearCount = 0;
|
||||
}
|
||||
} else {
|
||||
selection = items[Math.floor(Math.random() * items.length)];
|
||||
}
|
||||
$("#help-area").text('');
|
||||
$("#kana").removeClass("correct").val('');
|
||||
$("#question-area").text('');
|
||||
@ -110,9 +122,21 @@
|
||||
$('#filter-form').submit(function(e) {
|
||||
e.preventDefault();
|
||||
filterQuestions();
|
||||
return $('#modal-filter').modal('hide');
|
||||
$('#modal-filter').modal('hide');
|
||||
return linearCount = 0;
|
||||
});
|
||||
|
||||
toggleQuizMode = function() {
|
||||
linearMode = !linearMode;
|
||||
if (linearMode) {
|
||||
$('#mode-toggle').text("Linear Mode");
|
||||
} else {
|
||||
linearCount = 0;
|
||||
$('#mode-toggle').text("Random Mode");
|
||||
}
|
||||
return refreshQuestion();
|
||||
};
|
||||
|
||||
$(document).keypress(function(e) {
|
||||
if (e.which === 13) {
|
||||
return $("#submit-answer").click();
|
||||
@ -164,6 +188,7 @@
|
||||
$(function() {
|
||||
return $(document).ready(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
document.getElementById('mode-toggle').onclick = toggleQuizMode;
|
||||
return filterQuestions();
|
||||
});
|
||||
});
|
||||
|
@ -11,7 +11,7 @@
|
||||
</div>
|
||||
<form id="filter-form">
|
||||
<div class="modal-body">
|
||||
<label for=filter-input">Level</label><input type="text" pattern="\d[\d-,]*\d*" class="form-control" id="filter-input" placeholder="e.g. 1-3,5,8">
|
||||
<label for=filter-input">Level</label><input type="text" pattern="\d[\d-,]*\d*" class="form-control" id="filter-input" placeholder="e.g. 1-3,5,8 (leave blank for all)">
|
||||
<br />
|
||||
<p><strong>Progress</strong></p>
|
||||
{% for srs_tag in srs_levels %}
|
||||
@ -40,6 +40,11 @@
|
||||
</a>
|
||||
</div>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<button type="button" id="mode-toggle" class="btn btn-default navbar-btn">
|
||||
Random Mode
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="itemfilter" class="btn btn-default navbar-btn" data-toggle="modal" data-target="#modal-filter">
|
||||
Filter
|
||||
|
Loading…
Reference in New Issue
Block a user