Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michał Woźniak
covid
Commits
374fd0cd
Commit
374fd0cd
authored
Apr 21, 2020
by
Michał Woźniak
Browse files
working on sanity in processing the url hash (and adding settings-in-hash functionality)
parent
18af46f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
covid.js
View file @
374fd0cd
...
...
@@ -1714,14 +1714,17 @@ let processUrlHash = (hash) => {
hash
=
hash
.
substr
(
1
)
}
// ";" is used as a separator of options and sites
// with sites coming last
sites_hash
=
hash
.
split
(
'
;
'
)
sites_hash
=
sites_hash
[
sites_hash
.
length
-
1
]
// with sites coming last and settings being optional
hash
=
hash
.
split
(
'
;
'
)
sites_hash
=
hash
[
sites_hash
.
length
-
1
]
if
(
hash
.
length
>
1
)
{
settings_hash
=
hash
[
0
]
}
// return the data
return
{
sites
:
getSitesFromUrlString
(
sites_hash
),
settings
:
{}
settings
:
settings_hash
.
split
(
'
,
'
)
}
}
...
...
@@ -2097,22 +2100,22 @@ document.addEventListener('DOMContentLoaded', (e)=>{
console
.
log
(
` got hash:
${
window
.
location
.
hash
}
`
)
// get the actual site names from the URL hash (sans '#')
hash
_sites
=
processUrlHash
(
window
.
location
.
hash
)
.
sites
var
hash
=
processUrlHash
(
window
.
location
.
hash
)
// any site data containers to be removed?
if
(
sitesSelects
.
length
-
hash
_
sites
.
length
>
0
)
{
console
.
log
(
` +-- removing
${
sitesSelects
.
length
-
hash
_
sites
.
length
}
sites...`
)
if
(
sitesSelects
.
length
-
hash
.
sites
.
length
>
0
)
{
console
.
log
(
` +-- removing
${
sitesSelects
.
length
-
hash
.
sites
.
length
}
sites...`
)
var
cur_site_count
=
sitesSelects
.
length
for
(
var
i
=
hash
_
sites
.
length
;
i
<
cur_site_count
;
i
++
)
{
for
(
var
i
=
hash
.
sites
.
length
;
i
<
cur_site_count
;
i
++
)
{
console
.
log
(
` i:
${
i
}
`
)
removeSite
.
dispatchEvent
(
new
Event
(
'
click
'
))
}
}
// do we have any sites to work with?
if
(
hash
_
sites
.
length
>
0
)
{
if
(
hash
.
sites
.
length
>
0
)
{
// handle each hash site separately, adding site data containers if need be
hash
_
sites
.
forEach
((
hash_site
,
index
)
=>
{
hash
.
sites
.
forEach
((
hash_site
,
index
)
=>
{
// we only allow 6 sites
if
(
index
<
6
)
{
if
(
(
index
>=
sitesSelects
.
length
)
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment