|
|
|
|
|
|
|
|
|
function navigate_forward() { |
|
const url = new URL(window.location); |
|
const searchParams = url.searchParams; |
|
|
|
let q = searchParams.get('q'); |
|
let page = parseInt(searchParams.get('page')); |
|
|
|
if (isNaN(page)) { |
|
page = 1; |
|
} else { |
|
page++; |
|
} |
|
|
|
window.location.href = `${url.origin}${url.pathname}?q=${encodeURIComponent(q)}&page=${page}`; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
function navigate_backward() { |
|
const url = new URL(window.location); |
|
const searchParams = url.searchParams; |
|
|
|
let q = searchParams.get('q'); |
|
let page = parseInt(searchParams.get('page')); |
|
|
|
if (isNaN(page)) { |
|
page = 1; |
|
} else if (page > 1) { |
|
page--; |
|
} |
|
|
|
window.location.href = `${url.origin}${url.pathname}?q=${encodeURIComponent(q)}&page=${page}`; |
|
} |
|
|