(define browse (object dom (object selectable-tags null tag-groups null sections null) tag-filter-keypress (l (event) (let* ( (input event.target) (no-results (_.foldl browse.dom.tag-groups (l (result a index) (let* ((no-results #t)) (_.each a (l (a) (if (a.innerHTML.includes input.value) (begin (set a.style.display "inline") (set no-results #f)) (set a.style.display "none")))) (set (get (get browse.dom.sections index) "style" "display") (if* no-results "none" "block")) (and result no-results))) #t))) (set input.className (if* input.value (if* no-results "active no-results" "active") "")) #t)) init (l () (set browse.dom.selectable-tags (get (document.getElementsByClassName "selectable-tags") 0) browse.dom.sections (browse.dom.selectable-tags.querySelectorAll "section") browse.dom.tag-groups (_.map browse.dom.sections (l (a) (a.getElementsByTagName "a")))) (let* ((body (get (document.getElementsByTagName "body") 0))) (if (body.classList.contains "c-browse-all") (let* ( (middle (get (document.getElementsByClassName "middle") 0)) (input (crel "input")) (section (crel "section" (object class "tag-filter") (crel "h1" "tag filter") (crel "div" input)))) (input.addEventListener "input" browse.tag-filter-keypress) (middle.insertBefore section middle.firstChild))))))) (browse.init)