diff --git a/Foundation.hs b/Foundation.hs index 8e396dc..eb1eaf7 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -117,6 +117,7 @@ instance Yesod App where ]) $(combineScripts 'StaticR [ js_crementing_js + , js_barcode_js ]) $(widgetFile "default-layout") withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet") diff --git a/static/css/main.css b/static/css/main.css index cab3cfb..d93b491 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -239,3 +239,27 @@ input[type] { color: black;} 100% {-moz-transform: translate(1px, -2px) rotate(-1deg);} } + +#barcode { + display: none; + opacity: 0; +} +#barcode.shown { + z-index: 1000; + display: block; + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + background: black; + color: white; + font-size: 300%; + opacity: 0.9; + display: flex; + align-items: center; + justify-content: center; +} +#barcodeContent { + text-align: center; +} \ No newline at end of file diff --git a/static/js/barcode.js b/static/js/barcode.js new file mode 100644 index 0000000..0ccfea4 --- /dev/null +++ b/static/js/barcode.js @@ -0,0 +1,22 @@ +var barcodeBuf = "" +var barcodeShown = false + +function showBarcode(text) { + if (!barcodeShown) { + document.getElementById('barcode').classList.add('shown') + } + document.getElementById('barcodeContent').textContent = text +} + +function barcodeKeyPress(event) { + var key = String.fromCharCode(event.charCode) + if (event.keyCode === 13) { + // window.location = "" + barcodeBuf + barcodeBuf = "" + event.preventDefault() + } else { + barcodeBuf += key + showBarcode(barcodeBuf) + event.preventDefault() + } +} diff --git a/templates/default-layout-wrapper.hamlet b/templates/default-layout-wrapper.hamlet index a89dd1f..194e776 100644 --- a/templates/default-layout-wrapper.hamlet +++ b/templates/default-layout-wrapper.hamlet @@ -22,7 +22,10 @@ $newline never