diff --git a/serve.py b/serve.py index 81a4c50..c3373e4 100644 --- a/serve.py +++ b/serve.py @@ -294,8 +294,6 @@ def main(): context['gvars']['search_query'] = opt_q context['gvars']['svm_c'] = str(C) context['gvars']['page_number'] = str(page_number) - context['gvars']['prev_page_number'] = str(page_number - 1) - context['gvars']['next_page_number'] = str(page_number + 1) return render_template('index.html', **context) @app.route('/inspect', methods=['GET']) diff --git a/static/style.css b/static/style.css index 2fbf305..3ac3ff6 100644 --- a/static/style.css +++ b/static/style.css @@ -291,4 +291,7 @@ body { #link-prev-page, #link-next-page { margin: 0 5px 0 5px; font-size: 16px; + cursor: pointer; + color: #009; + text-decoration: underline; } diff --git a/static/word_list.js b/static/word_list.js index 9ba9531..e08e518 100644 --- a/static/word_list.js +++ b/static/word_list.js @@ -26,5 +26,7 @@ const WordList = props => { ) } -ReactDOM.render(, - document.getElementById('wordwrap')); +var elt = document.getElementById('wordwrap'); +if(elt) { + ReactDOM.render(, elt); +} diff --git a/templates/index.html b/templates/index.html index 47b8c53..0c814b7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,47 +7,19 @@ var tags = {{ tags | tojson }}; var words = {{ words | tojson }}; var words_desc = {{ words_desc | tojson }}; var gvars = {{ gvars | tojson }}; + +/* +JS code here handles pagination. I really don't super love this approach, +if anyone can think of a cleaner / shorter way please let me know. +*/ +var move_page = function(int_offset) { + var queryParams = new URLSearchParams(window.location.search); + queryParams.set("page_number", Math.max(1, parseInt(gvars.page_number) + int_offset)); + window.location.href = '/?' + queryParams.toString(); +} {% endblock %} - - {% block content %} {% if not user %} @@ -130,9 +102,9 @@ window.onload = function() { {% endblock %}