Skip to content

Commit

Permalink
Merge pull request #6183 from roed314/download_hidden
Browse files Browse the repository at this point in the history
Fix download input at top and bottom of search results
  • Loading branch information
AndrewVSutherland authored Sep 26, 2024
2 parents d052b8b + bc8f50b commit 16aa84e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
12 changes: 6 additions & 6 deletions lmfdb/static/lmfdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ function increase_start_by_count_and_submit_form() {
function get_count_of_results() {
var address = window.location.href;
$("#result-count").html("computing...");
$("#download-msg").html("Computing number of results...");
$("span.download-msg").html("Computing number of results...");
if (address.slice(-1) === "#")
address = address.slice(0,-1);
address += "&result_count=1";
Expand All @@ -365,8 +365,8 @@ function get_count_of_results() {
function get_count_callback(res) {
$('#result-count').html(res['nres']);
$('#result-count2').html(res['nres']);
$("#download-msg").html("");
$("#download-form").show();
$("span.download-msg").html("");
$("span.download-form").show();
};

/**
Expand Down Expand Up @@ -574,7 +574,7 @@ function control_sort(S) {
S.selectedIndex = -1;
};

function update_download_url(link) {
function update_download_url(link, downid) {
// console.log("before modification", link.href);
var newval;
var url = new URL(link.href);
Expand All @@ -588,12 +588,12 @@ function update_download_url(link) {
params.set(keys[i], newval);
}
}
newval = $("input[name=download_row_count]").val();
newval = $("input[name=download_row_count"+downid+"]").val();
console.log("newval", newval);
if (newval.length > 0 && newval != "all") {
params.set("download_row_count", newval);
}
newval = $('#downlang-select').find(":selected").val();
newval = $('#downlang-select'+downid).find(":selected").val();
params.set("Submit", newval);
url.search = params.toString();
link.href = url.href;
Expand Down
17 changes: 10 additions & 7 deletions lmfdb/templates/download_search_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
{% if not languages %}
{% set languages = ['text', 'gp', 'sage', 'magma', 'oscar', 'csv'] %}
{% endif %}
{% if not downid %}
{% set downid = 1 %} {# set externally so that we can distinguish in js between the download spans at the top and bottom of the results #}
{% endif %}

 
{% if info.exact_count %}
<span id="download-form">
<span class="download-form">
{% else %}
<span id="download-msg">
<span class="download-msg">
To download results, <a href="#" title="Get exact count" onclick="get_count_of_results(); return false;">determine the number of results</a>.
</span>
<span id="download-form" style="display:none;">
<span class="download-form" style="display:none;">
{% endif %}
<a class="like-button" href="{{modify_url(query_add='download=1&query='+(info.query|string))}}" onclick="return update_download_url(this);">Download</a>
<a class="like-button" href="{{modify_url(query_add='download=1&query='+(info.query|string))}}" onclick="return update_download_url(this, {{downid}});">Download</a>
{{KNOWL('doc.search_columns', 'displayed columns')}} for
<input id="download_row_count_input" name="download_row_count" type="text" value="{% if info.start == 0%}all{% else %}{{info.start+1}}-{{upper_count}}{% endif %}" /> results
<label for="downlang-select">to</label>
<select name="downlang" id="downlang-select">
<input class="download_row_count_input" name="download_row_count{{downid}}" type="text" value="{% if info.start == 0%}all{% else %}{{info.start+1}}-{{upper_count}}{% endif %}" /> results
<label for="downlang-select{{downid}}">to</label>
<select name="downlang{{downid}}" id="downlang-select{{downid}}">
{% for lang in languages %}
<option value="{{lang}}"{% if lang=='text' %} selected{% endif %}>{{lang_text[lang]}}</option>
{% endfor %}
Expand Down
8 changes: 4 additions & 4 deletions lmfdb/templates/dummy_download_search_results.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# Included so that the javascript functions that deal with updating counts (static/lmfdb.js:get_count_of_results and static/lmfdb.js:get_count_callback) have targets #}
<div id="download-area">
<span id="download-msg" style="display:none;">
<div>
<span class="download-msg" style="display:none;">
</span>
<span class="download-form" style="display:none;">
</span>
<form id="download-form" style="display:none;">
</form>
</div>
1 change: 1 addition & 0 deletions lmfdb/templates/matches.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ <h2 style="display: inline; color: #1565C0; font-weight: bold; font-family: sans
{% endif %}
</h2>
{% include 'forward_back.html' %}
{% set downid = 2 %}
{% include 'download_search_results.html' %}
</div>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion lmfdb/templates/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2114,7 +2114,7 @@ span.activesubgp {
#row_selector_shown {
display: none;
}
#download_row_count_input {
input.download_row_count_input {
width: 75px;
}

Expand Down

0 comments on commit 16aa84e

Please sign in to comment.