more work
This commit is contained in:
parent
e79201608a
commit
e7741e99e7
5 changed files with 25 additions and 38 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
15
examples/basic.html
Normal file
15
examples/basic.html
Normal file
|
|
@ -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>
|
||||
|
|
@ -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>
|
||||
|
|
@ -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
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
// 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";
|
||||
|
|
|
|||
Loading…
Reference in a new issue