Permalink
Browse files

cleanup + folder refactoring

  • Loading branch information...
1 parent 9cd4d87 commit 6cf004f07e4d93b8ac48b20e217ffe2ef3621874 @jeromeetienne committed Apr 7, 2011
Showing with 1,134 additions and 34 deletions.
  1. 0 README → Makefile
  2. +8 −0 README.md
  3. +44 −0 examples/index.html
  4. +0 −34 jquery.qrcode.js
  5. +47 −0 src/jquery.qrcode.js
  6. +1,035 −0 src/qrcode.js
View
File renamed without changes.
View
@@ -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.
View
@@ -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>
View
@@ -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 );
View
@@ -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 );
Oops, something went wrong.

0 comments on commit 6cf004f

Please sign in to comment.