-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
83 lines (73 loc) · 2.05 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ripple Point of Sale System</title>
<script type="text/javascript" src="qrcode.min.js"></script>
<script type="text/javascript">
function rippleURI() {
var data = window.location.hash.replace(/#/, '').split(/\//);
return 'http://ripple.com//send?to=' +
encodeURIComponent(data[0]) +
'&amount=' + encodeURIComponent(document.getElementById('amount').value) + '/' + data[1];
}
function size() {
if(window.innerWidth < window.innerHeight) {
return window.innerWidth / 2;
} else {
return window.innerHeight / 2;
}
}
function initQR() {
window.qrcode = new QRCode('qrcode', {
text: rippleURI(),
width: size(),
height: size(),
correctLevel : QRCode.CorrectLevel.H
});
}
window.addEventListener('load', function(){
initQR();
var data = window.location.hash.replace(/#/, '').split(/\//);
document.getElementById('currency').innerHTML = data[1];
document.getElementById('amount').addEventListener('keyup', function() {
qrcode.makeCode(rippleURI());
}, false);
document.getElementById('amount').addEventListener('change', function() {
qrcode.makeCode(rippleURI());
}, false);
}, false);
window.addEventListener('resize', function(){
document.getElementById('qrcode').innerHTML = '';
initQR();
}, false);
</script>
<style type="text/css">
html, body {
background: #ccc;
font-family: sans-serif;
text-align: center;
}
input, h1, img {
margin: 0.5em auto;
font-size: 2em;
}
input {
width: 5em;
padding: 0.5em;
border: 1px solid black;
border-radius: 0.5em;
text-align: right;
}
#currency { font-size: 2em; }
</style>
</head>
<body>
<h1>Ripple Point of Sale System</h1>
<label>
<input id="amount" type="number" placeholder="Amount" step="0.01" />
<span id="currency"></span>
</label>
<div id="qrcode"></div>
</body>
</html>