lucasjahn/jQuery-Scanner-Detection

OnComplete never is raised

Opened this issue · 0 comments

fuhye commented

I have the barcode DATALOGIC N263

when i read an barcode is readed oncomplete never is raised

debuggingi find what events keypress and keydown work but never oncomplete is raised

so log the e.timeStamp in keypress and that result

18:45:26.693 jquery.scannerdetection.js:110 timestamp 12921.730000000001
18:45:26.699 jquery.scannerdetection.js:110 timestamp 12937.2
18:45:26.714 jquery.scannerdetection.js:110 timestamp 12953.295
18:45:26.730 jquery.scannerdetection.js:110 timestamp 12969.465000000002
18:45:26.752 jquery.scannerdetection.js:110 timestamp 12986.145
18:45:26.776 jquery.scannerdetection.js:110 timestamp 13004.905
18:45:26.782 jquery.scannerdetection.js:110 timestamp 13017.435000000001
18:45:26.793 jquery.scannerdetection.js:110 timestamp 13034.205000000002
18:45:26.808 jquery.scannerdetection.js:110 timestamp 13050.105
18:45:26.860 jquery.scannerdetection.js:110 timestamp 13097.375000000002
18:45:26.872 jquery.scannerdetection.js:110 timestamp 1495842326871

the last character in my case 13 have an huge timestamp
so creating a variable before assign the new e.timeStamp fix it

so i change it

            lastCharTime=e.timeStamp;
            if(testTimer) clearTimeout(testTimer);
            if (callIsScanner) {
                self.scannerDetectionTest();
                testTimer=false;
            }else{
                testTimer=setTimeout(self.scannerDetectionTest,options.timeBeforeScanTest);
            }

for

            var lastlastCharTime = lastCharTime;
            lastCharTime=e.timeStamp;

            if(testTimer) clearTimeout(testTimer);
            if (callIsScanner) {
                lastCharTime = lastlastCharTime;
                self.scannerDetectionTest();
                testTimer=false;
            }else{
                testTimer=setTimeout(self.scannerDetectionTest,options.timeBeforeScanTest);
            }