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) => {
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 ) ) {
......
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