diff --git a/css/index.css b/css/index.css old mode 100644 new mode 100755 index dac530d..4bb4552 --- a/css/index.css +++ b/css/index.css @@ -19,8 +19,7 @@ * { -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */ -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */ - -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ - -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ + -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ } body { diff --git a/index.html b/index.html index 82b8231..01bd4a8 100644 --- a/index.html +++ b/index.html @@ -25,7 +25,7 @@ Barcode Scanner Demo - +

Apache Cordova

SCAN

-

ENCODE

+
+

ENCODE

+ +

OPENING LINKS:

InAppBrowser

diff --git a/js/index.js b/js/index.js index 660be3a..5cd127f 100644 --- a/js/index.js +++ b/js/index.js @@ -19,7 +19,7 @@ var app = { // Application Constructor initialize: function() { - this.bindEvents(); + this.bindEvents(); }, // Bind Event Listeners // @@ -82,14 +82,32 @@ var app = { encode: function() { var scanner = cordova.require("cordova/plugin/BarcodeScanner"); + var textToEncode = document.getElementById("textToEncode").value; + var qr_encode_div = document.getElementById("qr_encoder"); + var qrImgTag = "qrcode"; - scanner.encode(scanner.Encode.TEXT_TYPE, "http://www.nhl.com", function(success) { - alert("encode success: " + success); + scanner.encode(scanner.Encode.TEXT_TYPE, textToEncode, function(success) { + var img = document.getElementById("qrcode"); + + if(img != null){ + img.src = success.file + "?lastmod=" + (Date.now() / 1000 | 0); + } + else{ + img = document.createElement("img"); + img.setAttribute("id", qrImgTag); + img.setAttribute("height", "250"); + img.setAttribute("width", "250"); + img.src = success.file + "?lastmod=" + (Date.now() / 1000 | 0); + qr_encode_div.appendChild(img); + } + }, function(fail) { - alert("encoding failed: " + fail); + var qrImg = document.getElementById(qrImgTag); + if(qrImg != null) + qr_encode_div.removeChild(qrImg); + alert("encoding failed: " + fail); + } ); - } - };