From 6a9a25dfdf015fb7ea8a7908d8045c8645c74b98 Mon Sep 17 00:00:00 2001 From: Severyn Kozak Date: Sun, 11 May 2014 11:04:53 -0400 Subject: [PATCH] Add js/, index.js with working typing detection. Add: static/js/ -Add directory for all `javascript` files. static/js/index.js -Add functional search-bar typing-begin and typing-end detection. -Currently logs an appropriate message to the console in either state. --- static/js/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 static/js/index.js diff --git a/static/js/index.js b/static/js/index.js new file mode 100644 index 0000000..5ab4c97 --- /dev/null +++ b/static/js/index.js @@ -0,0 +1,16 @@ +var typingTimer; +var finishedTypingInterval = 650; + +searchBar = document.querySelectorAll("form#search-bar input[type='text']")[0] +console.log(searchBar) + +searchBar.onkeyup = function(){ + clearTimeout(typingTimer); + if(searchBar.value){ + typingTimer = setTimeout(finishedTyping, doneTypingInterval); + } +}; + +function finishedTyping(){ + console.log("You stopped typing."); +}