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
c72a877c
Commit
c72a877c
authored
Apr 23, 2020
by
Michał Woźniak
Browse files
settings-in-url now work
parent
6431fb7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
covid.js
View file @
c72a877c
...
...
@@ -1741,7 +1741,7 @@ let updateUrlHash = () => {
selected_sites
.
push
(
sselect
.
value
.
toLowerCase
().
replace
(
/
[^
a-z0-9
]
/g
,
'
-
'
))
}
//
s
et
the
radio b
utton groups to their default
s
//
g
et radio b
oxes setting
s
var
selected_settings
=
[]
document
.
querySelectorAll
(
'
.chart-config-container input[type=radio]
'
)
...
...
@@ -1751,7 +1751,7 @@ let updateUrlHash = () => {
selected_settings
.
push
(
r
.
id
.
split
(
'
-
'
).
slice
(
-
1
)[
0
])
}
})
// and all other inputs to
their default values
// and all other inputs to
o
document
.
querySelectorAll
(
'
.chart-config-container input:not([type=radio])
'
)
.
forEach
((
r
)
=>
{
...
...
@@ -2104,7 +2104,9 @@ document.addEventListener('DOMContentLoaded', (e)=>{
// get the actual site names from the URL hash (sans '#')
var
hash
=
processUrlHash
(
window
.
location
.
hash
)
// handle settings
// set settings
var
handled_setting_groups
=
[]
// handle settings from hash
hash
.
settings
.
forEach
((
setting
)
=>
{
// do we have anything to work with?
if
(
setting
===
''
)
{
...
...
@@ -2113,7 +2115,7 @@ document.addEventListener('DOMContentLoaded', (e)=>{
// perhaps it' a "valued" setting?
setting
=
setting
.
split
(
'
:
'
)
// get the node
node
=
document
.
querySelector
(
`.chart-config-container input[id$=
${
setting
[
0
]}
]`
)
var
node
=
document
.
querySelector
(
`.chart-config-container input[id$=
${
setting
[
0
]}
]`
)
// if so, use .value
if
(
setting
.
length
>
1
)
{
node
.
value
=
setting
[
1
]
...
...
@@ -2121,8 +2123,20 @@ document.addEventListener('DOMContentLoaded', (e)=>{
}
else
{
node
.
checked
=
true
}
// remove the node from consideration
handled_setting_groups
.
push
(
node
.
name
)
})
// set all other settings to defaults
document
.
querySelectorAll
(
'
.chart-config-container input
'
)
.
forEach
((
node
)
=>
{
if
(
(
node
.
name
!=
""
)
&&
!
handled_setting_groups
.
includes
(
node
.
name
)
)
{
node
.
value
=
node
.
defaultValue
node
.
checked
=
node
.
defaultChecked
}
})
// any site data containers to be removed?
if
(
sitesSelects
.
length
-
hash
.
sites
.
length
>
0
)
{
console
.
log
(
` +-- removing
${
sitesSelects
.
length
-
hash
.
sites
.
length
}
sites...`
)
...
...
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