pass node as parameter for search function (searchbar is child of nav)

This commit is contained in:
David Wu
2017-12-20 02:20:42 +01:00
parent 9bbf54aabc
commit 9f81f085ce

View File

@ -23,7 +23,7 @@
<link rel="stylesheet" href="prism.css">
</head>
<script>
const search = (input) => Array.from(node.parentElement.getElementsByTagName('a')).forEach(x =>x.style.display = x.getAttribute("href").toUpperCase().indexOf(query) + 1 ? '' : 'none');
const search = (node) => Array.from(node.parentElement.getElementsByTagName('a')).forEach(x =>x.style.display = x.getAttribute("href").toUpperCase().indexOf(node.value.toUpperCase()) + 1 ? '' : 'none');
</script>
<body>
<header style="height: 5.5rem;">
@ -35,6 +35,6 @@
<div class="row" style="height: calc(100vh - 5.875rem);overflow: hidden;">
<input id="doc-drawer-checkbox" class="drawer" value="on" type="checkbox">
<nav id="snippetListDrawer" class="col-md-4 col-lg-3" style="border-top: 0">
<input type="text" id="searchInput" onkeyup="search()" placeholder="Search for snippet..">
<input type="text" id="searchInput" onkeyup="search(this)" placeholder="Search for snippet..">
<label for="doc-drawer-checkbox" class="button drawer-close"></label>
<!-- <div><input style="width: 100%; margin: 0px;" placeholder="Search..." id="search-bar" oninput="search()" type="search"></div> -->