Commit c72a877c authored by Michał Woźniak's avatar Michał Woźniak
Browse files

settings-in-url now work

parent 6431fb7d
...@@ -1741,7 +1741,7 @@ let updateUrlHash = () => { ...@@ -1741,7 +1741,7 @@ let updateUrlHash = () => {
selected_sites.push(sselect.value.toLowerCase().replace(/[^a-z0-9]/g, '-')) selected_sites.push(sselect.value.toLowerCase().replace(/[^a-z0-9]/g, '-'))
} }
// set the radio button groups to their defaults // get radio boxes settings
var selected_settings = [] var selected_settings = []
document document
.querySelectorAll('.chart-config-container input[type=radio]') .querySelectorAll('.chart-config-container input[type=radio]')
...@@ -1751,7 +1751,7 @@ let updateUrlHash = () => { ...@@ -1751,7 +1751,7 @@ let updateUrlHash = () => {
selected_settings.push(r.id.split('-').slice(-1)[0]) selected_settings.push(r.id.split('-').slice(-1)[0])
} }
}) })
// and all other inputs to their default values // and all other inputs too
document document
.querySelectorAll('.chart-config-container input:not([type=radio])') .querySelectorAll('.chart-config-container input:not([type=radio])')
.forEach((r)=>{ .forEach((r)=>{
...@@ -2104,7 +2104,9 @@ document.addEventListener('DOMContentLoaded', (e)=>{ ...@@ -2104,7 +2104,9 @@ document.addEventListener('DOMContentLoaded', (e)=>{
// get the actual site names from the URL hash (sans '#') // get the actual site names from the URL hash (sans '#')
var hash = processUrlHash(window.location.hash) var hash = processUrlHash(window.location.hash)
// handle settings // set settings
var handled_setting_groups = []
// handle settings from hash
hash.settings.forEach((setting)=>{ hash.settings.forEach((setting)=>{
// do we have anything to work with? // do we have anything to work with?
if (setting === '') { if (setting === '') {
...@@ -2113,7 +2115,7 @@ document.addEventListener('DOMContentLoaded', (e)=>{ ...@@ -2113,7 +2115,7 @@ document.addEventListener('DOMContentLoaded', (e)=>{
// perhaps it' a "valued" setting? // perhaps it' a "valued" setting?
setting = setting.split(':') setting = setting.split(':')
// get the node // 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 so, use .value
if (setting.length > 1) { if (setting.length > 1) {
node.value = setting[1] node.value = setting[1]
...@@ -2121,8 +2123,20 @@ document.addEventListener('DOMContentLoaded', (e)=>{ ...@@ -2121,8 +2123,20 @@ document.addEventListener('DOMContentLoaded', (e)=>{
} else { } else {
node.checked = true 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? // any site data containers to be removed?
if (sitesSelects.length - hash.sites.length > 0) { if (sitesSelects.length - hash.sites.length > 0) {
console.log(` +-- removing ${sitesSelects.length - hash.sites.length} sites...`) console.log(` +-- removing ${sitesSelects.length - hash.sites.length} sites...`)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment