Now using query string instead of dedicated route.
This commit is contained in:
parent
25d916d4a0
commit
231b4231a3
@ -35,6 +35,7 @@ updateQuizItemStats = () ->
|
||||
$('#radical-num').text(sessionStorage.getItem('radical_count'));
|
||||
$('#kanji-num').text(sessionStorage.getItem('kanji_count'));
|
||||
$('#vocab-num').text(sessionStorage.getItem('vocabulary_count'));
|
||||
$('#total-num').text(parseInt(sessionStorage.getItem('radical_count')) + parseInt(sessionStorage.getItem('kanji_count'))+ parseInt(sessionStorage.getItem('vocabulary_count')))
|
||||
|
||||
filterQuestions = () ->
|
||||
input_data = $('#filter-input').val()
|
||||
@ -43,7 +44,7 @@ filterQuestions = () ->
|
||||
sessionStorage.removeItem('radical_count')
|
||||
sessionStorage.removeItem('kanji_count')
|
||||
sessionStorage.removeItem('vocabulary_count')
|
||||
target_url = "/user_items/" + input_data
|
||||
target_url = "/user_items?level_range=" + input_data
|
||||
$.ajax
|
||||
url: target_url,
|
||||
dataType: 'json',
|
||||
|
@ -45,7 +45,8 @@
|
||||
updateQuizItemStats = function() {
|
||||
$('#radical-num').text(sessionStorage.getItem('radical_count'));
|
||||
$('#kanji-num').text(sessionStorage.getItem('kanji_count'));
|
||||
return $('#vocab-num').text(sessionStorage.getItem('vocabulary_count'));
|
||||
$('#vocab-num').text(sessionStorage.getItem('vocabulary_count'));
|
||||
return $('#total-num').text(parseInt(sessionStorage.getItem('radical_count')) + parseInt(sessionStorage.getItem('kanji_count')) + parseInt(sessionStorage.getItem('vocabulary_count')));
|
||||
};
|
||||
|
||||
filterQuestions = function() {
|
||||
@ -56,7 +57,7 @@
|
||||
sessionStorage.removeItem('radical_count');
|
||||
sessionStorage.removeItem('kanji_count');
|
||||
sessionStorage.removeItem('vocabulary_count');
|
||||
target_url = "/user_items/" + input_data;
|
||||
target_url = "/user_items?level_range=" + input_data;
|
||||
return $.ajax({
|
||||
url: target_url,
|
||||
dataType: 'json',
|
||||
|
@ -38,6 +38,7 @@
|
||||
<li><span id="radical-num"></span> Radicals</li>
|
||||
<li><span id="kanji-num"></span> Kanji</li>
|
||||
<li><span id="vocab-num"></span> Vocabulary</li>
|
||||
<li><span id="total-num"></span> Total</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li id="api-refresh" class="navbar-text" data-toggle="tooltip" data-placement="bottom" title="Last API Refresh: {{ current_user.last_updated|datetime_format }}. Click to refresh."><span><img alt="avatar" src="http://www.gravatar.com/avatar/{{ current_user.gravatar }}?s=24"></span> {{ current_user.username }}</li>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import json, re
|
||||
from flask import Flask, render_template, redirect, url_for, jsonify, flash
|
||||
from flask import Flask, render_template, redirect, url_for, jsonify, flash, request
|
||||
from flask.ext.login import LoginManager, login_user, login_required, current_user, logout_user, login_fresh
|
||||
from flask.ext.sqlalchemy import SQLAlchemy
|
||||
from flask.ext.wtf import Form
|
||||
@ -181,13 +181,10 @@ def show_quiz():
|
||||
@app.route('/user_items')
|
||||
@login_required
|
||||
def get_items():
|
||||
return get_items_with_level_restriction(list(range(0, 61)))
|
||||
|
||||
|
||||
@app.route('/user_items/<level_range>')
|
||||
@login_required
|
||||
def get_items_with_range(level_range):
|
||||
return get_items_with_level_restriction(parse_range(level_range))
|
||||
level_range = list(range(0, 61))
|
||||
if request.args.get('level_range'):
|
||||
level_range = parse_range(request.args.get('level_range'))
|
||||
return get_items_with_level_restriction(level_range)
|
||||
|
||||
|
||||
@app.route('/refresh', methods=['POST'])
|
||||
|
Loading…
Reference in New Issue
Block a user