2023-06-07 12:37:35 -04:00
|
|
|
/**
|
2023-07-07 10:38:47 -04:00
|
|
|
* Navigates to the next page by incrementing the current page number in the URL query string.
|
2023-06-07 12:37:35 -04:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-05-03 14:31:52 -04:00
|
|
|
function navigate_forward() {
|
2023-06-07 12:37:35 -04:00
|
|
|
const url = new URL(window.location);
|
|
|
|
const searchParams = url.searchParams;
|
2023-05-03 14:31:52 -04:00
|
|
|
|
2023-06-07 12:37:35 -04:00
|
|
|
let q = searchParams.get('q');
|
|
|
|
let page = parseInt(searchParams.get('page'));
|
2023-05-03 14:31:52 -04:00
|
|
|
|
2023-06-07 12:37:35 -04:00
|
|
|
if (isNaN(page)) {
|
|
|
|
page = 1;
|
2023-05-03 14:31:52 -04:00
|
|
|
} else {
|
2023-06-07 12:37:35 -04:00
|
|
|
page++;
|
2023-05-03 14:31:52 -04:00
|
|
|
}
|
2023-06-07 12:37:35 -04:00
|
|
|
|
|
|
|
window.location.href = `${url.origin}${url.pathname}?q=${encodeURIComponent(q)}&page=${page}`;
|
2023-05-03 14:31:52 -04:00
|
|
|
}
|
|
|
|
|
2023-06-07 12:37:35 -04:00
|
|
|
/**
|
2023-07-07 10:38:47 -04:00
|
|
|
* Navigates to the previous page by decrementing the current page number in the URL query string.
|
2023-06-07 12:37:35 -04:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2023-05-03 14:31:52 -04:00
|
|
|
function navigate_backward() {
|
2023-06-07 12:37:35 -04:00
|
|
|
const url = new URL(window.location);
|
|
|
|
const searchParams = url.searchParams;
|
2023-05-03 14:31:52 -04:00
|
|
|
|
2023-06-07 12:37:35 -04:00
|
|
|
let q = searchParams.get('q');
|
|
|
|
let page = parseInt(searchParams.get('page'));
|
2023-05-03 14:31:52 -04:00
|
|
|
|
2023-06-07 12:37:35 -04:00
|
|
|
if (isNaN(page)) {
|
2023-06-29 12:49:38 -04:00
|
|
|
page = 0;
|
|
|
|
} else if (page > 0) {
|
2023-06-07 12:37:35 -04:00
|
|
|
page--;
|
2023-05-03 14:31:52 -04:00
|
|
|
}
|
2023-06-07 12:37:35 -04:00
|
|
|
|
|
|
|
window.location.href = `${url.origin}${url.pathname}?q=${encodeURIComponent(q)}&page=${page}`;
|
2023-05-03 14:31:52 -04:00
|
|
|
}
|