Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
cf8cf399
Commit
cf8cf399
authored
May 25, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
May 25, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate pagination module to TS
parent
7c88890f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
pagination.ts
src/sidebar/util/pagination.ts
+11
-11
No files found.
src/sidebar/util/pagination.
j
s
→
src/sidebar/util/pagination.
t
s
View file @
cf8cf399
/**
/**
* The number of an available pagination page, or `null`, indicating a gap
* The number of an available pagination page, or `null`, indicating a gap
* between sequential numbered pages.
* between sequential numbered pages.
*
* @typedef {number|null} PageNumber
*/
*/
type
PageNumber
=
number
|
null
;
/**
/**
* Determine the set of (pagination) page numbers that should be provided to
* Determine the set of (pagination) page numbers that should be provided to
...
@@ -22,16 +21,17 @@
...
@@ -22,16 +21,17 @@
* pageNumberOptions(9, 10, 5) => [1, null, 7, 8, 9, 10]
* pageNumberOptions(9, 10, 5) => [1, null, 7, 8, 9, 10]
* pageNumberOptions(2, 3, 5) => [1, 2, 3]
* pageNumberOptions(2, 3, 5) => [1, 2, 3]
*
*
* @param
{number}
currentPage - The currently-visible/-active page of results.
* @param currentPage - The currently-visible/-active page of results.
* Note that pages are 1-indexed
* Note that pages are 1-indexed
* @param {number} totalPages
* @param maxPages - The maximum number of numbered pages to make available
* @param {number} [maxPages] - The maximum number of numbered pages to make
* @return Set of navigation page options to show. `null` values represent gaps
* available
* in the sequence of pages, to be represented later as ellipses (...)
* @return {PageNumber[]} Set of navigation page options to show. `null`
* values represent gaps in the sequence of pages, to be represented later
* as ellipses (...)
*/
*/
export
function
pageNumberOptions
(
currentPage
,
totalPages
,
maxPages
=
5
)
{
export
function
pageNumberOptions
(
currentPage
:
number
,
totalPages
:
number
,
maxPages
=
5
):
PageNumber
[]
{
if
(
totalPages
<=
1
)
{
if
(
totalPages
<=
1
)
{
return
[];
return
[];
}
}
...
@@ -53,7 +53,7 @@ export function pageNumberOptions(currentPage, totalPages, maxPages = 5) {
...
@@ -53,7 +53,7 @@ export function pageNumberOptions(currentPage, totalPages, maxPages = 5) {
++
increment
;
++
increment
;
}
}
const
pageOptions
=
/** @type {PageNumber[]} */
([])
;
const
pageOptions
:
PageNumber
[]
=
[]
;
// Construct a numerically-sorted array with `null` entries inserted
// Construct a numerically-sorted array with `null` entries inserted
// between non-sequential entries
// between non-sequential entries
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment