Skip to content

Commit

Permalink
+ Page lists (1 2 ... 7 8) will now expand on both side of the suspen…
Browse files Browse the repository at this point in the history
…sion point, rather than just its left. This is MUCH more practical when navigating through hundreds of pages. Also reduced the number of entries to 20 per side (40 overall) instead of 50 overall, because 40 is already more than enough. (script.js)

+ Added strict mode to the main script file. I've been using that for years on Lestrades.com for years, and standards-oriented people like it anyway. It's just a few bytes. (script.js)
  • Loading branch information
Nao committed May 11, 2019
1 parent b3396c7 commit 9de5de8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/javascript/script.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@


@language index; @language index;


'use strict';

var var
oThought, oThought,
weEditors = [], weEditors = [],
Expand Down Expand Up @@ -272,10 +274,10 @@ function breakLinks(where)
// Shows the page numbers by clicking the dots. // Shows the page numbers by clicking the dots.
function expandPages(spanNode, firstPage, lastPage, perPage) function expandPages(spanNode, firstPage, lastPage, perPage)
{ {
var i = firstPage, pageLimit = 50, baseURL = $(spanNode).data('href'); var i = firstPage, pageLimit = 20, baseURL = $(spanNode).data('href');


// Prevent too many pages from being loaded at once. // Prevent too many pages from being loaded at once.
if ((lastPage - firstPage) / perPage > pageLimit) if ((lastPage - firstPage) / perPage > pageLimit * 2)
{ {
var oldLastPage = lastPage; var oldLastPage = lastPage;
lastPage = firstPage + perPage * pageLimit; lastPage = firstPage + perPage * pageLimit;
Expand All @@ -286,7 +288,11 @@ function expandPages(spanNode, firstPage, lastPage, perPage)
$(spanNode).before('<a href="' + baseURL.replace(/%1\$d/, i).replace(/%%/g, '%') + '">' + (1 + i / perPage) + '</a> '); $(spanNode).before('<a href="' + baseURL.replace(/%1\$d/, i).replace(/%%/g, '%') + '">' + (1 + i / perPage) + '</a> ');


if (oldLastPage) if (oldLastPage)
$(spanNode).off().click(function () { expandPages(this, lastPage, oldLastPage, perPage); }); {
for (i = oldLastPage - perPage; i > oldLastPage - perPage * pageLimit; i -= perPage)
$(spanNode).after(' <a href="' + baseURL.replace(/%1\$d/, i).replace(/%%/g, '%') + '">' + (1 + i / perPage) + '</a>');
$(spanNode).off().click(function () { expandPages(this, lastPage, oldLastPage - perPage * pageLimit, perPage); });
}
else else
$(spanNode).remove(); $(spanNode).remove();
} }
Expand Down

0 comments on commit 9de5de8

Please sign in to comment.