diff --git a/.gitignore b/.gitignore
index f0cb6bc..dece519 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,6 @@
.mtj.tmp/
# Package Files #
-*.jar
*.war
*.nar
*.ear
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..5c2d1cf
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json
new file mode 100644
index 0000000..88c6ad5
--- /dev/null
+++ b/node_modules/.package-lock.json
@@ -0,0 +1,12 @@
+{
+ "name": "TBMS",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "node_modules/onscan.js": {
+ "version": "1.5.2",
+ "resolved": "https://registry.npmjs.org/onscan.js/-/onscan.js-1.5.2.tgz",
+ "integrity": "sha512-9oGYy2gXYRjvXO9GYqqVca0VuCTAmWhbmX3egBSBP13rXiMNb+dKPJzKFEeECGqPBpf0m40Zoo+GUQ7eCackdw=="
+ }
+ }
+}
diff --git a/node_modules/onscan/.github/main.workflow b/node_modules/onscan/.github/main.workflow
new file mode 100644
index 0000000..76b294a
--- /dev/null
+++ b/node_modules/onscan/.github/main.workflow
@@ -0,0 +1,10 @@
+workflow "publish on release" {
+ on = "push"
+ resolves = ["publish"]
+}
+
+action "publish" {
+ uses = "actions/npm@master"
+ args = "publish"
+ secrets = ["77cd6a03-5851-4997-ba04-a529eb3a7629"]
+}
\ No newline at end of file
diff --git a/node_modules/onscan/.project b/node_modules/onscan/.project
new file mode 100644
index 0000000..1da9e1b
--- /dev/null
+++ b/node_modules/onscan/.project
@@ -0,0 +1,17 @@
+
+
+ onScan.js
+
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+
+ org.eclipse.wst.jsdt.core.jsNature
+
+
diff --git a/node_modules/onscan/.settings/.jsdtscope b/node_modules/onscan/.settings/.jsdtscope
new file mode 100644
index 0000000..c19fafc
--- /dev/null
+++ b/node_modules/onscan/.settings/.jsdtscope
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/node_modules/onscan/.settings/org.eclipse.wst.jsdt.ui.superType.container b/node_modules/onscan/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..49c8cd4
--- /dev/null
+++ b/node_modules/onscan/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.JRE_CONTAINER
\ No newline at end of file
diff --git a/node_modules/onscan/.settings/org.eclipse.wst.jsdt.ui.superType.name b/node_modules/onscan/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..11006e2
--- /dev/null
+++ b/node_modules/onscan/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Global
\ No newline at end of file
diff --git a/node_modules/onscan/HISTORY.md b/node_modules/onscan/HISTORY.md
new file mode 100644
index 0000000..d888e28
--- /dev/null
+++ b/node_modules/onscan/HISTORY.md
@@ -0,0 +1,55 @@
+# onScan.js - version history
+
+### 1.5.2
+
+- FIX undefined variable oOptions when in paste-mode
+
+### 1.5.1
+
+- NEW utility method `onScan.isAttachedTo()`.
+- FIX improvements in documentation
+
+## 1.5
+
+- NEW method `onScan.isScanInProgressFor()` to test if a potential keyboard scan is in progress
+- NEW option `captureEvents` to make sure onScan gets events before any other listerer below in the DOM
+
+### 1.4.3
+
+- NEW `onScan.simulate()` now accepts arrays of key codes or event properties
+- FIX shiftKey detection was not working
+
+### 1.4.2
+
+- FIX missing update of min-version for 1.4.1
+- FIX further improvements for key code normalization
+
+### 1.4.1
+
+- FIX default keyboard event decoder
+
+## 1.4
+
+- Improved default key code decoder: ignore non-alphanumeric characters, case sensitive now, etc.
+- Wrapped onScan as a JS module
+- Fixed JS errors in browsers, that do not allow overriding KeyboardEvent.which
+
+### 1.3.2
+
+- FIX option `ignoreIfFocusOn` not working
+
+## 1.3
+
+- Added option `reactToKeydown` to disable keyboard-mode if favor of clipboard-mode only
+- Cleaned up API
+- Improved README
+- Added LICENSE and HISTORY.md
+
+## 1.2
+
+- Added support for NPM
+
+## 1.0
+
+- Initial release
+
diff --git a/node_modules/onscan/LICENSE b/node_modules/onscan/LICENSE
new file mode 100644
index 0000000..e1854e8
--- /dev/null
+++ b/node_modules/onscan/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2014-2015 almasaeed2010
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/onscan/README.md b/node_modules/onscan/README.md
new file mode 100644
index 0000000..5bdc05f
--- /dev/null
+++ b/node_modules/onscan/README.md
@@ -0,0 +1,201 @@
+# onScan.js
+
+Framework-agnostic JavaScript scan-events for hardware barcode scanners.
+
+## Quick start
+
+1. Install via `npm install onscan.js` or `bower install onscan-js`
+2. Include `onscan.min.js` in your script
+3. Add the following initilization script to run on page/view load.
+
+```javascript
+// Enable scan events for the entire document
+onScan.attachTo(document);
+// Register event listener
+document.addEventListener('scan', function(sScancode, iQuantity) {
+ alert(iQuantity + 'x ' + sScancode);
+});
+```
+
+## Demo & Playground
+
+[Online demo](https://a.kabachnik.info/onscan-js-playground.html)
+
+A similar demo is available within the
+package: just load `index.html` from the lib's folder to play around with the settings on your own server.
+
+## Requirements
+
+1) A hardware barcode scanner, that
+ - acts as a keyboard (often called keyboard-wedge-mode), or
+ - pastes the scanned codes (clipboard-mode)
+2) A more-or-less modern browser (IE9+)
+
+## How it works
+
+onScan.js attempts to distinguish between regular input and scan input by measuring input spead,
+looking for certain prefix and suffix characters, etc. If a scan is detected, it triggers a custom
+JavaScript event called `scan` for the DOM element specified during initialization.
+
+There are lot's of options to fine-tune detection of specific scanner models.
+
+There are also a couple of usefull extras (some requiring specifc hardware):
+
+- Passing a counter along with the scanned code
+- Adding a secondary action to the hardware button of built-in scanners, if it is long pressed
+
+## Some examples
+
+```javascript
+// Initialize with options
+onScan.attachTo(document, {
+ suffixKeyCodes: [13], // enter-key expected at the end of a scan
+ reactToPaste: true, // Compatibility to built-in scanners in paste-mode (as opposed to keyboard-mode)
+ onScan: function(sCode, iQty) { // Alternative to document.addEventListener('scan')
+ console.log('Scanned: ' + iQty + 'x ' + sCode);
+ },
+ onKeyDetect: function(iKeyCode){ // output all potentially relevant key events - great for debugging!
+ console.log('Pressed: ' + iKeyCode);
+ }
+});
+
+// Simulate a scan programmatically - e.g. to test event handlers
+onScan.simulate(document, '1234567890123');
+
+// Simulate raw keyCodes
+onScan.simulate(document, [48,49,50]);
+
+// Simulate keydown events
+onScan.simulate(document, [ {keyCode:80, key:'P', shiftKey:true}, {keyCode:49,key:'1'} ]);
+
+// Change options on-the-fly
+onScan.setOptions(document, {
+ singleScanQty: 5 // change the quantity to 5 for every scan
+});
+
+// Remove onScan.js from a DOM element completely
+onScan.detachFrom(document);
+```
+
+## Options
+
+The following options can be set when initializing onScan.js:
+
+| Option | Default | Description |
+| ------ | ------- | ----------- |
+| onScan | function(sScanned, iQty){} | Callback after successful scan.
Arguments: - `sScanned` - [string] scanned code - `iQty` - [integer] quantity |
+| onScanButtonLongPress | function(){} | Callback after the scan button was pressed and held down for a time defined in `scanButtonLongPressThreshold`. This can only be used if the scan button behaves as a key itself and the `scanButtonKeyCode` option is set. |
+| onScanError | function(oDebug){} | Callback after a scanned string being dropped due to restrictions.
Arguments: - `oDebug` - [object] plain object with various debug data|
+| onKeyDetect | function(iKeyCode, oEvent){} | Callback after every detected key event. Further event processing can be canceled by returning `false` from this callback - e.g. to exclude certain key events completely.
Arguments: - `iKeyCode` - [integer] detected key code - `oEvent` [KeyboardEvent] complete event instance |
+| onKeyProcess | function(sChar, oEvent){} | Callback after a key event was decoded and found to be part of a potential scan code. Keep in mind, that a this point it is not yet known, whether it's a scan or not - it's just a valid character being processed and decoded.
Arguments: - `sChar` - [string] decoded character - `oEvent` [KeyboardEvent] complete event instance |
+| onPaste | function(sPasted, oEvent){} | Callback after detecting a paste. Only fired if `reactToPaste` is set to `true`.
Arguments: - `sPasted` - [string] pasted string - `oEvent` - [Event] complete event instance |
+| keyCodeMapper | onScan.decodeKeyEvent() | A function to extract the character from a `keydown` event. The event will be ignored if the function returns `null`. See chapter "Decoding key codes" below for more information. |
+| timeBeforeScanTest | 100 | Wait duration (ms) after keypress event to check if scanning finished |
+| avgTimeByChar | 30 | Average time (ms) between 2 chars. If a scan is detected, but it took more time that [code length] * `avgTimeByChar`, a `scanError` will be triggered. |
+| minLength | 6 | Minimum length for a scanned code. If the scan ends before reaching this length, it will trigger a `scanError` event. |
+| suffixKeyCodes | [9,13] | An array with possible suffix codes sent by the scanner after the actual data. Detecting one of them means end of scanning, but they can never be part of the scanned code. Many scanners will send key code `13` (enter) as suffix by default. This can be changed in the configuration in most cases.
NOTE: KeyboardEvents with these key codes will be silenced via `event.stopImmediatePropagation()` and `event.preventDefault()`. |
+| prefixKeyCodes | [] | An array with possible prefix codes sent by the scanner before the actual data. Detecting one of them means start of scanning, but they can never be part of the scanned code. Many scanners support prefix characters in their configuration.
NOTE: KeyboardEvents with these key codes will be silenced via `event.stopImmediatePropagation()` and `event.preventDefault()`. |
+| ignoreIfFocusOn | false | Ignore scans if the currently focused element matches this selector. For example, if you set this option to `'input'`, scan events will not be fired if an input field is focused. You can either pass an DOMElement, a CSS selector or an array containing multiple besaid objects. |
+| scanButtonKeyCode | false | Key code of the scanner hardware button (i.e. if the scanner button a acts as a key itself). Knowing this key code is important, because it is not part of the scanned code and must be ignored. |
+| scanButtonLongPressTime | 500 | Time (ms) to hold the scan button before `onScanButtonLongPress` is triggered. Only works if `scanButtonKeyCode` is set. |
+| stopPropagation | false | Stop immediate propagation of events, that are processed successfully.
WARNING: If `reactToKeyDown` is true, every keyboard event, that could potentially be part of a scancode will be stopped! |
+| preventDefault | false | Prevent default action of events, that are processed successfully.
WARNING: If `reactToKeyDown` is true, the default of every keyboard event, that could potentially be part of a scancode will be prevented - in particular you won't be able to use the keyboard for typing!!! |
+| captureEvents | false | Set to `true` to force all relevant events to be dispatched to onScan _before_ being dispatched to any `EventTarget` beneath it in the DOM tree. Use this if you need to cancel certain events in onScan callbacks. Technically this option is used as the third parameter in `.addEventListener(type, listener [, useCapture])` calls. The exact behavior is documented [here](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener). |
+| singleScanQty | 1 | This is the quantity of items which gets returned on a single successful scan. |
+| reactToKeydown | true | Look for scan input among `keydown` events (i.e. if the scanner works in keyboard-mode). |
+| reactToPaste | false | Look for scan input among `paste` events (i.e. if the scanner works in clipboard-mode). |
+
+
+## Events
+
+| Event name | Parameters passed to listener | Description |
+| ------ | ------- | ----------- |
+| scan | sScanned, iQty | Triggered after successful scan. Handler arguments: - `sScanned` - [string] scanned code - `iQty` - [integer] quantity |
+| scanButtonLongPress | | Triggered after the scan button was pressed and held down for a time defined in `scanButtonLongPressThreshold`. This can only be used if the scan button behaves as a key itself and the `scanButtonKeyCode` option is set. No arguments are passed to the handler. |
+| scanError | oDebug | Triggered after a scanned string being dropped due to restrictions. Handler arguments: - `oDebug` - [object] plain object with various debug data |
+
+You can register regular event listeners on the DOM element, onScan was initialized for:
+
+```javascript
+document
+ .addEventListener('scan', function(sScanned, iQty){ ... });
+ .addEventListener('scanError', function(oDebug){ ... });
+ .addEventListener('scanButtonLongPressed', function(){ ... });
+```
+
+You can also define callback directly in the options, when initializing onScan:
+
+```javascript
+onScan.attachTo(document, {
+ onScan: function(sScanned, iQty) { ... },
+ onScanError: function(oDebug) { ... },
+ onScanButtonLongPress: function() { ... },
+ onKeyDetect: function(iKeyCode, oEvent){ ... }
+ onKeyProcess: function(sChar, oEvent){ ... }
+ onPaste: function(sPasted){ ... }
+});
+```
+
+Note: there are more callbacks in the options, than event types. The non-event callbacks are primarily usefull for testing and finding the right configuration for a specific scanner - see playgournd for examples.
+
+## Methods
+
+| Method | Arguments | Description |
+| ------ | --------- | ----------- |
+| attachTo | DOMElement, oOptions | Initializes listening for scan events for given DOM element. Only events fired for this DOM element will be processed. Use `document` to process all possible events. This is the best pick in most cases.
NOTE: onScan.js can be attached to a DOM element only once. If you, for some reason, need to call `attachTo()` for a single element multiple times, you must call `detachFrom()` first. |
+| detachFrom | DOMElement | Removes all scanner detection logic from the given DOM element. |
+| simulate | DOMElement, mStringOrArray | Fires the `scan` event for the given scan code - usefull to trigger listeners manually (e.g. for testing). Accepts either an already decoded string or an array with key codes or event property objects - see below for details. |
+| setOptions | DOMElement, oOptions | Replaces only the newly sent options. |
+| getOptions | DOMElement | Retrieves entire oOptions object. |
+| decodeKeyEvent | Event | Extracts the scanned string character from a keyboard event (i.e. `keydown`) |
+| isAttachedTo | DOMElement | Returns `true` if onScan is attached to the given DOM element and `false` otherwise |
+| isScanInProgressFor | DOMElement | Returns `true` the scanner is currently in the middle of a scan sequence and `false` otherwise. Technically, this means, that the scan sequence started (e.g. via prefix character) and has not ended yet (e.g. via suffix or timeout). This method is usefull inside event handlers. |
+
+## Decoding key codes
+
+By default, onScan.js ignores any key codes other than those matching letters and numbers. The latter are transformed into characters using built-in browser logic (i.e. the `event.key`). These [key codes](https://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes) are converted to characters:
+
+- `48`-`90` (letters and regular numbers)
+- `96`-`105` (numeric keypad numbers)
+- `106`-`111` (numeric keypad operations)
+
+This should work for the vast majority of cases. However, if you encounter strange extra characters in the codes read or miss some characters (like hypens), you can override the default decoding algorithm by specifying a custom `keyCodeMapper` like this:
+
+```javascript
+onScan.attachTo(document, {
+ onScan: function(sScanned, iQty) { ... },
+ keyCodeMapper: function(oEvent) {
+ // Look for special keycodes or other event properties specific to
+ // your scanner
+ if (oEvent.which = 'your_special_key_code') {
+ return 'xxx';
+ }
+ // Fall back to the default decoder in all other cases
+ return onScan.decodeKeyEvent(oEvent);
+ }
+});
+```
+
+Background: Barcode scanners operating in keyboard-mode (as opposed to clipboard-mode) work by simulating pressing keyboard keys. They send numeric key codes and the browser interprets them as input. This works great for letters and numbers. However, many barcode scanners also send additional characters depending on their configuration: e.g. the trailing enter (key code `13`), prefix or suffix codes, delimiters, and even their own "virtual" key codes. There are also cases, when key codes are used in a non-standard way. All these cases can be easily treated using a custom `keyCodeMapper` as shown above.
+
+### Simulating key codes
+
+If you do not have your scanner at hand, you can simulate keyboard events programmatically via `onScan.simulate()`. You can pass the desired scan code in the following formats:
+
+- a string - in this case no keyCode decoding is done and the code is merely validated against constraints like minLenght, etc.
+- an array of keyCodes (e.g. `[70,71,80]`) - will produce `keydown` events with corresponding `keyCode` properties. NOTE: these events will have empty `key` properties, so decoding may yield different results than with native events.
+- an array of objects (e.g. `[{keyCode: 70, key: "F", shiftKey: true}, {keyCode: 71, key: "g"}]`) - this way almost any event can be simulated exactly, but it's a lot of work to do.
+
+Hint: use the `onKeyDetect` checkbox in the playground to get a full dump of each keyboard event an just paste them in your simulation code.
+
+## Credits
+
+This library was inspired by the jQuery plugin [jQuery ScannerDetection](https://github.com/iuyes/jQuery-Scanner-Detection) by Julien Maurel.
+
+## History
+
+See [HISTORY.md](https://github.com/axenox/onscan.js/blob/master/HISTORY.md).
+
+## License
+
+onScan.js is an open source project licensed under MIT.
diff --git a/node_modules/onscan/bower.json b/node_modules/onscan/bower.json
new file mode 100644
index 0000000..f2eca65
--- /dev/null
+++ b/node_modules/onscan/bower.json
@@ -0,0 +1,20 @@
+{
+ "name": "onscan-js",
+ "homepage": "https://github.com/axenox/onscan.js/issues",
+ "description": "Framework agnostic onScan event fired when using hardware barcode scanners",
+ "main": "onscan.js",
+ "license": "MIT",
+ "authors": [
+ "Andrej Kabachnik",
+ "Thomas Michael"
+ ],
+ "keywords": ["barcode", "RFID", "scanner", "scan"],
+
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ]
+}
diff --git a/node_modules/onscan/index.html b/node_modules/onscan/index.html
new file mode 100644
index 0000000..f23a561
--- /dev/null
+++ b/node_modules/onscan/index.html
@@ -0,0 +1,428 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/node_modules/onscan/onscan.js b/node_modules/onscan/onscan.js
new file mode 100644
index 0000000..3b01bdf
--- /dev/null
+++ b/node_modules/onscan/onscan.js
@@ -0,0 +1,526 @@
+/*
+ * onScan.js - scan-events for hardware barcodes scanners in javascript
+ */
+;(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory()) :
+ global.onScan = factory()
+}(this, (function () {
+ var onScan = {
+
+ /**
+ *
+ * @param DomElement oDomElement
+ * @param Object oOptions
+ * @return self
+ */
+ attachTo: function(oDomElement, oOptions) {
+
+ if(oDomElement.scannerDetectionData !== undefined){
+ throw new Error("onScan.js is already initialized for DOM element " + oDomElement);
+ }
+
+ var oDefaults = {
+ onScan: function(sScanned, iQty){}, // Callback after detection of a successfull scanning: function(){sScancode, iCount)}()
+ onScanError: function(oDebug){}, // Callback after detection of a unsuccessfull scanning (scanned string in parameter)
+ onKeyProcess: function(sChar, oEvent){}, // Callback after receiving and processing a char (scanned char in parameter)
+ onKeyDetect: function(iKeyCode, oEvent){}, // Callback after detecting a keyDown (key char in parameter) - in contrast to onKeyProcess, this fires for non-character keys like tab, arrows, etc. too!
+ onPaste: function(sPasted, oEvent){}, // Callback after receiving a value on paste, no matter if it is a valid code or not
+ keyCodeMapper: function(oEvent) {return onScan.decodeKeyEvent(oEvent)}, // Custom function to decode a keydown event into a character. Must return decoded character or NULL if the given event should not be processed.
+ onScanButtonLongPress: function(){}, // Callback after detection of a successfull scan while the scan button was pressed and held down
+ scanButtonKeyCode:false, // Key code of the scanner hardware button (if the scanner button a acts as a key itself)
+ scanButtonLongPressTime:500, // How long (ms) the hardware button should be pressed, until a callback gets executed
+ timeBeforeScanTest:100, // Wait duration (ms) after keypress event to check if scanning is finished
+ avgTimeByChar:30, // Average time (ms) between 2 chars. Used to do difference between keyboard typing and scanning
+ minLength:6, // Minimum length for a scanning
+ suffixKeyCodes:[9,13], // Chars to remove and means end of scanning
+ prefixKeyCodes:[], // Chars to remove and means start of scanning
+ ignoreIfFocusOn:false, // do not handle scans if the currently focused element matches this selector or object
+ stopPropagation:false, // Stop immediate propagation on keypress event
+ preventDefault:false, // Prevent default action on keypress event
+ captureEvents:false, // Get the events before any listeners deeper in the DOM
+ reactToKeydown:true, // look for scan input in keyboard events
+ reactToPaste:false, // look for scan input in paste events
+ singleScanQty: 1, // Quantity of Items put out to onScan in a single scan
+ }
+
+ oOptions = this._mergeOptions(oDefaults, oOptions);
+
+ // initializing options and variables on DomElement
+ oDomElement.scannerDetectionData = {
+ options: oOptions,
+ vars:{
+ firstCharTime: 0,
+ lastCharTime: 0,
+ accumulatedString: '',
+ testTimer: false,
+ longPressTimeStart: 0,
+ longPressed: false
+ }
+
+ };
+
+ // initializing handlers (based on settings)
+ if (oOptions.reactToPaste === true){
+ oDomElement.addEventListener("paste", this._handlePaste, oOptions.captureEvents);
+ }
+ if (oOptions.scanButtonKeyCode !== false){
+ oDomElement.addEventListener("keyup", this._handleKeyUp, oOptions.captureEvents);
+ }
+ if (oOptions.reactToKeydown === true || oOptions.scanButtonKeyCode !== false){
+ oDomElement.addEventListener("keydown", this._handleKeyDown, oOptions.captureEvents);
+ }
+ return this;
+ },
+
+ /**
+ *
+ * @param DomElement oDomElement
+ * @return void
+ */
+ detachFrom: function(oDomElement) {
+ // detaching all used events
+ if (oDomElement.scannerDetectionData.options.reactToPaste){
+ oDomElement.removeEventListener("paste", this._handlePaste);
+ }
+ if (oDomElement.scannerDetectionData.options.scanButtonKeyCode !== false){
+ oDomElement.removeEventListener("keyup", this._handleKeyUp);
+ }
+ oDomElement.removeEventListener("keydown", this._handleKeyDown);
+
+ // clearing data off DomElement
+ oDomElement.scannerDetectionData = undefined;
+ return;
+ },
+
+ /**
+ *
+ * @param DomElement oDomElement
+ * @return Object
+ */
+ getOptions: function(oDomElement){
+ return oDomElement.scannerDetectionData.options;
+ },
+
+ /**
+ *
+ * @param DomElement oDomElement
+ * @param Object oOptions
+ * @return self
+ */
+ setOptions: function(oDomElement, oOptions){
+ // check if some handlers need to be changed based on possible option changes
+ switch (oDomElement.scannerDetectionData.options.reactToPaste){
+ case true:
+ if (oOptions.reactToPaste === false){
+ oDomElement.removeEventListener("paste", this._handlePaste);
+ }
+ break;
+ case false:
+ if (oOptions.reactToPaste === true){
+ oDomElement.addEventListener("paste", this._handlePaste);
+ }
+ break;
+ }
+
+ switch (oDomElement.scannerDetectionData.options.scanButtonKeyCode){
+ case false:
+ if (oOptions.scanButtonKeyCode !== false){
+ oDomElement.addEventListener("keyup", this._handleKeyUp);
+ }
+ break;
+ default:
+ if (oOptions.scanButtonKeyCode === false){
+ oDomElement.removeEventListener("keyup", this._handleKeyUp);
+ }
+ break;
+ }
+
+ // merge old and new options
+ oDomElement.scannerDetectionData.options = this._mergeOptions(oDomElement.scannerDetectionData.options, oOptions);
+
+ // reinitiallize
+ this._reinitialize(oDomElement);
+ return this;
+ },
+
+ /**
+ * Transforms key codes into characters.
+ *
+ * By default, only the follwing key codes are taken into account
+ * - 48-90 (letters and regular numbers)
+ * - 96-105 (numeric keypad numbers)
+ * - 106-111 (numeric keypad operations)
+ *
+ * All other keys will yield empty strings!
+ *
+ * The above keycodes will be decoded using the KeyboardEvent.key property on modern
+ * browsers. On older browsers the method will fall back to String.fromCharCode()
+ * putting the result to upper/lower case depending on KeyboardEvent.shiftKey if
+ * it is set.
+ *
+ * @param KeyboardEvent oEvent
+ * @return string
+ */
+ decodeKeyEvent : function (oEvent) {
+ var iCode = this._getNormalizedKeyNum(oEvent);
+ switch (true) {
+ case iCode >= 48 && iCode <= 90: // numbers and letters
+ case iCode >= 106 && iCode <= 111: // operations on numeric keypad (+, -, etc.)
+ if (oEvent.key !== undefined && oEvent.key !== '') {
+ return oEvent.key;
+ }
+
+ var sDecoded = String.fromCharCode(iCode);
+ switch (oEvent.shiftKey) {
+ case false: sDecoded = sDecoded.toLowerCase(); break;
+ case true: sDecoded = sDecoded.toUpperCase(); break;
+ }
+ return sDecoded;
+ case iCode >= 96 && iCode <= 105: // numbers on numeric keypad
+ return 0+(iCode-96);
+ }
+ return '';
+ },
+
+ /**
+ * Simulates a scan of the provided code.
+ *
+ * The scan code can be defined as
+ * - a string - in this case no keyCode decoding is done and the code is merely validated
+ * against constraints like minLenght, etc.
+ * - an array of keyCodes (e.g. `[70,71,80]`) - will produce `keydown` events with corresponding
+ * `keyCode` properties. NOTE: these events will have empty `key` properties, so decoding may
+ * yield different results than with native events.
+ * - an array of objects (e.g. `[{keyCode: 70, key: "F", shiftKey: true}, {keyCode: 71, key: "g"}]`) -
+ * this way almost any event can be simulated, but it's a lot of work to do.
+ *
+ * @param DomElement oDomElement
+ * @param string|array mStringOrArray
+ * @return self
+ */
+ simulate: function(oDomElement, mStringOrArray){
+ this._reinitialize(oDomElement);
+ if (Array.isArray(mStringOrArray)){
+ mStringOrArray.forEach(function(mKey){
+ var oEventProps = {};
+ if( (typeof mKey === "object" || typeof mKey === 'function') && (mKey !== null) ) {
+ oEventProps = mKey;
+ } else {
+ oEventProps.keyCode = parseInt(mKey);
+ }
+ var oEvent = new KeyboardEvent('keydown', oEventProps);
+ document.dispatchEvent(oEvent);
+ })
+ } else {
+ this._validateScanCode(oDomElement, mStringOrArray);
+ }
+ return this;
+ },
+
+ /**
+ * @private
+ * @param DomElement oDomElement
+ * @return void
+ */
+ _reinitialize: function(oDomElement){
+ var oVars = oDomElement.scannerDetectionData.vars;
+ oVars.firstCharTime = 0;
+ oVars.lastCharTime = 0;
+ oVars.accumulatedString = '';
+ return;
+ },
+
+ /**
+ * @private
+ * @param DomElement oDomElement
+ * @return boolean
+ */
+ _isFocusOnIgnoredElement: function(oDomElement){
+
+ var ignoreSelectors = oDomElement.scannerDetectionData.options.ignoreIfFocusOn;
+
+ if(!ignoreSelectors){
+ return false;
+ }
+
+ var oFocused = document.activeElement;
+
+ // checks if ignored element is an array, and if so it checks if one of the elements of it is an active one
+ if (Array.isArray(ignoreSelectors)){
+ for(var i=0; i (sScanCode.length * oOptions.avgTimeByChar)):
+ oScanError = {
+ message: "Receieved code was not entered in time"
+ };
+ break;
+
+ // if a code was not filtered out earlier it is valid
+ default:
+ oOptions.onScan.call(oDomElement, sScanCode, iSingleScanQty);
+ oEvent = new CustomEvent(
+ 'scan',
+ {
+ detail: {
+ scanCode: sScanCode,
+ qty: iSingleScanQty
+ }
+ }
+ );
+ oDomElement.dispatchEvent(oEvent);
+ onScan._reinitialize(oDomElement);
+ return true;
+ }
+
+ // If an error occurred (otherwise the method would return earlier) create an object for errordetection
+ oScanError.scanCode = sScanCode;
+ oScanError.scanDuration = iLastCharTime - iFirstCharTime;
+ oScanError.avgTimeByChar = oOptions.avgTimeByChar;
+ oScanError.minLength = oOptions.minLength;
+
+ oOptions.onScanError.call(oDomElement, oScanError);
+
+ oEvent = new CustomEvent(
+ 'scanError',
+ {detail: oScanError}
+ );
+ oDomElement.dispatchEvent(oEvent);
+
+ onScan._reinitialize(oDomElement);
+ return false;
+ },
+
+ /**
+ * @private
+ * @param Object oDefaults
+ * @param Object oOptions
+ * @return Object
+ */
+ _mergeOptions: function(oDefaults, oOptions){
+ var oExtended = {};
+ var prop;
+ for (prop in oDefaults){
+ if (Object.prototype.hasOwnProperty.call(oDefaults, prop)){
+ oExtended[prop] = oDefaults[prop];
+ }
+ }
+ for (prop in oOptions){
+ if (Object.prototype.hasOwnProperty.call(oOptions, prop)){
+ oExtended[prop] = oOptions[prop];
+ }
+ }
+ return oExtended;
+ },
+
+ /**
+ * @private
+ * @param KeyboardEvent e
+ * @return int
+ * @see https://www.w3schools.com/jsref/event_key_keycode.asp
+ */
+ _getNormalizedKeyNum: function(e){
+ return e.which || e.keyCode;
+ },
+
+
+ /**
+ * @private
+ * @param KeyboardEvent e
+ * @return void
+ */
+ _handleKeyDown: function(e){
+ var iKeyCode = onScan._getNormalizedKeyNum(e);
+ var oOptions = this.scannerDetectionData.options;
+ var oVars = this.scannerDetectionData.vars;
+ var bScanFinished = false;
+
+ if (oOptions.onKeyDetect.call(this, iKeyCode, e) === false) {
+ return;
+ }
+
+ if (onScan._isFocusOnIgnoredElement(this)){
+ return;
+ }
+
+ // If it's just the button of the scanner, ignore it and wait for the real input
+ if(oOptions.scanButtonKeyCode !== false && iKeyCode==oOptions.scanButtonKeyCode) {
+
+ // if the button was first pressed, start a timeout for the callback, which gets interrupted if the scanbutton gets released
+ if (!oVars.longPressed){
+ oVars.longPressTimer = setTimeout( oOptions.onScanButtonLongPress, oOptions.scanButtonLongPressTime, this);
+ oVars.longPressed = true;
+ }
+
+ return;
+ }
+
+ switch(true){
+ // If it's not the first character and we encounter a terminating character, trigger scan process
+ case (oVars.firstCharTime && oOptions.suffixKeyCodes.indexOf(iKeyCode)!==-1):
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ bScanFinished=true;
+ break;
+
+ // If it's the first character and we encountered one of the starting characters, don't process the scan
+ case (!oVars.firstCharTime && oOptions.prefixKeyCodes.indexOf(iKeyCode)!==-1):
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ bScanFinished=false;
+ break;
+
+ // Otherwise, just add the character to the scan string we're building
+ default:
+ var character = oOptions.keyCodeMapper.call(this, e);
+ if (character === null){
+ return;
+ }
+ oVars.accumulatedString += character;
+
+ if (oOptions.preventDefault) {
+ e.preventDefault();
+ }
+ if (oOptions.stopPropagation) {
+ e.stopImmediatePropagation();
+ }
+
+ bScanFinished=false;
+ break;
+ }
+
+ if(!oVars.firstCharTime){
+ oVars.firstCharTime=Date.now();
+ }
+
+ oVars.lastCharTime=Date.now();
+
+ if(oVars.testTimer){
+ clearTimeout(oVars.testTimer);
+ }
+
+ if(bScanFinished){
+ onScan._validateScanCode(this, oVars.accumulatedString);
+ oVars.testTimer=false;
+ } else {
+ oVars.testTimer=setTimeout(onScan._validateScanCode, oOptions.timeBeforeScanTest, this, oVars.accumulatedString);
+ }
+
+ oOptions.onKeyProcess.call(this, character, e);
+ return;
+ },
+
+ /**
+ * @private
+ * @param Event e
+ * @return void
+ */
+ _handlePaste: function(e){
+
+ var oOptions = this.scannerDetectionData.options;
+ var oVars = this.scannerDetectionData.vars;
+ var sPasteString = (event.clipboardData || window.clipboardData).getData('text');
+
+ // if the focus is on an ignored element, abort
+ if (onScan._isFocusOnIgnoredElement(this)){
+ return;
+ }
+
+ e.preventDefault();
+
+ if (oOptions.stopPropagation) {
+ e.stopImmediatePropagation();
+ }
+
+ oOptions.onPaste.call(this, sPasteString, event);
+
+ oVars.firstCharTime = 0;
+ oVars.lastCharTime = 0;
+
+ // validate the string
+ onScan._validateScanCode(this, sPasteString);
+ return;
+ },
+
+ /**
+ * @private
+ * @param KeyboardEvent e
+ * @return void
+ */
+ _handleKeyUp: function(e){
+ // if the focus is on an ignored element, abort
+ if (onScan._isFocusOnIgnoredElement(this)){
+ return;
+ }
+
+ var iKeyCode = onScan._getNormalizedKeyNum(e);
+
+ // if hardware key is not being pressed anymore stop the timeout and reset
+ if (iKeyCode == this.scannerDetectionData.options.scanButtonKeyCode){
+ clearTimeout(this.scannerDetectionData.vars.longPressTimer);
+ this.scannerDetectionData.vars.longPressed = false;
+ }
+ return;
+ },
+
+ /**
+ * Returns TRUE the scanner is currently in the middle of a scan sequence.
+ *
+ * @param DomElement
+ * @return boolean
+ */
+ isScanInProgressFor: function(oDomElement) {
+ return oDomElement.scannerDetectionData.vars.firstCharTime > 0;
+ },
+
+ /**
+ * Returns TRUE if onScan is attached to the given DOM element and FALSE otherwise.
+ *
+ * @param DomElement
+ * @return boolean
+ */
+ isAttachedTo: function(oDomElement) {
+ return (oDomElement.scannerDetectionData !== undefined);
+ }
+ };
+
+ return onScan;
+})));
\ No newline at end of file
diff --git a/node_modules/onscan/onscan.min.js b/node_modules/onscan/onscan.min.js
new file mode 100644
index 0000000..0a7e644
--- /dev/null
+++ b/node_modules/onscan/onscan.min.js
@@ -0,0 +1,5 @@
+/*
+ * onScan.js - scan-events for hardware barcodes scanners in javascript
+ * Version: 1.5.2
+ */
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t()):e.onScan=t()}(this,function(){var d={attachTo:function(e,t){if(void 0!==e.scannerDetectionData)throw new Error("onScan.js is already initialized for DOM element "+e);var n={onScan:function(e,t){},onScanError:function(e){},onKeyProcess:function(e,t){},onKeyDetect:function(e,t){},onPaste:function(e,t){},keyCodeMapper:function(e){return d.decodeKeyEvent(e)},onScanButtonLongPress:function(){},scanButtonKeyCode:!1,scanButtonLongPressTime:500,timeBeforeScanTest:100,avgTimeByChar:30,minLength:6,suffixKeyCodes:[9,13],prefixKeyCodes:[],ignoreIfFocusOn:!1,stopPropagation:!1,preventDefault:!1,captureEvents:!1,reactToKeydown:!0,reactToPaste:!1,singleScanQty:1};return t=this._mergeOptions(n,t),e.scannerDetectionData={options:t,vars:{firstCharTime:0,lastCharTime:0,accumulatedString:"",testTimer:!1,longPressTimeStart:0,longPressed:!1}},!0===t.reactToPaste&&e.addEventListener("paste",this._handlePaste,t.captureEvents),!1!==t.scanButtonKeyCode&&e.addEventListener("keyup",this._handleKeyUp,t.captureEvents),!0!==t.reactToKeydown&&!1===t.scanButtonKeyCode||e.addEventListener("keydown",this._handleKeyDown,t.captureEvents),this},detachFrom:function(e){e.scannerDetectionData.options.reactToPaste&&e.removeEventListener("paste",this._handlePaste),!1!==e.scannerDetectionData.options.scanButtonKeyCode&&e.removeEventListener("keyup",this._handleKeyUp),e.removeEventListener("keydown",this._handleKeyDown),e.scannerDetectionData=void 0},getOptions:function(e){return e.scannerDetectionData.options},setOptions:function(e,t){switch(e.scannerDetectionData.options.reactToPaste){case!0:!1===t.reactToPaste&&e.removeEventListener("paste",this._handlePaste);break;case!1:!0===t.reactToPaste&&e.addEventListener("paste",this._handlePaste)}switch(e.scannerDetectionData.options.scanButtonKeyCode){case!1:!1!==t.scanButtonKeyCode&&e.addEventListener("keyup",this._handleKeyUp);break;default:!1===t.scanButtonKeyCode&&e.removeEventListener("keyup",this._handleKeyUp)}return e.scannerDetectionData.options=this._mergeOptions(e.scannerDetectionData.options,t),this._reinitialize(e),this},decodeKeyEvent:function(e){var t=this._getNormalizedKeyNum(e);switch(!0){case 48<=t&&t<=90:case 106<=t&&t<=111:if(void 0!==e.key&&""!==e.key)return e.key;var n=String.fromCharCode(t);switch(e.shiftKey){case!1:n=n.toLowerCase();break;case!0:n=n.toUpperCase()}return n;case 96<=t&&t<=105:return t-96}return""},simulate:function(e,t){return this._reinitialize(e),Array.isArray(t)?t.forEach(function(e){var t={};"object"!=typeof e&&"function"!=typeof e||null===e?t.keyCode=parseInt(e):t=e;var n=new KeyboardEvent("keydown",t);document.dispatchEvent(n)}):this._validateScanCode(e,t),this},_reinitialize:function(e){var t=e.scannerDetectionData.vars;t.firstCharTime=0,t.lastCharTime=0,t.accumulatedString=""},_isFocusOnIgnoredElement:function(e){var t=e.scannerDetectionData.options.ignoreIfFocusOn;if(!t)return!1;var n=document.activeElement;if(Array.isArray(t)){for(var a=0;at.length*i.avgTimeByChar:c={message:"Receieved code was not entered in time"};break;default:return i.onScan.call(e,t,o),n=new CustomEvent("scan",{detail:{scanCode:t,qty:o}}),e.dispatchEvent(n),d._reinitialize(e),!0}return c.scanCode=t,c.scanDuration=s-r,c.avgTimeByChar=i.avgTimeByChar,c.minLength=i.minLength,i.onScanError.call(e,c),n=new CustomEvent("scanError",{detail:c}),e.dispatchEvent(n),d._reinitialize(e),!1},_mergeOptions:function(e,t){var n,a={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=e[n]);for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(a[n]=t[n]);return a},_getNormalizedKeyNum:function(e){return e.which||e.keyCode},_handleKeyDown:function(e){var t=d._getNormalizedKeyNum(e),n=this.scannerDetectionData.options,a=this.scannerDetectionData.vars,i=!1;if(!1!==n.onKeyDetect.call(this,t,e)&&!d._isFocusOnIgnoredElement(this))if(!1===n.scanButtonKeyCode||t!=n.scanButtonKeyCode){switch(!0){case a.firstCharTime&&-1!==n.suffixKeyCodes.indexOf(t):e.preventDefault(),e.stopImmediatePropagation(),i=!0;break;case!a.firstCharTime&&-1!==n.prefixKeyCodes.indexOf(t):e.preventDefault(),e.stopImmediatePropagation(),i=!1;break;default:var o=n.keyCodeMapper.call(this,e);if(null===o)return;a.accumulatedString+=o,n.preventDefault&&e.preventDefault(),n.stopPropagation&&e.stopImmediatePropagation(),i=!1}a.firstCharTime||(a.firstCharTime=Date.now()),a.lastCharTime=Date.now(),a.testTimer&&clearTimeout(a.testTimer),i?(d._validateScanCode(this,a.accumulatedString),a.testTimer=!1):a.testTimer=setTimeout(d._validateScanCode,n.timeBeforeScanTest,this,a.accumulatedString),n.onKeyProcess.call(this,o,e)}else a.longPressed||(a.longPressTimer=setTimeout(n.onScanButtonLongPress,n.scanButtonLongPressTime,this),a.longPressed=!0)},_handlePaste:function(e){var t=this.scannerDetectionData.options,n=this.scannerDetectionData.vars,a=(event.clipboardData||window.clipboardData).getData("text");d._isFocusOnIgnoredElement(this)||(e.preventDefault(),t.stopPropagation&&e.stopImmediatePropagation(),t.onPaste.call(this,a,event),n.firstCharTime=0,n.lastCharTime=0,d._validateScanCode(this,a))},_handleKeyUp:function(e){d._isFocusOnIgnoredElement(this)||d._getNormalizedKeyNum(e)==this.scannerDetectionData.options.scanButtonKeyCode&&(clearTimeout(this.scannerDetectionData.vars.longPressTimer),this.scannerDetectionData.vars.longPressed=!1)},isScanInProgressFor:function(e){return 0= 48 && iCode <= 90: // numbers and letters
+ case iCode >= 106 && iCode <= 111: // operations on numeric keypad (+, -, etc.)
+ if (oEvent.key !== undefined && oEvent.key !== '') {
+ return oEvent.key;
+ }
+
+ var sDecoded = String.fromCharCode(iCode);
+ switch (oEvent.shiftKey) {
+ case false: sDecoded = sDecoded.toLowerCase(); break;
+ case true: sDecoded = sDecoded.toUpperCase(); break;
+ }
+ return sDecoded;
+ case iCode >= 96 && iCode <= 105: // numbers on numeric keypad
+ return 0+(iCode-96);
+ }
+ return '';
+ },
+
+ /**
+ * Simulates a scan of the provided code.
+ *
+ * The scan code can be defined as
+ * - a string - in this case no keyCode decoding is done and the code is merely validated
+ * against constraints like minLenght, etc.
+ * - an array of keyCodes (e.g. `[70,71,80]`) - will produce `keydown` events with corresponding
+ * `keyCode` properties. NOTE: these events will have empty `key` properties, so decoding may
+ * yield different results than with native events.
+ * - an array of objects (e.g. `[{keyCode: 70, key: "F", shiftKey: true}, {keyCode: 71, key: "g"}]`) -
+ * this way almost any event can be simulated, but it's a lot of work to do.
+ *
+ * @param DomElement oDomElement
+ * @param string|array mStringOrArray
+ * @return self
+ */
+ simulate: function(oDomElement, mStringOrArray){
+ this._reinitialize(oDomElement);
+ if (Array.isArray(mStringOrArray)){
+ mStringOrArray.forEach(function(mKey){
+ var oEventProps = {};
+ if( (typeof mKey === "object" || typeof mKey === 'function') && (mKey !== null) ) {
+ oEventProps = mKey;
+ } else {
+ oEventProps.keyCode = parseInt(mKey);
+ }
+ var oEvent = new KeyboardEvent('keydown', oEventProps);
+ document.dispatchEvent(oEvent);
+ })
+ } else {
+ this._validateScanCode(oDomElement, mStringOrArray);
+ }
+ return this;
+ },
+
+ /**
+ * @private
+ * @param DomElement oDomElement
+ * @return void
+ */
+ _reinitialize: function(oDomElement){
+ var oVars = oDomElement.scannerDetectionData.vars;
+ oVars.firstCharTime = 0;
+ oVars.lastCharTime = 0;
+ oVars.accumulatedString = '';
+ return;
+ },
+
+ /**
+ * @private
+ * @param DomElement oDomElement
+ * @return boolean
+ */
+ _isFocusOnIgnoredElement: function(oDomElement){
+
+ var ignoreSelectors = oDomElement.scannerDetectionData.options.ignoreIfFocusOn;
+
+ if(!ignoreSelectors){
+ return false;
+ }
+
+ var oFocused = document.activeElement;
+
+ // checks if ignored element is an array, and if so it checks if one of the elements of it is an active one
+ if (Array.isArray(ignoreSelectors)){
+ for(var i=0; i (sScanCode.length * oOptions.avgTimeByChar)):
+ oScanError = {
+ message: "Receieved code was not entered in time"
+ };
+ break;
+
+ // if a code was not filtered out earlier it is valid
+ default:
+ oOptions.onScan.call(oDomElement, sScanCode, iSingleScanQty);
+ oEvent = new CustomEvent(
+ 'scan',
+ {
+ detail: {
+ scanCode: sScanCode,
+ qty: iSingleScanQty
+ }
+ }
+ );
+ oDomElement.dispatchEvent(oEvent);
+ onScan._reinitialize(oDomElement);
+ return true;
+ }
+
+ // If an error occurred (otherwise the method would return earlier) create an object for errordetection
+ oScanError.scanCode = sScanCode;
+ oScanError.scanDuration = iLastCharTime - iFirstCharTime;
+ oScanError.avgTimeByChar = oOptions.avgTimeByChar;
+ oScanError.minLength = oOptions.minLength;
+
+ oOptions.onScanError.call(oDomElement, oScanError);
+
+ oEvent = new CustomEvent(
+ 'scanError',
+ {detail: oScanError}
+ );
+ oDomElement.dispatchEvent(oEvent);
+
+ onScan._reinitialize(oDomElement);
+ return false;
+ },
+
+ /**
+ * @private
+ * @param Object oDefaults
+ * @param Object oOptions
+ * @return Object
+ */
+ _mergeOptions: function(oDefaults, oOptions){
+ var oExtended = {};
+ var prop;
+ for (prop in oDefaults){
+ if (Object.prototype.hasOwnProperty.call(oDefaults, prop)){
+ oExtended[prop] = oDefaults[prop];
+ }
+ }
+ for (prop in oOptions){
+ if (Object.prototype.hasOwnProperty.call(oOptions, prop)){
+ oExtended[prop] = oOptions[prop];
+ }
+ }
+ return oExtended;
+ },
+
+ /**
+ * @private
+ * @param KeyboardEvent e
+ * @return int
+ * @see https://www.w3schools.com/jsref/event_key_keycode.asp
+ */
+ _getNormalizedKeyNum: function(e){
+ return e.which || e.keyCode;
+ },
+
+
+ /**
+ * @private
+ * @param KeyboardEvent e
+ * @return void
+ */
+ _handleKeyDown: function(e){
+ var iKeyCode = onScan._getNormalizedKeyNum(e);
+ var oOptions = this.scannerDetectionData.options;
+ var oVars = this.scannerDetectionData.vars;
+ var bScanFinished = false;
+
+ if (oOptions.onKeyDetect.call(this, iKeyCode, e) === false) {
+ return;
+ }
+
+ if (onScan._isFocusOnIgnoredElement(this)){
+ return;
+ }
+
+ // If it's just the button of the scanner, ignore it and wait for the real input
+ if(oOptions.scanButtonKeyCode !== false && iKeyCode==oOptions.scanButtonKeyCode) {
+
+ // if the button was first pressed, start a timeout for the callback, which gets interrupted if the scanbutton gets released
+ if (!oVars.longPressed){
+ oVars.longPressTimer = setTimeout( oOptions.onScanButtonLongPress, oOptions.scanButtonLongPressTime, this);
+ oVars.longPressed = true;
+ }
+
+ return;
+ }
+
+ switch(true){
+ // If it's not the first character and we encounter a terminating character, trigger scan process
+ case (oVars.firstCharTime && oOptions.suffixKeyCodes.indexOf(iKeyCode)!==-1):
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ bScanFinished=true;
+ break;
+
+ // If it's the first character and we encountered one of the starting characters, don't process the scan
+ case (!oVars.firstCharTime && oOptions.prefixKeyCodes.indexOf(iKeyCode)!==-1):
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ bScanFinished=false;
+ break;
+
+ // Otherwise, just add the character to the scan string we're building
+ default:
+ var character = oOptions.keyCodeMapper.call(this, e);
+ if (character === null){
+ return;
+ }
+ oVars.accumulatedString += character;
+
+ if (oOptions.preventDefault) {
+ e.preventDefault();
+ }
+ if (oOptions.stopPropagation) {
+ e.stopImmediatePropagation();
+ }
+
+ bScanFinished=false;
+ break;
+ }
+
+ if(!oVars.firstCharTime){
+ oVars.firstCharTime=Date.now();
+ }
+
+ oVars.lastCharTime=Date.now();
+
+ if(oVars.testTimer){
+ clearTimeout(oVars.testTimer);
+ }
+
+ if(bScanFinished){
+ onScan._validateScanCode(this, oVars.accumulatedString);
+ oVars.testTimer=false;
+ } else {
+ oVars.testTimer=setTimeout(onScan._validateScanCode, oOptions.timeBeforeScanTest, this, oVars.accumulatedString);
+ }
+
+ oOptions.onKeyProcess.call(this, character, e);
+ return;
+ },
+
+ /**
+ * @private
+ * @param Event e
+ * @return void
+ */
+ _handlePaste: function(e){
+
+ var oOptions = this.scannerDetectionData.options;
+ var oVars = this.scannerDetectionData.vars;
+ var sPasteString = (event.clipboardData || window.clipboardData).getData('text');
+
+ // if the focus is on an ignored element, abort
+ if (onScan._isFocusOnIgnoredElement(this)){
+ return;
+ }
+
+ e.preventDefault();
+
+ if (oOptions.stopPropagation) {
+ e.stopImmediatePropagation();
+ }
+
+ oOptions.onPaste.call(this, sPasteString, event);
+
+ oVars.firstCharTime = 0;
+ oVars.lastCharTime = 0;
+
+ // validate the string
+ onScan._validateScanCode(this, sPasteString);
+ return;
+ },
+
+ /**
+ * @private
+ * @param KeyboardEvent e
+ * @return void
+ */
+ _handleKeyUp: function(e){
+ // if the focus is on an ignored element, abort
+ if (onScan._isFocusOnIgnoredElement(this)){
+ return;
+ }
+
+ var iKeyCode = onScan._getNormalizedKeyNum(e);
+
+ // if hardware key is not being pressed anymore stop the timeout and reset
+ if (iKeyCode == this.scannerDetectionData.options.scanButtonKeyCode){
+ clearTimeout(this.scannerDetectionData.vars.longPressTimer);
+ this.scannerDetectionData.vars.longPressed = false;
+ }
+ return;
+ },
+
+ /**
+ * Returns TRUE the scanner is currently in the middle of a scan sequence.
+ *
+ * @param DomElement
+ * @return boolean
+ */
+ isScanInProgressFor: function(oDomElement) {
+ return oDomElement.scannerDetectionData.vars.firstCharTime > 0;
+ },
+
+ /**
+ * Returns TRUE if onScan is attached to the given DOM element and FALSE otherwise.
+ *
+ * @param DomElement
+ * @return boolean
+ */
+ isAttachedTo: function(oDomElement) {
+ return (oDomElement.scannerDetectionData !== undefined);
+ }
+ };
+
+ return onScan;
+})));
\ No newline at end of file
diff --git a/src/main/webapp/resources/js/onscan.min.js b/src/main/webapp/resources/js/onscan.min.js
new file mode 100644
index 0000000..0a7e644
--- /dev/null
+++ b/src/main/webapp/resources/js/onscan.min.js
@@ -0,0 +1,5 @@
+/*
+ * onScan.js - scan-events for hardware barcodes scanners in javascript
+ * Version: 1.5.2
+ */
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t()):e.onScan=t()}(this,function(){var d={attachTo:function(e,t){if(void 0!==e.scannerDetectionData)throw new Error("onScan.js is already initialized for DOM element "+e);var n={onScan:function(e,t){},onScanError:function(e){},onKeyProcess:function(e,t){},onKeyDetect:function(e,t){},onPaste:function(e,t){},keyCodeMapper:function(e){return d.decodeKeyEvent(e)},onScanButtonLongPress:function(){},scanButtonKeyCode:!1,scanButtonLongPressTime:500,timeBeforeScanTest:100,avgTimeByChar:30,minLength:6,suffixKeyCodes:[9,13],prefixKeyCodes:[],ignoreIfFocusOn:!1,stopPropagation:!1,preventDefault:!1,captureEvents:!1,reactToKeydown:!0,reactToPaste:!1,singleScanQty:1};return t=this._mergeOptions(n,t),e.scannerDetectionData={options:t,vars:{firstCharTime:0,lastCharTime:0,accumulatedString:"",testTimer:!1,longPressTimeStart:0,longPressed:!1}},!0===t.reactToPaste&&e.addEventListener("paste",this._handlePaste,t.captureEvents),!1!==t.scanButtonKeyCode&&e.addEventListener("keyup",this._handleKeyUp,t.captureEvents),!0!==t.reactToKeydown&&!1===t.scanButtonKeyCode||e.addEventListener("keydown",this._handleKeyDown,t.captureEvents),this},detachFrom:function(e){e.scannerDetectionData.options.reactToPaste&&e.removeEventListener("paste",this._handlePaste),!1!==e.scannerDetectionData.options.scanButtonKeyCode&&e.removeEventListener("keyup",this._handleKeyUp),e.removeEventListener("keydown",this._handleKeyDown),e.scannerDetectionData=void 0},getOptions:function(e){return e.scannerDetectionData.options},setOptions:function(e,t){switch(e.scannerDetectionData.options.reactToPaste){case!0:!1===t.reactToPaste&&e.removeEventListener("paste",this._handlePaste);break;case!1:!0===t.reactToPaste&&e.addEventListener("paste",this._handlePaste)}switch(e.scannerDetectionData.options.scanButtonKeyCode){case!1:!1!==t.scanButtonKeyCode&&e.addEventListener("keyup",this._handleKeyUp);break;default:!1===t.scanButtonKeyCode&&e.removeEventListener("keyup",this._handleKeyUp)}return e.scannerDetectionData.options=this._mergeOptions(e.scannerDetectionData.options,t),this._reinitialize(e),this},decodeKeyEvent:function(e){var t=this._getNormalizedKeyNum(e);switch(!0){case 48<=t&&t<=90:case 106<=t&&t<=111:if(void 0!==e.key&&""!==e.key)return e.key;var n=String.fromCharCode(t);switch(e.shiftKey){case!1:n=n.toLowerCase();break;case!0:n=n.toUpperCase()}return n;case 96<=t&&t<=105:return t-96}return""},simulate:function(e,t){return this._reinitialize(e),Array.isArray(t)?t.forEach(function(e){var t={};"object"!=typeof e&&"function"!=typeof e||null===e?t.keyCode=parseInt(e):t=e;var n=new KeyboardEvent("keydown",t);document.dispatchEvent(n)}):this._validateScanCode(e,t),this},_reinitialize:function(e){var t=e.scannerDetectionData.vars;t.firstCharTime=0,t.lastCharTime=0,t.accumulatedString=""},_isFocusOnIgnoredElement:function(e){var t=e.scannerDetectionData.options.ignoreIfFocusOn;if(!t)return!1;var n=document.activeElement;if(Array.isArray(t)){for(var a=0;at.length*i.avgTimeByChar:c={message:"Receieved code was not entered in time"};break;default:return i.onScan.call(e,t,o),n=new CustomEvent("scan",{detail:{scanCode:t,qty:o}}),e.dispatchEvent(n),d._reinitialize(e),!0}return c.scanCode=t,c.scanDuration=s-r,c.avgTimeByChar=i.avgTimeByChar,c.minLength=i.minLength,i.onScanError.call(e,c),n=new CustomEvent("scanError",{detail:c}),e.dispatchEvent(n),d._reinitialize(e),!1},_mergeOptions:function(e,t){var n,a={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(a[n]=e[n]);for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(a[n]=t[n]);return a},_getNormalizedKeyNum:function(e){return e.which||e.keyCode},_handleKeyDown:function(e){var t=d._getNormalizedKeyNum(e),n=this.scannerDetectionData.options,a=this.scannerDetectionData.vars,i=!1;if(!1!==n.onKeyDetect.call(this,t,e)&&!d._isFocusOnIgnoredElement(this))if(!1===n.scanButtonKeyCode||t!=n.scanButtonKeyCode){switch(!0){case a.firstCharTime&&-1!==n.suffixKeyCodes.indexOf(t):e.preventDefault(),e.stopImmediatePropagation(),i=!0;break;case!a.firstCharTime&&-1!==n.prefixKeyCodes.indexOf(t):e.preventDefault(),e.stopImmediatePropagation(),i=!1;break;default:var o=n.keyCodeMapper.call(this,e);if(null===o)return;a.accumulatedString+=o,n.preventDefault&&e.preventDefault(),n.stopPropagation&&e.stopImmediatePropagation(),i=!1}a.firstCharTime||(a.firstCharTime=Date.now()),a.lastCharTime=Date.now(),a.testTimer&&clearTimeout(a.testTimer),i?(d._validateScanCode(this,a.accumulatedString),a.testTimer=!1):a.testTimer=setTimeout(d._validateScanCode,n.timeBeforeScanTest,this,a.accumulatedString),n.onKeyProcess.call(this,o,e)}else a.longPressed||(a.longPressTimer=setTimeout(n.onScanButtonLongPress,n.scanButtonLongPressTime,this),a.longPressed=!0)},_handlePaste:function(e){var t=this.scannerDetectionData.options,n=this.scannerDetectionData.vars,a=(event.clipboardData||window.clipboardData).getData("text");d._isFocusOnIgnoredElement(this)||(e.preventDefault(),t.stopPropagation&&e.stopImmediatePropagation(),t.onPaste.call(this,a,event),n.firstCharTime=0,n.lastCharTime=0,d._validateScanCode(this,a))},_handleKeyUp:function(e){d._isFocusOnIgnoredElement(this)||d._getNormalizedKeyNum(e)==this.scannerDetectionData.options.scanButtonKeyCode&&(clearTimeout(this.scannerDetectionData.vars.longPressTimer),this.scannerDetectionData.vars.longPressed=!1)},isScanInProgressFor:function(e){return 0