forked from MatiasValenzuelaV/webcodecamjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_buildselect.html
35 lines (35 loc) · 1.35 KB
/
simple_buildselect.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Demo</title>
</head>
<body>
<h3>Simple initalization with default settings and build select menu</h3>
<hr>
<canvas></canvas>
<hr>
<select></select>
<hr>
<ul></ul>
<script type="text/javascript" src="js/qrcodelib.js"></script>
<script type="text/javascript" src="js/webcodecamjs.js"></script>
<script type="text/javascript">
var txt = "innerText" in HTMLElement.prototype ? "innerText" : "textContent";
var arg = {
resultFunction: function(result) {
var aChild = document.createElement('li');
aChild[txt] = result.format + ': ' + result.code;
document.querySelector('body').appendChild(aChild);
}
};
var decoder = new WebCodeCamJS("canvas").buildSelectMenu('select', 'environment|back').init(arg).play();
/* Without visible select menu
var decoder = new WebCodeCamJS("canvas").buildSelectMenu(document.createElement('select'), 'environment|back').init(arg).play();
*/
document.querySelector('select').addEventListener('change', function(){
decoder.stop().play();
});
</script>
</body>
</html>