Skip to content

Commit 6cf004f

Browse files
committed
cleanup + folder refactoring
1 parent 9cd4d87 commit 6cf004f

File tree

6 files changed

+1134
-34
lines changed

6 files changed

+1134
-34
lines changed

README renamed to Makefile

File renamed without changes.

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# jQuery.qrcode.js
2+
3+
with jQuery.qrcode.js you can easily add qrcode to your webpages.
4+
5+
jQuery("#container").qrcode("this plugin is great")
6+
7+
It is standalone, no external services which go on and off, or add latency
8+
while loading.

examples/index.html

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<html>
2+
<head>
3+
<title>Petite démo de QRCode</title>
4+
5+
<!--[if IE]><script src="excanvas.js"></script><![endif]-->
6+
<script type="text/javascript" src="qrcode.js"></script>
7+
<script type="text/javascript" src="qrcanvas.js"></script>
8+
9+
</head>
10+
<body>
11+
12+
<h1>Un petit message</h1>
13+
<div id="qr_msg">
14+
</div>
15+
16+
<h1>L'URL de mon site</h1>
17+
<div id="qr_url">
18+
</div>
19+
20+
<script type="text/javascript">
21+
//var d=new Date();
22+
//append_qrcode(9,"qr_msg","Thanks for generating this on "+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()+' '+d.getHours()+':'+d.getMinutes()+':'+d.getSeconds()+"\nI hope you enjoyed it!\n--\nCipher Brain SPRL");
23+
//
24+
//append_qrcode(4,"qr_url","http://jetienne.com");
25+
</script>
26+
27+
<hr />
28+
Note: pour lire ceci depuis Android, je recommande l'application <tt>Bar Code Scanner</tt> de ZXing Team.
29+
30+
31+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
32+
<script type="text/javascript" src="jquery.qrcode.js"></script>
33+
34+
<div id="output"></div>
35+
<script>
36+
jQuery(function(){
37+
jQuery('#output').qrcode({
38+
text : "http://jetienne.com"
39+
})
40+
})
41+
</script>
42+
43+
</body>
44+
</html>

jquery.qrcode.js

-34
This file was deleted.

src/jquery.qrcode.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
(function( $ ){
2+
$.fn.qrcode = function(options) {
3+
4+
// if options is string,
5+
if( typeof options === 'string' ){
6+
options = { text: options };
7+
}
8+
9+
// set default values
10+
options = $.extend( {}, {
11+
width : 256,
12+
height : 256,
13+
typeNumber : 4,
14+
correctLevel : QRErrorCorrectLevel.H
15+
}, options);
16+
17+
var createCanvas = function(){
18+
// create the qrcode itself
19+
var qrcode = new QRCode(options.typeNumber, options.correctLevel);
20+
qrcode.addData(options.text);
21+
qrcode.make();
22+
23+
// create canvas element
24+
var canvas = document.createElement('canvas');
25+
canvas.width = options.width;
26+
canvas.height = options.height;
27+
var ctx = canvas.getContext('2d');
28+
29+
var tileW = options.width / qrcode.getModuleCount();
30+
var tileH = options.height / qrcode.getModuleCount();
31+
32+
for( var row = 0; row < qrcode.getModuleCount(); row++ ){
33+
for( var col = 0; col < qrcode.getModuleCount(); col++ ){
34+
ctx.fillStyle = qrcode.isDark(row, col) ? "#000000" : "#ffffff";
35+
ctx.fillRect( col*tileW, row*tileH, tileW, tileH );
36+
}
37+
}
38+
// return just built canvas
39+
return canvas;
40+
}
41+
42+
return this.each(function(){
43+
var canvas = createCanvas();
44+
jQuery(canvas).appendTo(this);
45+
});
46+
};
47+
})( jQuery );

0 commit comments

Comments
 (0)