diff --git a/index.html b/index.html
index ee82245..5db2c1c 100644
--- a/index.html
+++ b/index.html
@@ -361,8 +361,8 @@
+
Your browser does not offer camera support
diff --git a/js/coinbin.js b/js/coinbin.js
index 0ddad87..bded4db 100644
--- a/js/coinbin.js
+++ b/js/coinbin.js
@@ -415,71 +415,69 @@ $(document).ready(function() {
/* code for the qr code scanner */
- function gotSources(sourceInfos) {
- for (var i = 0; i !== sourceInfos.length; ++i) {
- var sourceInfo = sourceInfos[i];
- var option = document.createElement('option');
- option.value = sourceInfo.id;
- if (sourceInfo.kind === 'video') {
- option.text = sourceInfo.label || 'camera ' + ($("select#videoSource options").length + 1);
- $(option).appendTo("select#videoSource");
- }
- }
- }
-
- if (typeof MediaStreamTrack === 'undefined'){
- return alert('This browser does not support MediaStreamTrack.\n\nTry Chrome Canary.');
- } else {
- MediaStreamTrack.getSources(gotSources);
- }
-
- function videoStart(){
-
- navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
-
- if (!!window.stream) {
- $("video").attr('src',null);
- window.stream.stop();
- }
-
- var videoSource = $("select#videoSource").val()
- var constraints = {
- video: {
- optional: [{sourceId: videoSource}]
- }
- };
- navigator.getUserMedia(constraints, function(stream){
- window.stream = stream; // make stream available to console
- var videoElement = document.querySelector('video');
- videoElement.src = window.URL.createObjectURL(stream);
- videoElement.play();
- }, function(error){ });
-
- QCodeDecoder().decodeFromCamera(document.getElementById('videoReader'), function(er,data){
- if(!er){
- var r = '';
- var match = data.match(/^bitcoin\:(.*)\??$/i);
- if(match){
- r = match[1];
- } else {
- r = data;
- }
-
- $(""+$("#qrcode-scanner-callback-to").html()).val(r);
- $("#qrScanClose").click();
- }
- });
- }
-
$(".qrcodeScanner").click(function(){
- $("select#videoSource").change(function(){
+ if ((typeof MediaStreamTrack === 'function') && typeof MediaStreamTrack.getSources === 'function'){
+ MediaStreamTrack.getSources(function(sourceInfos){
+ var f = 0;
+ $("select#videoSource").html("");
+ for (var i = 0; i !== sourceInfos.length; ++i) {
+ var sourceInfo = sourceInfos[i];
+ var option = document.createElement('option');
+ option.value = sourceInfo.id;
+ if (sourceInfo.kind === 'video') {
+ option.text = sourceInfo.label || 'camera ' + ($("select#videoSource options").length + 1);
+ $(option).appendTo("select#videoSource");
+ }
+ }
+ });
+ } else {
+ $("#videoSource").addClass("hidden");
+ }
+
+ $("#videoSource").unbind("change").change(function(){
videoStart()
});
- videoStart();
+ videoStart();
$("#qrcode-scanner-callback-to").html($(this).attr('forward-result'));
});
+ function videoStart(){
+ navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || false;
+ if(navigator.getUserMedia){
+ if (!!window.stream) {
+ $("video").attr('src',null);
+ window.stream.stop();
+ }
+
+ var videoSource = $("select#videoSource").val();
+ var constraints = {
+ video: {
+ optional: [{sourceId: videoSource}]
+ }
+ };
+
+ navigator.getUserMedia(constraints, function(stream){
+ window.stream = stream; // make stream available to console
+ var videoElement = document.querySelector('video');
+ videoElement.src = window.URL.createObjectURL(stream);
+ videoElement.play();
+ }, function(error){ });
+
+ QCodeDecoder().decodeFromCamera(document.getElementById('videoReader'), function(er,data){
+ if(!er){
+ var match = data.match(/^bitcoin\:([13][a-z0-9]{26,33})/i);
+ var result = match ? match[1] : data;
+ $(""+$("#qrcode-scanner-callback-to").html()).val(result);
+ $("#qrScanClose").click();
+ }
+ });
+ } else {
+ $("#videoReaderError").removeClass("hidden");
+ $("#videoReader, #videoSource").addClass("hidden");
+ }
+ }
+
$("#redeemFromBtn").click(function(){
var thisbtn = this;
var addr = '';