Skip to content

Instantly share code, notes, and snippets.

@cianclarke
Last active June 28, 2016 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cianclarke/c499c5cef33c1ae603ab to your computer and use it in GitHub Desktop.
Save cianclarke/c499c5cef33c1ae603ab to your computer and use it in GitHub Desktop.
Barcode Client Finished Files
{
"plugins": [
{
"id": "com.phonegap.plugins.barcodescanner",
"version": "2.0.1",
"url" : "https://github.com/wildabeast/BarcodeScanner.git"
}
]
}
document.getElementById('say_hello').onclick = function () {
return cordova.plugins.barcodeScanner.scan(function (result) {
document.getElementById('hello_to').value = result.text;
document.getElementById('cloudResponse').innerHTML = "<p>Calling Cloud.....</p>";
$fh.cloud(
{
path: 'hello',
data: {
barcode: result.text
}
},
function (res) {
var product = res;
document.getElementById('cloudResponse').innerHTML = "<img src='" + product.imageurl + "'>" +
"<p>" + product.productname + "</p>";
},
function (code, errorprops, params) {
alert('An error occured: ' + code + ' : ' + errorprops);
}
);
}, function (error) {
alert("Scanning failed: " + error);
});
};
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>Hello World</title>
<link rel="stylesheet" href="css/app.css">
</head>
<body>
<header class="header-footer-bg">
<div class="center">
<h3>FeedHenry
<small>Barcode Scanner</small>
</h3>
</div>
</header>
<div id="count" class="">
<div id="formWrapper">
<p id="description">This app will take a USP code, send it to the cloud, and return the product name and image.</p>
<br>
<div class="input-div">
<input id="hello_to" type="text" class="input-text" placeholder="Enter Your USP Code"/>
</div>
<br>
<button id="say_hello" type="button" class="say-hello-button">Scan Barcode</button>
<div id="cloudResponse" class="cloudResponse"></div>
</div>
</div>
<footer class="header-footer-bg">
<div>
<small class="right">
<!-- v.&nbsp;{{ version }} -->
</small>
</div>
</footer>
<script src="feedhenry.js"></script>
<script src="hello.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment