-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbarcode.html
82 lines (56 loc) · 1.64 KB
/
barcode.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style type="text/css">
* {padding:0; margin:0;}
svg {border:1px #eee solid; display:inline-block; float:left;}
</style>
<script src="barcode.min.js"></script>
</head>
<body>
<script>
'use strict';
var
barcodes = [
BARCode({
msg : '128 Barcode'
,dim : [ 80, 352 ] /* vertical */
,pad : [ 16, 20 ] /* padding */
,pal : ['#037','#cef'] /* palette */
})
,BARCode('RC123456789US') /* simple */
,BARCode({
msg : 'autowidth'
,dim : [ 0, 80 ] /* autowidth depends on the length of generated barcode. */
,pal : ['#037','#eef']
})
,BARCode({
msg : 'demo'
,dim : [ 0, 80 ]
,pal : ['#17e'] /* transparent background */
})
,BARCode({
msg : 'padding'
,dim : [ 0, 80 ]
,pad : [ 16, 30 ] /* padding */
,pal : ['#037','#cef']
})
];
/* do not try this at home... */
for( var c = 0; c < 500; c++ ) {
barcodes.push(
BARCode({
msg : ['1','2','3','4','5','6','7','8','9','0','bar','code','generator','git','hub','datalog','simple','poetry','cool','128bit','java','script','awesome'][ Math.floor( Math.random() * 23 ) ]
,dim : [ [ 0, 88, 120, 200, 320 ][ Math.floor( Math.random() * 5 ) ], 80 ]
,pad : [ [ 6, 8, 10, 12, 14, 16 ][ Math.floor( Math.random() * 6 ) ], [ 16, 18, 20, 22, 28 ][ Math.floor( Math.random() * 5 ) ] ]
,pal : ['#' + Math.floor( Math.random() * 16777215 ).toString( 16 ) ] /* it MUST generate invalid color codes sometimes */
})
);
}
for( var c = 0; c < barcodes.length; c++ ) {
document.body.appendChild( barcodes[ c ] );
}
</script>
</body>
</html>