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

working on sanity in processing the url hash (and adding settings-in-hash functionality)

parent 18af46f2
...@@ -1714,14 +1714,17 @@ let processUrlHash = (hash) => { ...@@ -1714,14 +1714,17 @@ let processUrlHash = (hash) => {
hash = hash.substr(1) hash = hash.substr(1)
} }
// ";" is used as a separator of options and sites // ";" is used as a separator of options and sites
// with sites coming last // with sites coming last and settings being optional
sites_hash = hash.split(';') hash = hash.split(';')
sites_hash = sites_hash[sites_hash.length-1] sites_hash = hash[sites_hash.length-1]
if (hash.length > 1) {
settings_hash = hash[0]
}
// return the data // return the data
return { return {
sites: getSitesFromUrlString(sites_hash), sites: getSitesFromUrlString(sites_hash),
settings: {} settings: settings_hash.split(',')
} }
} }
...@@ -2097,22 +2100,22 @@ document.addEventListener('DOMContentLoaded', (e)=>{ ...@@ -2097,22 +2100,22 @@ document.addEventListener('DOMContentLoaded', (e)=>{
console.log(` got hash: ${window.location.hash}`) console.log(` got hash: ${window.location.hash}`)
// get the actual site names from the URL hash (sans '#') // 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? // 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...`)
var cur_site_count = sitesSelects.length 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}`) console.log(` i: ${i}`)
removeSite.dispatchEvent(new Event('click')) removeSite.dispatchEvent(new Event('click'))
} }
} }
// do we have any sites to work with? // 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 // 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 // we only allow 6 sites
if ( index < 6 ) { if ( index < 6 ) {
if ( ( index >= sitesSelects.length ) ) { if ( ( index >= sitesSelects.length ) ) {
......
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