-
Notifications
You must be signed in to change notification settings - Fork 0
/
giving.html
129 lines (103 loc) · 4.88 KB
/
giving.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>QrRelay beta - Giving</title>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-CC3LK8SQE9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-CC3LK8SQE9');
</script>
<script type="text/javascript">
function resizeFunction(){
console.log("Resize function trigerred.");
document.getElementById("qr-video").width = window.innerWidth;
document.getElementById("qr-video").height = window.innerWidth;
}
</script>
</head>
<body onresize="resizeFunction()">
<h1>QrRelay beta : The Giving End</h1>
<p id="jsCheck">For this to work correctly, please enable javascript in your browser.</p>
<span id="testConnection">You are not connected. Probably something is wrong with your connection.</span><br>
<span id="sessionID"></span>
<p>[Optional] Enter sessionID, else a random id (shown above) will be used.
<input type="text" placeholder="sessionID" id="sessionInput" onchange=querySession() /></p>
<div id="keyExist" style="display: none">ID exists. Please choose another ID.</div>
Enter here if you want to send a custom key:
<input type="text" placeholder="Key to send" id="sendingKey" onchange=sendKey() /><br>
<b>Sent code: </b><span id="sentCode">None</span>
<p><input type="button" value="Tap / Click here to test if you are still connected." id="poke"
onclick=pokeFunction() /></p>
<div id="test"></div>
<hr>
<h1>Or, Scan from WebCam:</h1>
<div>
<b>Camera detected: </b>
<span id="cam-has-camera">true</span>
<br>
<b>Detected QR code: </b><span id="cam-qr-result">None</span>
<br>
<b>Last detected at: </b><span id="cam-qr-result-timestamp"></span>
<br>
<video muted="" playsinline="" id="qr-video"></video>
</div>
<div>
<b>Scanning type: </b>
<select id="inversion-mode-select">
<option value="both">Both original and inverted.</option>
<option value="original">Scan original (dark QR code on bright background)</option>
<option value="invert">Scan with inverted colors (bright QR code on dark background)</option>
</select>
<br>
</div>
<hr>
<p><a href="./">Go back to selection page.</a></p>
<p><a href="./receive">Change role</a></p>
<script src="/socket.io/socket.io.js"></script>
<script src="/assets/givingPage.js"></script>
<script type="module">
import QrScanner from "/assets/webQR/qr-scanner.min.js";
QrScanner.WORKER_PATH = '/assets/webQR/qr-scanner-worker.min.js';
const video = document.getElementById('qr-video');
const camHasCamera = document.getElementById('cam-has-camera');
const camQrResult = document.getElementById('cam-qr-result');
const camQrResultTimestamp = document.getElementById('cam-qr-result-timestamp');
const fileSelector = document.getElementById('file-selector');
const fileQrResult = document.getElementById('file-qr-result');
var currentKey = "";
function setResult(label, result) {
label.textContent = result;
var timeStamp = new Date();
camQrResultTimestamp.textContent = timeStamp.toString();
label.style.color = 'teal';
clearTimeout(label.highlightTimeout);
label.highlightTimeout = setTimeout(() => label.style.color = 'inherit', 100);
console.log({ ID: sessionID, key: result.toString(), timestamp: timeStamp });
if (result === currentKey) {
} else {
socket.emit("codeSubmit", { ID: sessionID, key: result.toString(), timestamp: timeStamp });
currentKey = result.toString();
console.log("Sent " + { ID: sessionID, key: result.toString(), timestamp: timeStamp });
}
}
// ####### Web Cam Scanning #######
QrScanner.hasCamera().then(hasCamera => camHasCamera.textContent = hasCamera);
const scanner = new QrScanner(video, result => setResult(camQrResult, result));
scanner.start();
document.getElementById('inversion-mode-select').addEventListener('change', event => {
scanner.setInversionMode(event.target.value);
});
</script>
<script type="text/javascript">
var infolinks_pid = 3231462;
var infolinks_wsid = 0;
</script>
<script type="text/javascript" src="//resources.infolinks.com/js/infolinks_main.js"></script>
<input type="hidden" name="IL_IN_ARTICLE">
<img src="https://hitcounter.pythonanywhere.com/count/tag.svg?url=https%3A%2F%2Fqr-cottendance-265413.appspot.com%2Fgiving"
alt="Hits">
</body>
</html>