Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<!DOCTYPE html>
<head>
<title>Rx for JavaScript Rocks!</title>
<script type="text/javascript">
function throttleInput (element, onNext) {
var delay = function (action) {
return window.setTimeout(function () {
action();
}, 500);
}
, cancelToken
, onkeyup = function (event) {
var content = element.value;
window.clearTimeout(cancelToken);
cancelToken = delay(function () {
if (content === element.value && content.length > 2) {
onNext(content);
}
});
};
element.addEventListener('keyup', onkeyup, false);
}
function initialize () {
var textInput = document.getElementById('textInput');
throttleInput(textInput, function (content) {
var element = document.createElement('li');
element.innerHTML = content;
document.getElementById('results').appendChild(element);
});
}
</script>
</head>
<body style="font-family: Consolas, monospace; overflow: hidden" onload="initialize();">
<input type="text" id="textInput"></input>
<ul id="results"></ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.