barcode.js integration
This commit is contained in:
parent
c5f138a36c
commit
38e91a20b5
4 changed files with 51 additions and 1 deletions
|
@ -117,6 +117,7 @@ instance Yesod App where
|
||||||
])
|
])
|
||||||
$(combineScripts 'StaticR
|
$(combineScripts 'StaticR
|
||||||
[ js_crementing_js
|
[ js_crementing_js
|
||||||
|
, js_barcode_js
|
||||||
])
|
])
|
||||||
$(widgetFile "default-layout")
|
$(widgetFile "default-layout")
|
||||||
withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")
|
withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")
|
||||||
|
|
|
@ -239,3 +239,27 @@ input[type] {
|
||||||
color: black;}
|
color: black;}
|
||||||
100% {-moz-transform: translate(1px, -2px) rotate(-1deg);}
|
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;
|
||||||
|
}
|
22
static/js/barcode.js
Normal file
22
static/js/barcode.js
Normal file
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,7 +22,10 @@ $newline never
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.documentElement.className = document.documentElement.className.replace(/\bno-js\b/,'js');
|
document.documentElement.className = document.documentElement.className.replace(/\bno-js\b/,'js');
|
||||||
<body>
|
<body onkeypress="barcodeKeyPress(event)">
|
||||||
|
<aside #barcode>
|
||||||
|
<p #barcodeContent>
|
||||||
|
|
||||||
^{pageBody pc}
|
^{pageBody pc}
|
||||||
|
|
||||||
$maybe analytics <- appAnalytics $ appSettings master
|
$maybe analytics <- appAnalytics $ appSettings master
|
||||||
|
|
Loading…
Reference in a new issue