Mercurial > qr-html
comparison 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 |
comparison
equal
deleted
inserted
replaced
3:6875be47fb24 | 4:cc0a5142a56f |
---|---|
78 <a href="https://bitbucket.org/nanaya1/qr-html">Source</a> | 78 <a href="https://bitbucket.org/nanaya1/qr-html">Source</a> |
79 </div> | 79 </div> |
80 </div> | 80 </div> |
81 | 81 |
82 <script src="qrcode.min.js"></script> | 82 <script src="qrcode.min.js"></script> |
83 <script src="lodash.min.js"></script> | |
84 | 83 |
85 <script> | 84 <script> |
86 var inputDom = document.getElementsByClassName("js-qr-input")[0] | 85 var inputDom = document.getElementsByClassName("js-qr-input")[0] |
87 var outputDom = document.getElementsByClassName("js-qr-output")[0] | 86 var outputDom = document.getElementsByClassName("js-qr-output")[0] |
88 var qr = new QRCode(outputDom) | 87 var qr = new QRCode(outputDom) |
88 | |
89 var runTimeout = null | |
90 var debouncedRefreshCode = function() { | |
91 clearTimeout(runTimeout) | |
92 runTimeout = setTimeout(refreshCode, 100) | |
93 } | |
89 | 94 |
90 var refreshCode = function() { | 95 var refreshCode = function() { |
91 var text = inputDom.value | 96 var text = inputDom.value |
92 | 97 |
93 if (text !== "") { | 98 if (text !== "") { |
96 } else { | 101 } else { |
97 outputDom.classList.add('js-hidden') | 102 outputDom.classList.add('js-hidden') |
98 } | 103 } |
99 } | 104 } |
100 | 105 |
101 inputDom.addEventListener('input', _.debounce(refreshCode, 100)) | 106 inputDom.addEventListener('input', debouncedRefreshCode) |
102 refreshCode() | 107 refreshCode() |
103 </script> | 108 </script> |
104 </body> | 109 </body> |