Namespace: scanning

airlock.scanning

Provides various functions for working with the hardware barcode scanner.
Source:

Members

(static, readonly) PopulationMethod :number

Enum for scanning population method values.
Type:
  • number
Properties:
Name Type Description
NONE number Population does not occur.
SET_TEXT number An HTML text input's value is set to the value of scanned data.
EMULATE_KEYBOARD number Scanned text and pre and post-scan keys are sent as keyboard presses.
Source:

Methods

(static) beginScan()

Simulates pressing hardware trigger for the barcode reader.
Source:

(static) endScan()

Ends the simulated pressing of the hardware trigger.
Source:
See:

(static) getApiVersion() → {string}

Gets the API version of the device SDK. This value is retrieved from the device SDK itself.
Source:
Returns:
The API version reported by the device SDK.
Type
string

(static) getConfiguration() → {object}

Returns the scanner configuration as an object. Fields can be set, and the configuration can be applied using setConfiguration.
Source:
See:
Returns:
The reader configuration.
Type
object
Example
var config = airlock.scanning.getConfiguration();
// Displays false
alert(config.displayMode);

(static) getDecoders() → {Promise.<Array.<object>>}

Retrieves all decoders via a Promise.
Source:
Returns:
A list of all decoders.
Type
Promise.<Array.<object>>
Example
airlock.scanning.getDecoders()
.then(function (decoders) {
		var text = "";
		for (let i = 0; i < decoders.length; i++) {
			text += decoders[i].name + ", ";
		}
		alert(text);
	}).catch(function (error) {
		alert(`Error: ${error}`);
	});

(static) getDecoderWithName(decoderName) → {object}

Retrieves the decoder with the specified name. Device makers use different names for decoders. If you are uncertain of the name, use getDecoderWithNativeId instead.
Parameters:
Name Type Description
decoderName string The name of the decoder. Cannot be null.
Source:
See:
Returns:
The decoder object that may allow you to modify its state.
Type
object
Example
var decoder = airlock.scanning.getDecoderWithName('codabar');
// Displays 'codabar'
alert(decoder.name);

(static) getDecoderWithNativeId(id) → {object}

Retrieves the decoder with the specified native identifier, corresponding to the ID within the device SDK.
Parameters:
Name Type Description
id int The id of the decoder. Cannot be null.
Source:
See:
Returns:
The decoder object that may allow you to modify its state.
Type
object
Example
var codabarDecoder = airlock.scanning.getDecoderWithNativeId(71);
// Displays 'codabar'
alert(decoder.name);

(static) getFirmwareVersion() → {string}

Gets the reader firmware version as reported by the device SDK.
Source:
Returns:
The reader firmware version as reported by the device SDK.
Type
string

(static) getPopulationMethod() → {airlock.scanning.PopulationMethod}

Returns a value indicating whether the keyboard wedge is enabled and whether it is set to set the HTML element's value or emulate the keyboard.
Source:
Returns:
The current population method.
Type
airlock.scanning.PopulationMethod

(static) getPostScanKeys() → {string}

Gets the keys that are invoked or inserted after a barcode is scanned.
Source:
Returns:
The space delimited list of Android key codes.
Type
string

(static) getPreScanKeys() → {string}

Gets the keys that are invoked or inserted when a barcode is scanned.
Source:
Returns:
The space delimited list of Android key codes.
Type
string

(static) getReaderModel() → {string}

Gets the reader model as reported by the device SDK.
Source:
Returns:
The reader type as reported by the device SDK.
Type
string

(static) isScannerActive() → {boolean}

Gets a value indicating whether the scanner is ready.
Source:
Returns:
true if the scanner is started and usable; false otherwise.
Type
boolean
Example
var active = airlock.scanning.isScannerActive();
// Display true if active; false otherwise.
alert(active);

(static) resetConfiguration() → {Promise.<boolean>}

