diff index.html @ 4:cc0a5142a56f

Now without lodash
author nanaya <me@myconan.net>
date Sun, 15 Jan 2017 19:22:39 +0900
parents 6875be47fb24
children 461c6e7dea56
line wrap: on
line diff
--- a/index.html	Sun Jan 15 19:17:27 2017 +0900
+++ b/index.html	Sun Jan 15 19:22:39 2017 +0900
@@ -80,13 +80,18 @@
     </div>
 
     <script src="qrcode.min.js"></script>
-    <script src="lodash.min.js"></script>
 
     <script>
         var inputDom = document.getElementsByClassName("js-qr-input")[0]
         var outputDom = document.getElementsByClassName("js-qr-output")[0]
         var qr = new QRCode(outputDom)
 
+        var runTimeout = null
+        var debouncedRefreshCode = function() {
+            clearTimeout(runTimeout)
+            runTimeout = setTimeout(refreshCode, 100)
+        }
+
         var refreshCode = function() {
             var text = inputDom.value
 
@@ -98,7 +103,7 @@
             }
         }
 
-        inputDom.addEventListener('input', _.debounce(refreshCode, 100))
+        inputDom.addEventListener('input', debouncedRefreshCode)
         refreshCode()
     </script>
 </body>