Implement search logic

This commit is contained in:
nietonfir 2017-05-25 22:56:33 +02:00
parent ea951c0e51
commit 408b8e119a

View File

@ -424,9 +424,22 @@
{% capture allIconNames %}{{ allIconNames }}"{{ iconArray[1] }}"{% unless forloop.last %},{% endunless %}{% endcapture %}
{% endfor %}
<script type="text/javascript">
(function() {
var icons = [{{ allIconNames }}];
})();
(function(document) {
var icons = [{{ allIconNames }}],
$icons = document.querySelectorAll('.grid > .grid-item:not(.grid-item--ad)');
function search(value) {
value = value.toLowerCase();
icons.forEach(function(e, i) {
if (e.indexOf(value) > -1) {
$icons[i].classList.remove('hidden');
} else {
$icons[i].classList.add('hidden');
}
})
};
})( document );
</script>
</body>
</html>