Auto-emit keyup on first run

This commit is contained in:
Mahdi Dibaiee 2015-07-26 14:33:23 +04:30
parent c459136de8
commit 63a70a4e94
4 changed files with 24 additions and 8 deletions

View File

@ -39,7 +39,7 @@ for (var category in data) {
var input = document.querySelector('input');
var results = document.querySelector('#results');
input.addEventListener('keyup', function () {
function keyup() {
results.innerHTML = '';
var nodes = trie.find(input.value);
@ -72,4 +72,8 @@ input.addEventListener('keyup', function () {
}
}
}
});
}
input.addEventListener('keyup', keyup);
keyup();

View File

@ -51,7 +51,7 @@ input.addEventListener('keydown', function (e) {
}
});
input.addEventListener('keyup', function () {
function keyup() {
results.innerHTML = '';
var nodes = trie.findWords(input.value);
@ -84,4 +84,8 @@ input.addEventListener('keyup', function () {
}
}
}
});
}
input.addEventListener('keyup', keyup);
keyup();

View File

@ -20,7 +20,7 @@ for (let category in data) {
const input = document.querySelector('input');
const results = document.querySelector('#results');
input.addEventListener('keyup', () => {
function keyup() {
results.innerHTML = '';
const nodes = trie.find(input.value);
@ -32,4 +32,8 @@ input.addEventListener('keyup', () => {
results.innerHTML += `<li>${node.name} ${category}</li>`;
}
});
}
input.addEventListener('keyup', keyup);
keyup();

View File

@ -32,7 +32,7 @@ input.addEventListener('keydown', e => {
}
});
input.addEventListener('keyup', () => {
function keyup() {
results.innerHTML = '';
const nodes = trie.findWords(input.value);
@ -44,4 +44,8 @@ input.addEventListener('keyup', () => {
results.innerHTML += `<li>${node.name} ${category}</li>`;
}
});
}
input.addEventListener('keyup', keyup);
keyup();