Accept URL parameters for hiding and number of walkers

This commit is contained in:
shoe 2025-03-22 06:11:54 +00:00
parent e42ec34ce2
commit 53540ccb77
2 changed files with 17 additions and 1 deletions

View File

@ -16,9 +16,11 @@ function hide_actually_everything() {
hidden.style.display = 'none';
}
// get the elements we need to hide
var shown = document.getElementById("page-content");
var hidden = document.getElementById("page-content-hidden");
// assign functions to buttons
document
.getElementById("button-hide-page")
.addEventListener("click", hide_page);
@ -28,3 +30,10 @@ document
document
.getElementById("button-hide-everything")
.addEventListener("click", hide_actually_everything);
// check URL params and see if we should hideall
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('hideall')) {
hide_page();
hide_actually_everything();
}

View File

@ -95,8 +95,14 @@ function random_update_time() {
function init_walk() {
setInterval(update_trails, 200);
// read URL parameters to see if we should create a default number,
// otherwise default to walker_colors.length
const urlParams = new URLSearchParams(window.location.search);
console.log(urlParams.get('n'));
const n_create = Number(urlParams.get('n')) || walker_colors.length;
// create initial walkers of every color
for (var i = 0; i < walker_colors.length; i++) {
for (var i = 0; i < n_create; i++) {
create_random_walker();
}
}
@ -260,3 +266,4 @@ var walkers = [];
var walker_timers = [];
var trails = []
init_walk();