This repository was archived by the owner on Feb 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.tmpl.html
98 lines (81 loc) · 2.59 KB
/
example.tmpl.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>libqrencode-js example</title>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.7.min.js"></script>
<script type="text/javascript"
src="{{libqrencode.js}}"></script>
<style type="text/css">
.qrTrue, .qrFalse {
display: inline-block;
width: 5px;
height: 5px;
margin: 0;
}
.qrTrue {
background-color: black;
}
#qrCode {
line-height: 0px;
font-size: 0px;
}
#qrText {
width: 300px;
}
#genButton {
margin-top: 10px;
margin-bottom: 10px;
}
</style>
<script type="text/javascript">
$(function() {
makeCode();
$("#genButton").click(function() { makeCode(); });
});
var makeCode = function() {
var text = $("#qrText").val();
var rst = "";
var addPoint = function(t) {
rst +=
"<div class='" +
(t ? "qrTrue" : "qrFalse") +
"'> </div>";
};
var newLine = function() { rst += "<br/>"; }
var code = qrencode.encodeString(text, 0,
qrencode.QR_ECLEVEL_L,
qrencode.QR_MODE_8, true);
var i;
var j;
for ( i = 0; i < 2; i++ ) {
for ( j = 0; j < code.length; j++ ) addPoint(false);
newLine();
}
for ( j = 0; j < code.length; j++ ) {
addPoint(false);
addPoint(false);
for ( i = 0; i < code.length; i++ )
addPoint(code[i][j]);
addPoint(false);
addPoint(false);
newLine();
}
for ( i = 0; i < 2; i++ ) {
for ( j = 0; j < code.length; j++ ) addPoint(false);
newLine();
}
$("#qrCode").html(rst);
};
</script>
</head>
<body>
<h3><a href="https://github.com/lymar/libqrencode-js">libqrencode-js</a> demo</h3>
<textarea id="qrText">hello, world</textarea>
<br/>
<button id="genButton">Generate</button>
<br/>
<div id="qrCode"></div>
</body>
</html>