diff options
| author | luccioman <luccioman@users.noreply.github.com> | 2019-02-28 22:56:49 +0100 |
|---|---|---|
| committer | luccioman <luccioman@users.noreply.github.com> | 2019-02-28 22:56:49 +0100 |
| commit | 6e9d5f60ad5455decaa8972efaa64c662606e5f0 (patch) | |
| tree | 93d1ed59e5c89ee1da5e2045ee1385d286268bee /htroot/js | |
| parent | 4b9cc4746db12e71e14ae237abee273d4cbfef53 (diff) | |
Server side initial pagination links rendering
For better support of the search page usage with JavaScript disabled.
Reduces also the number of initial refreshes of the paginations links.
When JavaScript is enabled, pagination links are still regularly
refreshed until all the search feeds are terminated on server side.
Diffstat (limited to 'htroot/js')
| -rw-r--r-- | htroot/js/yacysearch.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/htroot/js/yacysearch.js b/htroot/js/yacysearch.js index 09305031d..dc9a19868 100644 --- a/htroot/js/yacysearch.js +++ b/htroot/js/yacysearch.js @@ -62,7 +62,8 @@ function renderPaginationButtons(buttonsList, offset, itemsperpage, totalcount, var firstPage = thispage - (thispage % 10); var prevPageElement = buttons[0]; - var prevPageLink = prevPageElement.firstChild; + var links = prevPageElement.getElementsByTagName("a"); + var prevPageLink = links.length == 1 ? links[0] : null; if (thispage == 0) { /* First page : the prev page button is disabled */ prevPageElement.className = "disabled"; @@ -83,14 +84,12 @@ function renderPaginationButtons(buttonsList, offset, itemsperpage, totalcount, } } - var nextPageElement = buttons[buttons.length - 1]; - var totalPagesNb = Math.floor(1 + ((totalcount - 1) / itemsperpage)); var numberofpages = Math.min(10, totalPagesNb - firstPage); if (!numberofpages) { numberofpages = 10; } - if(numberofpages > 1) { + if(totalPagesNb > 1 && numberofpages >= 1) { buttonsList.className = "pagination"; } else { /* Hide the pagination buttons when there is less than one page of results */ @@ -140,7 +139,9 @@ function renderPaginationButtons(buttonsList, offset, itemsperpage, totalcount, buttonsList.removeChild(buttons[buttons.length - 2]); } - var nextPageLink = nextPageElement.firstChild; + var nextPageElement = buttons[buttons.length - 1]; + links = nextPageElement.getElementsByTagName("a"); + var nextPageLink = links.length == 1 ? links[0] : null; if ((localQuery && thispage >= (totalPagesNb - 1)) || (!localQuery && thispage >= (numberofpages - 1))) { /* Last page on a local query, or last fetchable page in p2p mode : the next page button is disabled */ @@ -181,7 +182,7 @@ function parseFormattedInt(strIntValue) { return intValue; } -function statistics(offset, itemscount, itemsperpage, totalcount, localIndexCount, remoteIndexCount, remotePeerCount, navurlbase, localQuery, feedRunning, jsResort) { +function statistics(offset, itemscount, itemsperpage, totalcount, localIndexCount, remoteIndexCount, remotePeerCount, navurlbase, localQuery, feedRunning, jsResort, updatePagination) { var totalcountIntValue = parseFormattedInt(totalcount); var offsetIntValue = parseFormattedInt(offset); var itemscountIntValue = parseFormattedInt(itemscount); @@ -259,7 +260,7 @@ function statistics(offset, itemscount, itemsperpage, totalcount, localIndexCoun progresseBarElement.setAttribute('style',"width:" + percent + "%"); } var buttonsList = document.getElementById("paginationButtons"); - if (buttonsList != null && !jsResort) { + if (buttonsList != null && !jsResort && updatePagination) { renderPaginationButtons(buttonsList, offsetIntValue, itemsperpageIntValue, totalcountIntValue, navurlbase, localQuery, jsResort); } } |
