www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

TODO (900B)


      1 # Options filtered by text
      2 
      3 1. Figure out how to position the options so that they (A) don't
      4    alter the document-flow, (B) stay right below the filtering text
      5    input, and (C), disappear when input is not focused.
      6 
      7    The selection is fairly easy, here's what I had written before
      8    realizing that positioning the list would proove difficult:
      9 
     10 	enumSelection(enums, input) {
     11 		let enums = document.createElement("ul")
     12 		enums.classList.add("enums")
     13 		input.after(enums)
     14 
     15 		function showEnums(values) {
     16 			let items = []
     17 			for (let i in values) {
     18 				let item = document.createElement("li")
     19 				item.appendChild(document.createTextNode(values[i]))
     20 				items.push(item)
     21 			}
     22 			enums.replaceChildren(...items)
     23 		}
     24 
     25 		showEnums(values)
     26 		input.addEventListener("input", function(ev) {
     27 			showEnums(values.filter(function(item) {
     28 				return item.includes(input.value)
     29 			}))
     30 		})
     31 
     32 		return input
     33 	}