Resets the scanner configuration. Resets the current devices configuration and removes any settings stored for the barcode reader, including decoder settings and so forth. An app restart may be required by some device brands.
Source:
Returns:
When resolved indicates the reset is complete. If the resolve value is true, the new configuration has been applied. If false, an app restart is required.
Type
Promise.<boolean>
Example
airlock.scanning.resetConfiguration()
.then(function (defaultSettingsApplied) {
		alert("Configuration reset."
			+ (defaultSettingsApplied ? "" : "Restart required."));
}).catch(function (e) {
		alert("Error: " + e);
});

(static) setConfiguration(configuration)

Applies the specified scanner configuration to the device.
Parameters:
Name Type Description
configuration object The barcode reader configuration.
Source:
Throws:
Thrown if the device SDK is not supported.
Type
ScriptCallException
Example
var config = airlock.scanning.getConfiguration();
config.displayMode = true;
airlock.scanning.setConfiguration(config);

(static) setDecoder(decoder)

Sets the values of a decoder.
Parameters:
Name Type Description
decoder object The decoder object. Cannot be null.
Source:
Throws:
If the device SDK is not supported.
Type
Exception
Example
var codabarDecoder = airlock.scanning.getDecoderWithNativeId(71);
codabarDecoder.enabled = true;
codabarDecoder.notisEditingType = 1;
codabarDecoder.length1 = 10;
airlock.scanning.setDecoder(codabarDecoder);

(static) setPopulationMethod(populationMethod)

Sets the population method used when a barcode is scanned.
Parameters:
Name Type Description
populationMethod airlock.scanning.PopulationMethod The population method to use.
Source:

(static) setPostScanKeys(keys)

Sets the keys that are invoked or inserted after a barcode is scanned.
Parameters:
Name Type Description
keys string The space delimited list of Android key codes.
Source:

(static) setPreScanKeys(keys)

Sets the keys that are invoked or inserted when a barcode is scanned.
Parameters:
Name Type Description
keys string The space delimited list of Android key codes.
Source:

(static) setScannerActive(active)

Starts or stops the scanner.
Parameters:
Name Type Description
active boolean If true the scanner is placed in a started state. If false, the scanner is stopped.
Source:

Type Definitions

ScanErrorEventArgs

Properties:
Name Type Description
errorInfo object SDK dependent information regarding the error.
timestamp Date Indicates when the scan failed.
Source:

ScanEventArgs

Properties:
Name Type Description
rawDataInBase64 string The raw barcode data in Base64 format (if available).
text string The formatted barcode data that may be modified by an event handler before it is placed in a text field.
barcodeText string The original read-only barcode text.
nativeSymbologyId string | Number The identifier used in the device manufacturer's SDK for a symbology.
symbologyName string The symbology name, such as 'Code11'.
sourceScanner string The reader ID (if available).
insertMode number Replace = 0, Append = 1, Prepend = 2. Determines the behaviour of the barcode wedge and whether it overwrites, appends, or prepends a text field with the scanned text.
moveToNextField boolean If true, after the scan, the browser will attempt to move to the next field on the page.
populationMethod airlock.scanning.PopulationMethod Indicates whether scanned data is placed in a field, and if so, how it is placed.
timestamp Date Indicates when the scan occured.
Source:

Events

onScan

onScan Event. Is raised when the barcode reader receives scan data. To subscribe to the event use: airlock.scanning.onScan.addListener(aFunction) To unsubscribe to the event use: airlock.scanning.onScan.removeListener(aFunction)
Type:
Source:
Example
// Subscribe
airlock.scanning.onScan.addListener(handleScan);

function handleScan(args) {
		// Displays the barcode data.
		alert(args.text);
}
// Unsubscribe
airlock.scanning.onScan.removeListener(handleScan);

onScanError

onScanError Event. Is raised when the barcode reader fails to scan a barcode. To subscribe to the event use: airlock.scanning.onScanError.addListener(handleScanError) To unsubscribe to the event use: airlock.scanning.onScanError.removeListener(handleScanError)
Type:
Source:
Examples
// Subscribe
airlock.scanning.onScanError.addListener(handleScanError);

function handleScanError(args) {
		// Display error info (if exists)
		alert(args.errorInfo);
}
// Unsubscribe
airlock.scanning.onScanError.removeListener(handleScanError);