Skip to content
Browse files

more work

  • Loading branch information...
1 parent e792016 commit e7741e99e753b4eebfbe657409a04cab86c15490 @jeromeetienne committed
Showing with 25 additions and 38 deletions.
  1. +4 −2 README.md
  2. +15 −0 examples/basic.html
  3. +0 −28 examples/index.html
  4. +3 −3 index.html
  5. +3 −5 src/jquery.qrcode.js
View
6 README.md
@@ -2,7 +2,9 @@
With jQuery.qrcode.js you can easily add qrcode to your webpages.
It is standalone, no external services which go on and off, or add latency
-while loading.
+while loading. It is based on a <a href='http://www.d-project.com/qrcode/index.html'>library</a>
+which build qrcode in various language. jQuery.qrcode.js wraps it to make it easy
+to include in your own code.
Show, dont tell, here is a <a href='examples/demo.html'>demo</a>
@@ -21,7 +23,7 @@ Then you add the *qrcode* in this container by
jQuery('#qrcode').qrcode("this plugin is great");
-This is it.
+This is it. see it <a href='examples/basic.html'>live</a>.
## Conclusion
View
15 examples/basic.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+<title>basic example</title>
+</head>
+<body>
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
+<script type="text/javascript" src="../jquery.qrcode.min.js"></script>
+
+<div id="qrcode"></div>
+<script>
+ jQuery('#qrcode').qrcode("this plugin is great");
+</script>
+
+</body>
+</html>
View
28 examples/index.html
@@ -1,28 +0,0 @@
-<html>
-<head>
-<title>basic example</title>
-
-</head>
-<body>
-<p>
- TODO make a nice looking pure client qrcode generator
- even allow download of the image
-</p>
-<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
-<!--<script type="text/javascript" src="../src/jquery.qrcode.js"></script>
-<script type="text/javascript" src="../src/qrcode.js"></script>
--->
-
-<script type="text/javascript" src="../jquery.qrcode.min.js"></script>
-
-<div id="output"></div>
-<script>
-jQuery(function(){
- jQuery('#output').qrcode({
- text : "http://jetienne.com"
- })
-})
-</script>
-
-</body>
-</html>
View
6 index.html
@@ -11,7 +11,7 @@
><h1
>jQuery.qrcode.js</h1
><p
- >With jQuery.qrcode.js you can easily add qrcode to your webpages. It is standalone, no external services which go on and off, or add latency while loading.</p
+ >With jQuery.qrcode.js you can easily add qrcode to your webpages. It is standalone, no external services which go on and off, or add latency while loading. It is based on a <a href='http://www.d-project.com/qrcode/index.html'>library</a> which build qrcode in various language. jQuery.qrcode.js wraps it to make it easy to include in your own code.</p
><p
>Show, dont tell, here is a <a href='examples/demo.html'>demo</a></p
><div id="how-to-use-it"
@@ -41,13 +41,13 @@
</code
></pre
><p
- >This is it.</p
+ >This is it. see it <a href='examples/basic.html'>live</a>.</p
></div
><div id="conclusion"
><h2
>Conclusion</h2
><p
- >MicroEvent.js is available on github <a href='https://github.com/jeromeetienne/jquery-qrcode'>here</a> under <a href='https://github.com/jeromeetienne/microevent.js/blob/master/MIT-LICENSE.txt'>MIT license</a>. If you hit bugs, fill issues on github. Feel free to fork, modify and have fun with it :)</p
+ >MicroEvent.js is available on github <a href='https://github.com/jeromeetienne/jquery-qrcode'>here</a> under <a href='https://github.com/jeromeetienne/jquery-qrcode.js/blob/master/MIT-LICENSE.txt'>MIT license</a>. If you hit bugs, fill issues on github. Feel free to fork, modify and have fun with it :)</p
></div
></div
>
View
8 src/jquery.qrcode.js
@@ -1,6 +1,5 @@
(function( $ ){
$.fn.qrcode = function(options) {
-
// if options is string,
if( typeof options === 'string' ){
options = { text: options };
@@ -19,16 +18,15 @@
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();
+ // compute tileW/tileH based on options.width/options.height
+ var tileW = options.width / qrcode.getModuleCount();
var tileH = options.height / qrcode.getModuleCount();
-
+ // draw in the canvas
for( var row = 0; row < qrcode.getModuleCount(); row++ ){
for( var col = 0; col < qrcode.getModuleCount(); col++ ){
ctx.fillStyle = qrcode.isDark(row, col) ? "#000000" : "#ffffff";

0 comments on commit e7741e9

Please sign in to comment.
Something went wrong with that request. Please try again.