Fix walker number url detection for n = 0
This commit is contained in:
		
							parent
							
								
									53540ccb77
								
							
						
					
					
						commit
						dcdf2e7c55
					
				
							
								
								
									
										12
									
								
								walkers.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								walkers.js
									
									
									
									
									
								
							| @ -95,11 +95,15 @@ 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
 | ||||
|   // read url params to see how many we should create, default to num colors.
 | ||||
|   // special case is because 0 == null and my brain doesn't wanna work good
 | ||||
|   var n_create; | ||||
|   const urlParams = new URLSearchParams(window.location.search); | ||||
|   console.log(urlParams.get('n')); | ||||
|   const n_create = Number(urlParams.get('n')) || walker_colors.length; | ||||
|   if (urlParams.has('n', "0")) { | ||||
|     n_create = 0; | ||||
|   } else { | ||||
|     n_create = Number(urlParams.get('n')) || walker_colors.length; | ||||
|   } | ||||
| 
 | ||||
|   // create initial walkers of every color
 | ||||
|   for (var i = 0; i < n_create; i++) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user