mirror of
https://github.com/iptv-org/iptv-org.github.io.git
synced 2025-05-13 02:20:06 -04:00
Update the results after pressing the Back button
This commit is contained in:
parent
59dde05ee9
commit
f22f3cb680
3 changed files with 40 additions and 15 deletions
13
src/store.js
13
src/store.js
|
@ -9,7 +9,6 @@ export const countries = writable({})
|
|||
export const filteredChannels = writable([])
|
||||
|
||||
export function search(_query) {
|
||||
setSearchParam('q', _query)
|
||||
const parts = _query.toLowerCase().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g) || []
|
||||
const filters = []
|
||||
for (let value of parts) {
|
||||
|
@ -180,11 +179,19 @@ function generateSearchable(c) {
|
|||
return searchable
|
||||
}
|
||||
|
||||
function setSearchParam(key, value) {
|
||||
export function setSearchParam(key, value) {
|
||||
if (window.history.pushState) {
|
||||
let query = key && value ? `?${key}=${value}` : ''
|
||||
query = query.replace(/\+/g, '%2B')
|
||||
const url = `${window.location.protocol}//${window.location.host}${window.location.pathname}${query}`
|
||||
window.history.pushState({ path: url }, '', url)
|
||||
const state = {}
|
||||
state[key] = value
|
||||
window.history.pushState(state, '', url)
|
||||
setPageTitle(value)
|
||||
}
|
||||
}
|
||||
|
||||
export function setPageTitle(value) {
|
||||
const title = value ? `${value} · iptv-org` : 'iptv-org'
|
||||
document.title = title
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue