Published
Edited
Jun 6, 2021
Insert cell
Insert cell
radiusRange = [10,20]
Insert cell
patternCount = urlVariables.seed
Insert cell
md`construct the url:`
Insert cell
md `If there is no prams then these should be set

If localion.hash = "" then use hashPath to build urlVariables`
Insert cell
ok = {
if ( location.hash == "" ) {
// config the default prams from hashPath
return hashPath }
}
Insert cell
hashPath = `#seed=${seed}&patternCount=${patternCount}&radiusRangeMin=${radiusRange[0]}&radiusRangeMax=${radiusRange[1]}`
Insert cell
md`Convert URL parameters into variable object`
Insert cell
urlVariables = {
let vars = hash.slice(1).split("&");
let vals = {};
vars.forEach(d => {
let pair = d.split("=");
vals[pair[0]] = +pair[1];
});
return vals;
}
Insert cell
seed = urlVariables["seed"] || 42
Insert cell
hash = Generators.observe(notify => {
const hashchange = () => notify(location.hash);
hashchange();
addEventListener("hashchange", hashchange);
return () => removeEventListener("hashchange", hashchange);
})
Insert cell
//location
// location.href //returns the href (URL) of the current page
// location.hostname //returns the domain name of the web host
location.pathname //returns the path and filename of the current page
// location.protocol //returns the web protocol used (http: or https:)
//location.assign() //loads a new document


Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more