Created
November 16, 2011 06:15
-
-
Save pmuellr/1369403 to your computer and use it in GitHub Desktop.
phonegap-plugins_issue-225.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- | |
| * PhoneGap is available under *either* the terms of the modified BSD license *or* the | |
| * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. | |
| * | |
| * Copyright (c) 2011, IBM Corporation | |
| * | |
| --> | |
| <html> | |
| <head> | |
| <title>PhoneGap BarcodeScanner device test app</title> | |
| <script src="phonegap-1.1.0.js"></script> | |
| <script src="barcodescanner.js"></script> | |
| <style> | |
| button { | |
| font-size: 120%; | |
| } | |
| </style> | |
| </head> | |
| <body onload="onLoad()"> | |
| <button id="scan-button">scan something</button> | |
| <p>scanned: <span id="scan-result">n/a</span> | |
| </body> | |
| <script> | |
| //------------------------------------------------------------------------------ | |
| var button | |
| var result | |
| //------------------------------------------------------------------------------ | |
| function onLoad() { | |
| if (!window.PhoneGap) { | |
| alert("PhoneGap is not available") | |
| return | |
| } | |
| document.addEventListener("deviceready",onDeviceReady,false) | |
| button = document.getElementById("scan-button") | |
| resultSpan = document.getElementById("scan-result") | |
| } | |
| //------------------------------------------------------------------------------ | |
| function onDeviceReady() { | |
| button.addEventListener("click", onClick, false) | |
| } | |
| //------------------------------------------------------------------------------ | |
| function onClick() { | |
| window.plugins.barcodeScanner.scan(scannerSuccess, scannerFailure) | |
| } | |
| //------------------------------------------------------------------------------ | |
| function scannerSuccess(result) { | |
| console.log("scannerSuccess: result: " + JSON.stringify(result)) | |
| resultSpan.innerText = "success: " + JSON.stringify(result) | |
| } | |
| //------------------------------------------------------------------------------ | |
| function scannerFailure(message) { | |
| console.log("scannerFailure: message: " + JSON.stringify(message)) | |
| resultSpan.innerText = "failure: " + JSON.stringify(message) | |
| } | |
| </script> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment