cleanup + folder refactoring
This commit is contained in:
parent
9cd4d877ff
commit
6cf004f07e
6 changed files with 1134 additions and 34 deletions
8
README.md
Normal file
8
README.md
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# jQuery.qrcode.js
|
||||
|
||||
with jQuery.qrcode.js you can easily add qrcode to your webpages.
|
||||
|
||||
jQuery("#container").qrcode("this plugin is great")
|
||||
|
||||
It is standalone, no external services which go on and off, or add latency
|
||||
while loading.
|
||||
44
examples/index.html
Normal file
44
examples/index.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Petite démo de QRCode</title>
|
||||
|
||||
<!--[if IE]><script src="excanvas.js"></script><![endif]-->
|
||||
<script type="text/javascript" src="qrcode.js"></script>
|
||||
<script type="text/javascript" src="qrcanvas.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Un petit message</h1>
|
||||
<div id="qr_msg">
|
||||
</div>
|
||||
|
||||
<h1>L'URL de mon site</h1>
|
||||
<div id="qr_url">
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
//var d=new Date();
|
||||
//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");
|
||||
//
|
||||
//append_qrcode(4,"qr_url","http://jetienne.com");
|
||||
</script>
|
||||
|
||||
<hr />
|
||||
Note: pour lire ceci depuis Android, je recommande l'application <tt>Bar Code Scanner</tt> de ZXing Team.
|
||||
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="jquery.qrcode.js"></script>
|
||||
|
||||
<div id="output"></div>
|
||||
<script>
|
||||
jQuery(function(){
|
||||
jQuery('#output').qrcode({
|
||||
text : "http://jetienne.com"
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
(function( $ ){
|
||||
$.fn.qrcode = function(options) {
|
||||
|
||||
var createCanvas = function(text, typeNumber){
|
||||
var tileW = 4;
|
||||
|
||||
// create the qrcode itself
|
||||
var qrcode = new QRCode(typeNumber, QRErrorCorrectLevel.H);
|
||||
qrcode.addData(text);
|
||||
qrcode.make();
|
||||
|
||||
// create canvas element
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = canvas.height = qrcode.getModuleCount()*tileW;
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
for( var row = 0; row < qrcode.getModuleCount(); row++ ){
|
||||
for( var col = 0; col < qrcode.getModuleCount(); col++ ){
|
||||
ctx.fillStyle = qrcode.isDark(row, col) ? "#000000" : "#ffffff";
|
||||
ctx.fillRect( col*tileW, row*tileW, tileW, tileW );
|
||||
}
|
||||
}
|
||||
// return just built canvas
|
||||
return canvas;
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
var $this = $(this);
|
||||
|
||||
var canvas = createCanvas("http://jetienne.com", 4);
|
||||
jQuery(canvas).appendTo($this);
|
||||
});
|
||||
};
|
||||
})( jQuery );
|
||||
47
src/jquery.qrcode.js
Normal file
47
src/jquery.qrcode.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
(function( $ ){
|
||||
$.fn.qrcode = function(options) {
|
||||
|
||||
// if options is string,
|
||||
if( typeof options === 'string' ){
|
||||
options = { text: options };
|
||||
}
|
||||
|
||||
// set default values
|
||||
options = $.extend( {}, {
|
||||
width : 256,
|
||||
height : 256,
|
||||
typeNumber : 4,
|
||||
correctLevel : QRErrorCorrectLevel.H
|
||||
}, options);
|
||||
|
||||
var createCanvas = function(){
|
||||
// create the qrcode itself
|
||||
var qrcode = new QRCode(options.typeNumber, options.correctLevel);
|
||||
qrcode.addData(options.text);
|
||||
qrcode.make();
|
||||
|
||||
// create canvas element
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = options.width;
|
||||
canvas.height = options.height;
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
var tileW = options.width / qrcode.getModuleCount();
|
||||
var tileH = options.height / qrcode.getModuleCount();
|
||||
|
||||
for( var row = 0; row < qrcode.getModuleCount(); row++ ){
|
||||
for( var col = 0; col < qrcode.getModuleCount(); col++ ){
|
||||
ctx.fillStyle = qrcode.isDark(row, col) ? "#000000" : "#ffffff";
|
||||
ctx.fillRect( col*tileW, row*tileH, tileW, tileH );
|
||||
}
|
||||
}
|
||||
// return just built canvas
|
||||
return canvas;
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
var canvas = createCanvas();
|
||||
jQuery(canvas).appendTo(this);
|
||||
});
|
||||
};
|
||||
})( jQuery );
|
||||
1035
src/qrcode.js
Normal file
1035
src/qrcode.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue