0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-24 15:08:22 -05:00
websurfx/public/static/pagination.js

27 lines
723 B
JavaScript

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}`
}
}