Difference between revisions of "Barcode Scanning/Debug"
From PartKeepr Wiki
(Created page with "If barcode scanning does not work properly, you can copy and paste the following code into your browser's JavaScript console. This overrides the default barcode scanning class...") |
(No difference)
|
Latest revision as of 11:12, 15 June 2017
If barcode scanning does not work properly, you can copy and paste the following code into your browser's JavaScript console. This overrides the default barcode scanning class, printing debug output on the console.
PartKeepr.getApplication().barcodeScannerManager.onKeyPress = function (e) { var hotKeyPressed = false; var hotKey = PartKeepr.getApplication().getSystemPreference("partkeepr.barcodeScanner.key", ""); if (hotKey === "") { console.log("No hotkey configured, returning"); return; } console.log("got key event:"); console.log(e); if (e.event.key === hotKey) { hotKeyPressed = true; console.log("Hotkey not pressed"); } if (PartKeepr.getApplication().getSystemPreference("partkeepr.barcodeScanner.modifierCtrl", false)) { if (!e.ctrlKey) { console.log("ctrl hotkey modifier not pressed"); hotKeyPressed = false; } } if (PartKeepr.getApplication().getSystemPreference("partkeepr.barcodeScanner.modifierShift", false)) { if (!e.shiftKey) { console.log("shift hotkey modifier not pressed"); hotKeyPressed = false; } } if (PartKeepr.getApplication().getSystemPreference("partkeepr.barcodeScanner.modifierAlt", false)) { if (!e.altKey) { console.log("alt hotkey modifier not pressed"); hotKeyPressed = false; } } if (hotKeyPressed) { console.log("starting key monitoring"); this.startKeyMonitoring(); return; } if (this.monitor) { if (PartKeepr.getApplication().getSystemPreference("partkeepr.barcodeScanner.enter", true)) { if (e.event.code == "Enter") { this.stopKeyMonitoring(); return; } } if (!e.isSpecialKey()) { this.monitoredKeys += e.event.key; } this.runnerTask.delay( PartKeepr.getApplication().getSystemPreference("partkeepr.barcodeScanner.timeout", 500)); e.stopEvent(); } }; Ext.get(document).on("keydown", PartKeepr.getApplication().barcodeScannerManager.onKeyPress, PartKeepr.getApplication().barcodeScannerManager, { priority: 10000 });