add previous and next button to navigate to different pages
This commit is contained in:
parent
664fba2449
commit
a912e64f6d
3 changed files with 64 additions and 13 deletions
26
public/static/pagination.js
Normal file
26
public/static/pagination.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
function navigate_forward() {
|
||||
const url = new URL(window.location)
|
||||
const searchParams = url.searchParams
|
||||
|
||||
let q = searchParams.get('q')
|
||||
let page = searchParams.get('page')
|
||||
|
||||
if (page === null) {
|
||||
page = 2
|
||||
window.location = `${url.origin}${url.pathname}?q=${q}&page=${page}`
|
||||
} else {
|
||||
window.location = `${url.origin}${url.pathname}?q=${q}&page=${++page}`
|
||||
}
|
||||
}
|
||||
|
||||
function navigate_backward() {
|
||||
const url = new URL(window.location)
|
||||
const searchParams = url.searchParams
|
||||
|
||||
let q = searchParams.get('q')
|
||||
let page = searchParams.get('page')
|
||||
|
||||
if (page !== null && page > 1) {
|
||||
window.location = `${url.origin}${url.pathname}?q=${q}&page=${--page}`
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue