[FIX] barcodes: don't require suffix for scans
Users don't have to configure their scanner. As stated in the docs/planner, either wait 50ms between 2 scans or use a suffix.
This commit is contained in:
@@ -95,7 +95,7 @@ The purpose of this component is to listen to keypresses to detect barcodes, the
|
||||
on core.bus inside a 'barcode_event'.
|
||||
All keypress events are buffered until there is no more keypress during 50ms or a carriage return / tab is
|
||||
inputted (because most barcode scanners use this as a suffix).
|
||||
If the buffered keys looks like a barcode (match the the regexp /.{3,}[\n\r\t]+), an event is triggered :
|
||||
If the buffered keys looks like a barcode (match the the regexp /.{3,}[\n\r\t]*), an event is triggered :
|
||||
core.bus.trigger('barcode_scanned', barcode);
|
||||
Otherwise, the keypresses are 'resent'. However, for security reasons, a keypress event programmatically
|
||||
crafted doesn't trigger native browser behaviors. For this reason, BarcodeEvents doesn't intercept keypresses
|
||||
|
||||
@@ -10,7 +10,7 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
|
||||
buffered_key_events: [],
|
||||
// Regexp to match a barcode input and extract its payload
|
||||
// Note: to build in init() if prefix/suffix can be configured
|
||||
regexp: /(.{3,})[\n\r\t]+/,
|
||||
regexp: /(.{3,})[\n\r\t]*/,
|
||||
// By knowing the terminal character we can interpret buffered keys
|
||||
// as a barcode as soon as it's encountered (instead of waiting x ms)
|
||||
suffix: /[\n\r\t]+/,
|
||||
|
||||
Reference in New Issue
Block a user