D028868 CR1500 CR1100 CR2700 JavaScript Programming Guide User Manual Page 12 of 41
The Code Corporation
12393 South Gateway Park Place, Suite 600, Draper, UT 84020
+1 (801) 495-2200
FAX +1 (801) 495-0280
reader.onPowerChange(int mode)
The reader.onPowerChange property is called when the reader requests permission to
change between active (0), standby (1), sleep (2), and off (3) modes. The user can prevent the
mode from changing by returning “false”, or can accept the change by returning “true”.
Example:
reader.onPowerChange = function(mode)
{
if(mode == 2)
{
comm.sendText(“No Sleep For You”);
return false;
}
return true;
}
reader.onBatteryChange(void)
The reader.onBatteryChange property is not yet implemented.
reader.onTrigger(triggerButton, buttonAction)(CR2700)
The reader.onTrigger property allows the user to intercept trigger presses, take actions
to handle the trigger events, and then either absorb the trigger event (return true), or allow
the reader to process the event after JavaScript does its handling of the event (return false).
This allows a wide variety of actions to be programmed for each time a trigger button is
pressed.
Example:
// constants for reader.onTrigger
const mainTrigger = 0;
const frontTrigger = 1;
const rearTrigger = 2;
const triggerPress = 0;
const triggerHold = 1; // hold is pressed for 700 mS
const triggerRelease = 2;
reader.onTrigger = function(Trigger, Type)
{
if( Trigger == frontTrigger )
reader.configure(“CDOPG”);
if(Trigger == rearTrigger && Type == triggerHold)
reader.configure(“CFR”);
return true;
}
reader.onDecodeAttempt(count)
The reader.onDecodeAttempt function is called anytime there is a decode attempt
made, including times that there hasn’t been a valid decode. It takes in an integer that
represents the number of successful decodes that happened during the decode attempt.
Example:
reader.onDecodeAttempt = function(mode)