File size: 723 Bytes
a912e64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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}`
    }
}