coinb.in can now scan qrcodes

This commit is contained in:
OutCast3k 2015-03-09 00:34:19 +00:00
parent f3aa1ba027
commit c150800a5f
4 changed files with 103 additions and 6 deletions

View file

@ -24,6 +24,7 @@
<script type="text/javascript" src="js/aes.js"></script>
<script type="text/javascript" src="js/qrcode.js"></script>
<script type="text/javascript" src="js/qcode-decoder.min.js"></script>
<script type="text/javascript" src="js/jsbn.js"></script>
<script type="text/javascript" src="js/ellipticcurve.js"></script>
@ -316,6 +317,9 @@
<b>Address, WIF key or Multisig Redeem Script</b>:
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-info qrcodeScanner" type="button" data-toggle="modal" data-target="#modalQrcodeScanner" forward-result="#redeemFrom"><span class="glyphicon glyphicon-camera"></span></button>
</span>
<input type="text" id="redeemFrom" class="form-control" value="">
<span class="input-group-btn">
<button id="redeemFromBtn" class="btn btn-info" type="button">Load</button>
@ -357,8 +361,8 @@
</div>
<ul class="nav nav-tabs" id="putTabs">
<li class="active"><a href="#txoutputs" data-toggle="tab">Outputs (<span id="totalOutput">0.0000</span>)</a></li>
<li><a href="#txinputs" data-toggle="tab">Inputs (<span id="totalInput">0.0000</span>)</a></li>
<li class="active"><a href="#txoutputs" data-toggle="tab">Outputs <small>(<span id="totalOutput">0.0000</span>)</small></a></li>
<li><a href="#txinputs" data-toggle="tab">Inputs <small>(<span id="totalInput">0.0000</span>)</small></a></li>
</ul>
<br>
@ -665,13 +669,36 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" id="agentClose">Close</button>
<button type="button" class="btn btn-default" data-dismiss="modal" id="qrCodeClose">Close</button>
</div>
</div>
</div>
</div>
<!-- qrcode modal -->
<!-- qrcode scanner modal -->
<div class="modal fade" id="modalQrcodeScanner" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">qrcode scanner</h4>
</div>
<div class="modal-body" align="center">
<select id="videoSource" class="form-control"></select>
<video id="videoReader" muted autoplay style="width:100%;height:100%"></video>
<div id="qrcode-scanner-callback-to" class="hidden"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" id="qrScanClose">Close</button>
</div>
</div>
</div>
</div>
<!-- qrcode scanner modal -->
<div class="hidden" id="entropybucket"></div>
</body>
</html>

View file

@ -413,6 +413,73 @@ $(document).ready(function() {
totalInputAmount();
});
/* 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(){
videoStart()
});
videoStart();
$("#qrcode-scanner-callback-to").html($(this).attr('forward-result'));
});
$("#redeemFromBtn").click(function(){
var thisbtn = this;
var addr = '';

2
js/qcode-decoder.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
---- Version 1.0 2015.01.08 ----
---- Version 1.0 2015.03.09 ----
e6810907c901e6bd34a28735a68850936f0823b8 ./js/ellipticcurve.js
9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js
77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js
@ -8,9 +8,10 @@ be17ca7c834204bff711f582e41f76c06d472bac ./js/jsbn.js
8bc3bd34c0f7605ea49e56a65841eab9d0dbf53b ./js/cryptojs.ripemd160.js
15a81fe4074f920898e98b1b42cf11bda26da0a8 ./js/bootstrap.min.js
f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js
0ce26da5ef686d4ece91acd6cb6506559e11ab07 ./js/qcode-decoder.min.js
ad038e1f39646b68ae666324ed4c2882a8c42474 ./js/qrcode.js
64eb4ea5c882f8bce3e1885bf00728455f1c2f4c ./js/ripemd160.js
429a82eac1aa02c9a3a340adf8176b17fcf98c25 ./js/coinbin.js
3450ac66ed7608ac5c12db73e5afcdc0683226b7 ./js/coinbin.js
46f1b2e7f64482753f5f0ecde3ec2af7b01812f7 ./js/coin.js
ae49e56999d82802727455f0ba83b63acd90a22b ./js/jquery-1.9.1.min.js
5f570018ed044eafd464f7e0ab1783b966224055 ./LICENCE
@ -24,4 +25,4 @@ ecee9033d9183117d8f59df0e7238e2b24002b24 ./fonts/glyphicons-halflings-regular.s
c6ea7b1a5bb16b160cc9b8a02f6f6371b5ef7b73 ./fonts/glyphicons-halflings-regular.woff
536d2b1b2f3462fb122df1922f2e232546f1b11d ./fonts/glyphicons-halflings-regular.ttf
64d660230800302cae4e94f3660b0b9233a56559 ./README.md
215e858ba5406a1858fc8125ec427bec171e4165 ./index.html
a82c6ea039866790d2126923d3e8dfaa449dbbfd ./index.html