Merge pull request #65 from s72785/patch-8
enable backspace and escape, disable overlay
This commit is contained in:
commit
8be29dd8c9
1 changed files with 18 additions and 2 deletions
|
@ -8,6 +8,13 @@ function showBarcode(text) {
|
||||||
document.getElementById('barcodeContent').textContent = text
|
document.getElementById('barcodeContent').textContent = text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hideBarcode() {
|
||||||
|
if (barcodeShown) {
|
||||||
|
document.getElementById('barcode').classList.remove('shown')
|
||||||
|
}
|
||||||
|
return document.getElementById('barcodeContent').textContent
|
||||||
|
}
|
||||||
|
|
||||||
function barcodeKeyPress(event) {
|
function barcodeKeyPress(event) {
|
||||||
var key = String.fromCharCode(event.charCode)
|
var key = String.fromCharCode(event.charCode)
|
||||||
var focused = document.activeElement
|
var focused = document.activeElement
|
||||||
|
@ -26,6 +33,15 @@ function barcodeKeyPress(event) {
|
||||||
}
|
}
|
||||||
barcodeBuf = ""
|
barcodeBuf = ""
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
} 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()
|
||||||
} else {
|
} else {
|
||||||
barcodeBuf += key
|
barcodeBuf += key
|
||||||
showBarcode(barcodeBuf)
|
showBarcode(barcodeBuf)
|
||||||
|
|
Loading…
Reference in a new issue