1 /** 2 * Used for helpful debugging info. 3 * 4 * @type Boolean Weather to show events when bad stuff happens. 5 */ 6 Debugging = true; 7 /** 8 * ScannerDevice library to listen and set options to the Linea device. Note that you must then register the object after it's been 9 * constructed or no events will be passed to function. 10 * 11 * @param {Object} mappings If you wish to set listeners, you do it here by passing the listener function here. 12 * @example DeviceObject = ScannerDevice({ 13 barcodeData: function (data, bar_type){ 14 alert('Barcode scanned with with data: '+data+' and of type: '+bar_type); 15 }, 16 magneticCardData: function (track1, track2, track3){ 17 alert('Card read with following data: '+track1+'\n'+track2+'\n'+track3); 18 }, 19 magneticCardRawData: function (data){ 20 alert('Raw data read from card reader: '+data); 21 }, 22 buttonPressed: function (button){ 23 // Currently device only registers 1 button. 24 alert('Button was pressed'); 25 }, 26 buttonReleased: function (button){ 27 // Currently device only registers 1 button. 28 alert('Button was released'); 29 }, 30 connectionState: function (state){ 31 alert('Scanner is now in state: '+state); 32 } 33 }); 34 ScannerDevice.registerListener(Device); 35 * @namespace ScannerDevice 36 * @constructor 37 */ 38 ScannerDevice = function (mappings){ 39 /* BEGIN PRIVATE VARS */ 40 /** 41 * Used to save memory by using the same ref for every empty function 42 * instead of createing a new instance every time 43 * @ignore 44 */ 45 var emptyFn = function (){}; 46 /** 47 * Used as a default callback if none is specified. Used only for error 48 * callback. 49 * 50 * @param {Array} params Error returned by cordova or scanner. 51 * @ignore 52 */ 53 var emptyErrFn = function (params){ 54 if(Debugging) 55 alert(params); 56 }; 57 /* END PRIVATE VARS */ 58 /** 59 * Helper function to return the constant name of a barcode by it's ID. 60 * *Note this function only works for non extended barcodes. 61 * 62 * @param {Int} barcode_id Barcode ID. 63 * @returns {String|Null} Constant name of barcode if exists. 64 */ 65 this.getBarcodeConstName = function(barcode_id){ 66 barcode_id = parseInt(barcode_id); 67 var i; 68 for(i in ScannerDevice.CONSTANTS.BAR_TYPES){ 69 if(ScannerDevice.CONSTANTS.BAR_TYPES[i] == barcode_id){ 70 return i; 71 } 72 } 73 return null; 74 }; 75 /** 76 * @see ScannerDevice#unregisterListener 77 */ 78 this.destroy = function (){ 79 ScannerDevice.unregisterListener(this); 80 }; 81 /** 82 * Sends a command though cordova to the Linea Device. See each individual functions 83 * for available commands 84 * 85 * @param {String} command Command to send to device. 86 * @param {Array} args Arguments to send along with command. 87 * @param {Function} callback Success callback function. Callback contains 1 arguments containing an array of arguments. 88 * @param {Function} errorCallback Error callback function. Callback contains 1 arguments containing an array of arguments. 89 */ 90 this.sendCommand = function (command, args, callback, errorCallback){ 91 switch(command){ 92 case 'enableBarcode': 93 ScannerDevice.lastSettings.barcodeStatus[parseInt(args[0])] = args[1] ? true : false; 94 break; 95 case 'playSound': break; 96 case 'startScan': 97 ScannerDevice.LAZER_ON = true; 98 break; 99 case 'stopScan': 100 ScannerDevice.LAZER_ON = false; 101 break; 102 case 'setScanMode': 103 ScannerDevice.lastSettings.SCAN_MODE = parseInt(args[0]); 104 break; 105 case 'setScanBeep': 106 ScannerDevice.lastSettings.SCAN_BEEP_ENABLED = args[0] ? true : false; 107 ScannerDevice.lastSettings.SCAN_BEEP = args[2]; 108 break; 109 case 'setScanButtonMode': 110 ScannerDevice.lastSettings.BUTTON_ENABLED = args[0] ? true : false; 111 break; 112 case 'setMSCardDataMode': 113 ScannerDevice.lastSettings.MS_MODE = parseInt(args[0]); 114 break; 115 case 'setBarcodeTypeMode': 116 ScannerDevice.lastSettings.BARCODE_TYPE = parseInt(args[0]); 117 break; 118 case 'getBatteryCapacity': break; 119 case 'getBatteryVoltage': break; 120 case 'isBarcodeEnabled': break; 121 case 'isBarcodeSupported': break; 122 case 'getMSCardDataMode': break; 123 case 'getCharging': break; 124 case 'setCharging': 125 ScannerDevice.lastSettings.CHARGING = args[0] ? true : false; 126 break; 127 case 'getSyncButtonMode': break; 128 case 'msProcessFinancialCard': break; 129 case 'getBarcodeTypeMode': break; 130 case 'barcodeEnginePowerControl': 131 ScannerDevice.lastSettings.BARCODE_ENGINE_POWER = args[0] ? true : false; 132 break; 133 case 'barcodeType2Text': break; 134 case 'getConnectionState': break; 135 } 136 if(ScannerDevice.allowedFunctions.indexOf(command) == -1){ 137 if(Debugging) 138 alert('Command not found: '+command); 139 return false; 140 } 141 cordova.exec(callback || emptyFn, errorCallback || emptyErrFn, "LineaDevice", command, args || []); 142 return true; 143 }; 144 /** 145 * Enables or Disables a single barcode by it's ID. 146 * @param {Int} Integer of barcode enableing/disableing (see ScannerDevice.CONSTANTS.BAR_TYPES for mappings). 147 * @param {Boolean} enabled To enable or disable barcode. 148 */ 149 this.enableBarcode = function (barcode, enabled){ 150 this.sendCommand('enableBarcode', [barcode, enabled]); 151 }; 152 /** 153 * Plays a sound from the linea device. 154 * 155 * @param {Array} sounds Sound to play. This can be in the following formats: [frequency,duration,frequency,duration,...] or [[frequency,duration], [frequency,duration], ...] or [{frequency: xxx, duration: xxx}, {frequency: xxx, duration: xxx}, ...] 156 * Note: This argument cannot exceed 5 sounds at a time (10 array elements). 157 */ 158 this.playSound = function (sounds){ 159 if(!(sounds instanceof Array)){ 160 return false; 161 } 162 var newSounds = []; 163 for(var i=0;i<sounds.length;i++){ 164 if(sounds[i] instanceof Array){ 165 newSounds.push(parseInt(sounds[i][0] || 0)); 166 newSounds.push(parseInt(sounds[i][1] || 0)); 167 }else if(sounds[i] instanceof Object){ 168 newSounds.push(parseInt(sounds[i].frequency || 0)); 169 newSounds.push(parseInt(sounds[i].duration || 0)); 170 }else{ 171 newSounds.push(parseInt(sounds[i] || 0)); 172 newSounds.push(parseInt(sounds[i+1] || 0)); 173 i++; 174 } 175 } 176 this.sendCommand('playSound', [100, newSounds]); 177 }; 178 /** 179 * Starts the scanner on device. 180 */ 181 this.startScan = function (){ 182 this.sendCommand('startScan'); 183 }; 184 /** 185 * Stops the scanner on device. (if scanning) 186 */ 187 this.stopScan = function (){ 188 this.sendCommand('stopScan'); 189 }; 190 /** 191 * Sets if the scanner will remain active after scanning barcode. 192 * 193 * @param {Int} mode Mode to scan in. See: ScannerDevice.CONSTANTS.MODE_* 194 */ 195 this.setScanMode = function (mode){ 196 this.sendCommand('setScanMode', [mode]); 197 }; 198 /** 199 * Sets the beep for when a barcode is scanned.@argument 200 * 201 * @param {Boolean} enabled Weather scanner beep is enabled or not. 202 * @param {Array} See ScannerLibrary#playSound for more info. 203 */ 204 this.setScanBeep = function (enabled, sounds){ 205 if(!sounds instanceof Array){ 206 return false; 207 } 208 var newSounds = []; 209 for(var i=0;i<sounds.length;i++){ 210 if(sounds[i] instanceof Array){ 211 newSounds.push(parseInt(sounds[i][0] || 0)); 212 newSounds.push(parseInt(sounds[i][1] || 0)); 213 }else if(sounds[i] instanceof Object){ 214 newSounds.push(parseInt(sounds[i].frequency || 0)); 215 newSounds.push(parseInt(sounds[i].duration || 0)); 216 }else{ 217 newSounds.push(parseInt(sounds[i] || 0)); 218 newSounds.push(parseInt(sounds[i+1] || 0)); 219 i++; 220 } 221 } 222 this.sendCommand('setScanBeep', [enabled ? true : false, 100, newSounds]); 223 }; 224 /** 225 * Sets if the button is enabled or disabled on the scanner. 226 * 227 * @param {Boolean} enabled Weather to enable or disable the button. 228 */ 229 this.setScanButtonMode = function (enabled){ 230 this.sendCommand('setScanButtonMode', [enabled ? true : false]); 231 }; 232 /** 233 * Sets the mode for the card swipper. 234 * 235 * @param {Int} Mode to put the swipper in. See: ScannerDevice.CONSTANTS.MS_* for availale options. 236 */ 237 this.setMSCardDataMode = function (mode){ 238 this.sendCommand('setScanButtonMode', [mode]); 239 }; 240 /** 241 * Sets the mode to receive the barcodes in. 242 * 243 * @param {Int} type The mode to receive the barcodes in. See: ScannerDevice.CONSTANTS.BARCODE_TYPE_* 244 */ 245 this.setBarcodeTypeMode = function (type){ 246 this.sendCommand('setBarcodeTypeMode', [type]); 247 }; 248 /** 249 * Retrieves the battery capacity in percent of Linea device. 250 * @param {Function} callback Callback to execute after info is received. Example: function (params) { var percent = params[0]; } 251 */ 252 this.getBatteryCapacity = function (callback){ 253 this.sendCommand('getBatteryCapacity', [], function (params){ 254 callback(params[0]); 255 }); 256 }; 257 /** 258 * Gets the voltage of the battery. 259 * @param {Function} callback Callback to execute after info is received. Example: function (params) { var voltage = params[0]; } 260 */ 261 this.getBatteryVoltage = function (callback){ 262 this.sendCommand('getBatteryVoltage', [], function (params){ 263 callback(params[0]); 264 }); 265 }; 266 /** 267 * Check weather barcode is enabled or not. 268 * 269 * @param {Function} callback Callback to execute after info is received. Example: function (params) { var enabled = params[0]; } 270 * @param {Int} barcode Barcode to check if enabled. See ScannerDevice.CONSTANTS.BAR_TYPES.* for available values. 271 */ 272 this.isBarcodeEnabled = function (callback, barcode){ 273 this.sendCommand('isBarcodeEnabled', [barcode], function (params){ 274 callback(params[0]); 275 }); 276 }; 277 /** 278 * Checks if barcode is supported. 279 * 280 * @param {Function} callback Callback to execute after info is received. Example: function (params) { var supported = params[0]; } 281 * @param {Int} barcode Barcode to check if supported. See ScannerDevice.CONSTANTS.BAR_TYPES.* for available values. 282 */ 283 this.isBarcodeSupported = function (callback, barcode){ 284 this.sendCommand('isBarcodeSupported', [barcode], function (params){ 285 callback(params[0]); 286 }); 287 }; 288 /** 289 * Checks if device is charging. 290 * 291 * @param {Function} callback Callback to execute after info is received. Example: function (params) { var charging = params[0]; } 292 */ 293 this.getCharging = function (callback){ 294 this.sendCommand('getCharging', [], function (params){ 295 callback(Boolean(paseInt(params[0]))); 296 }); 297 }; 298 /** 299 * Set if you wish to charge iphone/ipod/ipad. 300 * 301 * @param {Boolean} enabled Weather to enable or disable charging. 302 */ 303 this.setCharging = function (enabled){ 304 this.sendCommand('setCharging', [enabled ? true : false]); 305 }; 306 /** 307 * Retreives the sync button mode (Very little documentation is given on this, so I am not even sure what it does.) 308 * 309 * @param {Function} callback Callback to execute after info is received. Example: function (params) { var sync_mode = params[0]; } 310 */ 311 this.getSyncButtonMode = function (callback){ 312 this.sendCommand('getSyncButtonMode', [], function (params){ 313 callback(parseInt(params[0])); 314 }); 315 }; 316 /** 317 * Tries to process credit card info from a swipped card. 318 * 319 * @param {Function} callback Callback to execute after info is received. Example: function (params) { 320 var accountNumber = params[0].accountNumber, 321 cardholderName = params[0].cardholderName, 322 discretionaryData = params[0].discretionaryData, 323 exirationMonth = params[0].exirationMonth, 324 exirationYear = params[0].exirationYear, 325 firstName = params[0].firstName, 326 lastName = params[0].lastName, 327 serviceCode = params[0].serviceCode; 328 } 329 * @param {String} track1 Data from track1. 330 * @param {String} track2 Data from track2. 331 * @param {String} track3 Data from track3. 332 */ 333 this.msProcessFinancialCard = function (callback, track1, track2, track3){ 334 this.sendCommand('msProcessFinancialCard', [track1 || '', track2 || '', track3 || ''], function (params){ 335 callback(params[0]); 336 }); 337 }; 338 /** 339 * Gets the mode cards are received in. See: ScannerDevice.CONSTANTS.MS_* for more info. 340 * 341 * @param {Function} callback Callback to execute after info is received. Example: function (params) { var mode = params[0]; } 342 */ 343 this.getMSCardDataMode = function (callback){ 344 this.sendCommand('getMSCardDataMode', [], function (params){ 345 callback(params[0]); 346 }); 347 }; 348 /** 349 * Gets the mode barcodes will be scanned in. See: ScannerDevice.CONSTANTS.BARCODE_TYPE_* 350 * @param {Function} callback Callback to execute after info is received. Example: function (params) { var bar_type_mode = params[0]; } 351 */ 352 this.getBarcodeTypeMode = function (type, callback){ 353 this.sendCommand('getBarcodeTypeMode', [], function (){ 354 callback(params[0]); 355 }); 356 }; 357 /** 358 * You can turn the barcode engine off with this function. When the engine is turned back on it may take up to 2 seconds for device to be 359 * responsive again. (Don't play with this unless you know what you are doing.) 360 * 361 * @param {Boolean} enabled Weather to enable or disable engine. 362 */ 363 this.barcodeEnginePowerControl = function (enabled){ 364 this.sendCommand('barcodeEnginePowerControl', []); 365 }; 366 /** 367 * Helper function to get the name of barcodes by their code. 368 * 369 * @param {Int} type Barcode type to get name. See: ScannerDeice.CONSTANTS.BAR_TYPES.* for available barcodes. 370 */ 371 this.barcodeType2Text = function (type, callback){ 372 this.sendCommand('barcodeType2Text', [], function (params){ 373 callback(params[0]); 374 }); 375 }; 376 /** 377 * Gets the connection state of the device. 378 * 379 * @param {Function} callback Callback to execute after info is received. Example: function (params) { var state = params[0]; } // See ScannerDevice.CONSTANTS.CONN_* 380 */ 381 this.getConnectionState = function (callback){ 382 this.sendCommand('getConnectionState', [], function (params){ 383 callback(params[0]); 384 }); 385 } 386 var i; 387 for(i in mappings){ 388 if(ScannerDevice.allowedCallbacks.indexOf(i) != -1 && mappings[i] && mappings[i] instanceof Function){ 389 this[i] = mappings[i]; 390 } 391 } 392 }; 393 /** 394 * Deligate functions device will automatically execute when an event happens. 395 */ 396 ScannerDevice.allowedCallbacks = [ 397 'barcodeData', 398 'magneticCardData', 399 'magneticCardRawData', 400 'buttonPressed', 401 'buttonReleased', 402 'connectionState' 403 ]; 404 /** 405 * Allowed functions that scanner accepts. 406 */ 407 ScannerDevice.allowedFunctions = [ 408 'enableBarcode', 409 'playSound', 410 'startScan', 411 'stopScan', 412 'setScanMode', 413 'setScanBeep', 414 'setScanButtonMode', 415 'setMSCardDataMode', 416 'setBarcodeTypeMode', 417 'getBatteryCapacity', 418 'getBatteryVoltage', 419 'isBarcodeEnabled', 420 'isBarcodeSupported', 421 'getMSCardDataMode', 422 'getCharging', 423 'setCharging', 424 'getSyncButtonMode', 425 'msProcessFinancialCard', 426 'getBarcodeTypeMode', 427 'barcodeEnginePowerControl', 428 'barcodeType2Text', 429 'getConnectionState', 430 ]; 431 /** 432 * List of objects listeneing on device. 433 * 434 * @static 435 * @private 436 */ 437 ScannerDevice.listeners = []; 438 /** 439 * Registers a listener to device. 440 * 441 * @param {ScannerDevice} obj ScannerDevice object to listen to device on. 442 * @static 443 */ 444 ScannerDevice.registerListener = function (obj){ 445 if(obj instanceof ScannerDevice){ 446 var i = 0, 447 objs = ScannerDevice.listeners, 448 len = objs.length; 449 for(;i<len;i++){ 450 if(objs[i] === obj){ 451 return false; // Already assigned 452 } 453 } 454 ScannerDevice.listeners.push(obj); 455 return true; 456 }else{ 457 return false; 458 } 459 }; 460 /** 461 * Unregisters a listener to device. 462 * 463 * @param {ScannerDevice} obj ScannerDevice object to unregister with library. 464 */ 465 ScannerDevice.unregisterListener = function (obj){ 466 if(obj instanceof ScannerDevice){ 467 var i = 0, 468 objs = ScannerDevice.listeners, 469 len = objs.length; 470 for(;i<len;i++){ 471 if(objs[i] === obj){ 472 objs.splice(i, 1); 473 return true; 474 } 475 } 476 return false; 477 }else{ 478 return false; 479 } 480 }; 481 /** 482 * Master function to listen to events. Do not override this unless you wish to write your own library. 483 * 484 * @param {Array} params Params passed from device. 485 * @static 486 * @private 487 */ 488 ScannerDevice.triggerEvent = function (params){ 489 var event = params[0], 490 listeners = ScannerDevice.listeners, 491 len = listeners.length, i, obj, args = [], emptyFn = function (){}, 492 emptyErrFn = function (params){ 493 if(Debugging) 494 alert(params); 495 }; 496 if(!event || ScannerDevice.allowedCallbacks.indexOf(event) == -1){ 497 return false; 498 } 499 switch(event){ 500 case 'connectionState': 501 ScannerDevice.CONNECTION_STATE = parseInt(params[1]); // Set local Connection state variable 502 break; 503 case 'buttonPressed': 504 if(ScannerDevice.lastSettings.BUTTON_ENABLED == ScannerDevice.CONSTANTS.BUTTON_ENABLED){ 505 ScannerDevice.LAZER_ON = true; 506 } 507 ScannerDevice.BUTTON_PRESSED = true; 508 break; 509 case 'buttonReleased': 510 if(ScannerDevice.lastSettings.BUTTON_ENABLED == ScannerDevice.CONSTANTS.BUTTON_ENABLED){ 511 ScannerDevice.LAZER_ON = false; 512 } 513 ScannerDevice.BUTTON_PRESSED = false; 514 } 515 for(i=1;i<params.length;i++){ 516 args.push(params[i]); 517 } 518 for(i=0;i<len;i++){ 519 obj = listeners[i]; 520 if(obj[event] && obj[event] instanceof Function){ 521 try{ 522 obj[event].apply(obj[event], args); 523 }catch(e){ 524 if(Debugging){ 525 alert(e); 526 } 527 } 528 } 529 } 530 if(event == 'connectionState'){ 531 if(ScannerDevice.CONNECTION_STATE == ScannerDevice.CONSTANTS.CONN_CONNECTED){ 532 cordova.exec(emptyFn, emptyErrFn, "LineaDevice", 'configureAllSettings', [ScannerDevice.lastSettings]); 533 } 534 } 535 }; 536 /** 537 * Usefull constants. 538 * @static 539 */ 540 ScannerDevice.CONSTANTS = { 541 /* BEGIN CONN STATES */ 542 CONN_DISCONNECTED: 0, 543 CONN_CONNECTING: 1, 544 CONN_CONNECTED: 2, 545 /* END CONN STATES */ 546 /* BEGIN SCAN MODES */ 547 MODE_SINGLE_SCAN: 0, 548 MODE_MULTI_SCAN: 1, 549 /* END SCAN MODES */ 550 /* BEGIN BUTTON STATES */ 551 BUTTON_DISABLED:0, 552 BUTTON_ENABLED:1, 553 /* END BUTTON STATES */ 554 /* BEGIN MS MODES */ 555 MS_PROCESSED_CARD_DATA:0, 556 MS_RAW_CARD_DATA:1, 557 /* BEGIN BARCODE TYPES MODE */ 558 BARCODE_TYPE_DEFAULT:0, 559 BARCODE_TYPE_EXTENDED:1, 560 561 562 /* BEGIN BARCODE TYPES */ 563 BAR_TYPES: { 564 BAR_ALL: 0, 565 BAR_UPC: 1, 566 BAR_CODABAR: 2, 567 BAR_CODE25_NI2OF5: 3, 568 BAR_CODE25_I2OF5: 4, 569 BAR_CODE39: 5, 570 BAR_CODE93: 6, 571 BAR_CODE128: 7, 572 BAR_CODE11: 8, 573 BAR_CPCBINARY: 9, 574 BAR_DUN14: 10, 575 BAR_EAN2: 11, 576 BAR_EAN5: 12, 577 BAR_EAN8: 13, 578 BAR_EAN13: 14, 579 BAR_EAN128: 15, 580 BAR_GS1DATABAR: 16, 581 BAR_ITF14: 17, 582 BAR_LATENT_IMAGE: 18, 583 BAR_PHARMACODE: 19, 584 BAR_PLANET: 20, 585 BAR_POSTNET: 21, 586 BAR_INTELLIGENT_MAIL: 22, 587 BAR_MSI: 23, 588 BAR_POSTBAR: 24, 589 BAR_RM4SCC: 25, 590 BAR_TELEPEN: 26, 591 BAR_PLESSEY: 27, 592 BAR_PDF417: 28, 593 BAR_MICROPDF417: 29, 594 BAR_DATAMATRIX: 30, 595 BAR_AZTEK: 31, 596 BAR_QRCODE: 32, 597 BAR_MAXICODE: 33, 598 BAR_LAST: 34, 599 600 BAR_EX_ALL: 0, 601 BAR_EX_UPCA: 1, 602 BAR_EX_CODABAR: 2, 603 BAR_EX_CODE25_NI2OF5: 3, 604 BAR_EX_CODE25_I2OF5: 4, 605 BAR_EX_CODE39: 5, 606 BAR_EX_CODE93: 6, 607 BAR_EX_CODE128: 7, 608 BAR_EX_CODE11: 8, 609 BAR_EX_CPCBINARY: 9, 610 BAR_EX_DUN14: 10, 611 BAR_EX_EAN2: 11, 612 BAR_EX_EAN5: 12, 613 BAR_EX_EAN8: 13, 614 BAR_EX_EAN13: 14, 615 BAR_EX_EAN128: 15, 616 BAR_EX_GS1DATABAR: 16, 617 BAR_EX_ITF14: 17, 618 BAR_EX_LATENT_IMAGE: 18, 619 BAR_EX_PHARMACODE: 19, 620 BAR_EX_PLANET: 20, 621 BAR_EX_POSTNET: 21, 622 BAR_EX_INTELLIGENT_MAIL: 22, 623 BAR_EX_MSI_PLESSEY: 23, 624 BAR_EX_POSTBAR: 24, 625 BAR_EX_RM4SCC: 25, 626 BAR_EX_TELEPEN: 26, 627 BAR_EX_UK_PLESSEY: 27, 628 BAR_EX_PDF417: 28, 629 BAR_EX_MICROPDF417: 29, 630 BAR_EX_DATAMATRIX: 30, 631 BAR_EX_AZTEK: 31, 632 BAR_EX_QRCODE: 32, 633 BAR_EX_MAXICODE: 33, 634 BAR_EX_RESERVED1: 34, 635 BAR_EX_RESERVED2: 35, 636 BAR_EX_RESERVED3: 36, 637 BAR_EX_RESERVED4: 37, 638 BAR_EX_RESERVED5: 38, 639 BAR_EX_UPCA_2: 39, 640 BAR_EX_UPCA_5: 40, 641 BAR_EX_UPCE: 41, 642 BAR_EX_UPCE_2: 42, 643 BAR_EX_UPCE_5: 43, 644 BAR_EX_EAN13_2: 44, 645 BAR_EX_EAN13_5: 45, 646 BAR_EX_EAN8_2: 46, 647 BAR_EX_EAN8_5: 47, 648 BAR_EX_CODE39_FULL: 48, 649 BAR_EX_ITA_PHARMA: 49, 650 BAR_EX_CODABAR_ABC: 50, 651 BAR_EX_CODABAR_CX: 51, 652 BAR_EX_SCODE: 52, 653 BAR_EX_MATRIX_2OF5: 53, 654 BAR_EX_IATA: 54, 655 BAR_EX_KOREAN_POSTAL: 55, 656 BAR_EX_CCA: 56, 657 BAR_EX_CCB: 57, 658 BAR_EX_CCC: 58, 659 BAR_EX_LAST: 59 660 } 661 }; 662 /** 663 * This object contains info on the current state of device. These variables will change based on when functions 664 * are executed out of library. Also when device disconnects and re-connects it will auto re-assign all options 665 * you already set. 666 */ 667 ScannerDevice.lastSettings = { 668 SCAN_BEEP_ENABLED: true, 669 SCAN_BEEP: [600,150,900,200], 670 SCAN_MODE: ScannerDevice.CONSTANTS.MODE_SINGLE_SCAN, 671 BUTTON_ENABLED: ScannerDevice.CONSTANTS.BUTTON_ENABLED, 672 MS_MODE: ScannerDevice.CONSTANTS.MS_PROCESSED_CARD_DATA, 673 BARCODE_TYPE: ScannerDevice.CONSTANTS.BARCODE_TYPE_DEFAULT, 674 BARCODE_ENGINE_POWER: true, 675 CHARGING: false, 676 barcodeStatus: { 677 } 678 }; 679 (function (){ 680 var i; 681 for(i in ScannerDevice.CONSTANTS.BAR_TYPES){ 682 if(i != 'BAR_EX_LAST' && i != 'BAR_LAST' && i != 'BAR_EX_ALL' && i != 'BAR_ALL'){ 683 ScannerDevice.lastSettings.barcodeStatus[ScannerDevice.CONSTANTS.BAR_TYPES[i]] = true; 684 } 685 } 686 })(); 687 688 ScannerDevice.LAZER_ON = false; 689 ScannerDevice.CONNECTION_STATE = ScannerDevice.CONSTANTS.CONN_DISCONNECTED; 690 ScannerDevice.BUTTON_PRESSED = false; 691 /** 692 * @ignore 693 */ 694 document.addEventListener('deviceready', function (){ 695 cordova.exec(ScannerDevice.triggerEvent, function (){}, "LineaDevice", "monitor", []); 696 }, false);