Hopefully fix strange barcode scanner bug
This commit is contained in:
		
							parent
							
								
									69e4f09685
								
							
						
					
					
						commit
						41b0edd609
					
				| @ -120,6 +120,35 @@ function setupHTML5BarcodeScanner() { | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | function setupCordovaBarcodeScanner() { | ||||||
|  |     scanBarcode = function (success, error) { | ||||||
|  |         scanningBarcode = true; | ||||||
|  |         cordova.plugins.barcodeScanner.scan( | ||||||
|  |                 function (result) { | ||||||
|  |                     scanningBarcode = false; | ||||||
|  |                     if (!result.cancelled) { | ||||||
|  |                         success(result.text); | ||||||
|  |                     } | ||||||
|  |                 }, | ||||||
|  |                 function (err) { | ||||||
|  |                     scanningBarcode = false; | ||||||
|  |                     if (typeof error == "function") { | ||||||
|  |                         error(err); | ||||||
|  |                     } | ||||||
|  |                 }, | ||||||
|  |                 { | ||||||
|  |                     showTorchButton: true, | ||||||
|  |                     showFlipCameraButton: true, | ||||||
|  |                     prompt: "Scan barcode", | ||||||
|  |                     resultDisplayDuration: 0, | ||||||
|  |                     disableSuccessBeep: true, | ||||||
|  |                     formats: "QR_CODE,DATA_MATRIX,CODE_39,CODE_93,CODE_128,CODABAR,PDF_417" | ||||||
|  |                 } | ||||||
|  |         ); | ||||||
|  |     }; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| function initCordova() { | function initCordova() { | ||||||
|     platform_type = "cordova"; |     platform_type = "cordova"; | ||||||
| 
 | 
 | ||||||
| @ -151,38 +180,21 @@ function initCordova() { | |||||||
|         window.open(url, '_system', ''); |         window.open(url, '_system', ''); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     // If initialization fails wait a few seconds and try again
 | ||||||
|     if (typeof device != "undefined" && device.platform != "browser") { |     if (typeof device != "undefined" && device.platform != "browser") { | ||||||
|         scanBarcode = function (success, error) { |         setupCordovaBarcodeScanner(); | ||||||
|             scanningBarcode = true; |  | ||||||
|             cordova.plugins.barcodeScanner.scan( |  | ||||||
|                     function (result) { |  | ||||||
|                         scanningBarcode = false; |  | ||||||
|                         if (!result.cancelled) { |  | ||||||
|                             success(result.text); |  | ||||||
|                         } |  | ||||||
|                     }, |  | ||||||
|                     function (err) { |  | ||||||
|                         scanningBarcode = false; |  | ||||||
|                         if (typeof error == "function") { |  | ||||||
|                             error(err); |  | ||||||
|                         } |  | ||||||
|                     }, |  | ||||||
|                     { |  | ||||||
|                         showTorchButton: true, |  | ||||||
|                         showFlipCameraButton: true, |  | ||||||
|                         prompt: "Scan barcode", |  | ||||||
|                         resultDisplayDuration: 0, |  | ||||||
|                         disableSuccessBeep: true, |  | ||||||
|                         formats: "QR_CODE,DATA_MATRIX,CODE_39,CODE_93,CODE_128,CODABAR,PDF_417,AZTEC,MAXICODE" |  | ||||||
|                     } |  | ||||||
|             ); |  | ||||||
|         }; |  | ||||||
|     } else { |     } else { | ||||||
|         setupHTML5BarcodeScanner(); |         setTimeout(function () { | ||||||
|  |             if (typeof device != "undefined" && device.platform != "browser") { | ||||||
|  |                 setupCordovaBarcodeScanner(); | ||||||
|  |             } else { | ||||||
|  |                 setupHTML5BarcodeScanner(); | ||||||
|  |             } | ||||||
|  |         }, 5000); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Handle geo: urls
 |     // Handle geo: urls
 | ||||||
|     $("#app").on("click", ".geolink", function (evt) { |     $("#app").on("click", "a[href^='geo:']", function (evt) { | ||||||
|         window.open($(this).attr("href"), "_system"); |         window.open($(this).attr("href"), "_system"); | ||||||
|         evt.preventDefault(); |         evt.preventDefault(); | ||||||
|     }); |     }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user