2015-07-18 23:00:54 +00:00
|
|
|
var barcodeBuf = ""
|
|
|
|
var barcodeShown = false
|
|
|
|
|
|
|
|
function showBarcode(text) {
|
|
|
|
if (!barcodeShown) {
|
|
|
|
document.getElementById('barcode').classList.add('shown')
|
2015-07-21 17:18:00 +00:00
|
|
|
barcodeShown = true
|
2015-07-18 23:00:54 +00:00
|
|
|
}
|
|
|
|
document.getElementById('barcodeContent').textContent = text
|
|
|
|
}
|
|
|
|
|
2015-07-21 12:14:47 +00:00
|
|
|
function hideBarcode() {
|
|
|
|
if (barcodeShown) {
|
|
|
|
document.getElementById('barcode').classList.remove('shown')
|
2015-07-21 17:18:00 +00:00
|
|
|
barcodeShown = false
|
2015-07-21 12:14:47 +00:00
|
|
|
}
|
2015-07-21 17:18:00 +00:00
|
|
|
return ""
|
2015-07-21 12:14:47 +00:00
|
|
|
}
|
|
|
|
|
2015-07-18 23:00:54 +00:00
|
|
|
function barcodeKeyPress(event) {
|
|
|
|
var key = String.fromCharCode(event.charCode)
|
2015-07-21 12:33:37 +00:00
|
|
|
var input = document.getElementById('crement')
|
|
|
|
if ( input ) {
|
|
|
|
input.focus()
|
|
|
|
}
|
2015-07-21 07:14:38 +00:00
|
|
|
var focused = document.activeElement
|
|
|
|
if (! focused || focused == document.body) {
|
|
|
|
focused = null
|
|
|
|
} else if (document.querySelector) {
|
|
|
|
focused = document.querySelector(":focus")
|
|
|
|
}
|
2015-07-21 12:14:47 +00:00
|
|
|
if ( focused == null || focused.tagName != "INPUT" ) {
|
|
|
|
if ( event.keyCode === 13 ) {
|
2015-07-21 07:14:38 +00:00
|
|
|
var input = document.getElementById('barcodeInput')
|
2015-07-21 17:18:00 +00:00
|
|
|
if (input && barcodeBuf.length > 0) {
|
2015-07-21 07:14:38 +00:00
|
|
|
input.setAttribute('value', barcodeBuf)
|
|
|
|
input.parentNode.submit()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
barcodeBuf = ""
|
|
|
|
event.preventDefault()
|
2015-07-21 12:14:47 +00:00
|
|
|
} else if ( event.keyCode === 27 ){
|
|
|
|
barcodeBuf=hideBarcode()
|
|
|
|
event.preventDefault()
|
|
|
|
} else if ( event.keyCode === 9 ){
|
|
|
|
barcodeBuf = barcodeBuf.substring( 0, barcodeBuf.length - 1 )
|
|
|
|
if ( barcodeBuf.length <= 0 ) {
|
|
|
|
barcodeBuf=hideBarcode()
|
|
|
|
}
|
|
|
|
event.preventDefault()
|
2015-07-21 07:14:38 +00:00
|
|
|
} else {
|
|
|
|
barcodeBuf += key
|
|
|
|
showBarcode(barcodeBuf)
|
|
|
|
event.preventDefault()
|
2015-07-20 23:14:21 +00:00
|
|
|
}
|
2015-07-18 23:00:54 +00:00
|
|
|
}
|
|
|
|
}
|