mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 11:20:30 +00:00
Scroll into view on enter keypress in search bar
This commit is contained in:
parent
c6e85d5cc0
commit
8d9c46bedc
1 changed files with 9 additions and 2 deletions
11
third_party/chibicc/dox2.c
vendored
11
third_party/chibicc/dox2.c
vendored
|
@ -716,11 +716,18 @@ document.addEventListener('DOMContentLoaded', function () {\n\
|
||||||
option.setAttribute('value', el.id)\n\
|
option.setAttribute('value', el.id)\n\
|
||||||
datalist.appendChild(option)\n\
|
datalist.appendChild(option)\n\
|
||||||
})\n\
|
})\n\
|
||||||
document.getElementById('search').addEventListener('change', function (event) {\n\
|
function scrollIntoView(event) {\n\
|
||||||
var value = event.target.value\n\
|
var value = event.target.value\n\
|
||||||
if (document.getElementById(value)) {\n\
|
var el = document.getElementById(value) \n\
|
||||||
|
if (el) {\n\
|
||||||
location.hash = value\n\
|
location.hash = value\n\
|
||||||
|
el.scrollIntoView()\n\
|
||||||
}\n\
|
}\n\
|
||||||
|
}\n\
|
||||||
|
var search = document.getElementById('search')\n\
|
||||||
|
search.addEventListener('change', scrollIntoView)\n\
|
||||||
|
search.addEventListener('keypress', function (event) {\n\
|
||||||
|
if (event.key === 'Enter') scrollIntoView(event)\n\
|
||||||
})\n\
|
})\n\
|
||||||
})\n\
|
})\n\
|
||||||
</script>\n\n");
|
</script>\n\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue