Compare commits

..

3 commits

Author SHA1 Message Date
Jerome Etienne
6d406f4df2 Merge pull request #39 from ccotter/gh-pages
Fix 'forkme' banner on github pages
2013-03-23 15:30:16 -07:00
Chris Cotter
4f169be943 fix 'forkme' banner src 2013-03-20 15:37:14 -05:00
Jerome Etienne
f7e2a850b9 New deploy 2012-03-27 11:12:27 +02:00
4 changed files with 15 additions and 34 deletions

View file

@ -9,7 +9,7 @@ It is based on a <a href='http://www.d-project.com/qrcode/index.html'>library</a
which build qrcode in various language. <a href='http://jeromeetienne.github.com/jquery-qrcode'>jquery.qrcode.js</a> wraps which build qrcode in various language. <a href='http://jeromeetienne.github.com/jquery-qrcode'>jquery.qrcode.js</a> wraps
it to make it easy to include in your own code. it to make it easy to include in your own code.
Show, dont tell, here is a <a href='https://github.com/jeromeetienne/jquery-qrcode/blob/master/examples/basic.html'>example</a> Show, dont tell, here is a <a href='examples/basic.html'>example</a>
## How to Use It ## How to Use It

View file

@ -11,7 +11,7 @@
<p>Render in table</p> <p>Render in table</p>
<div id="qrcodeTable"></div> <div id="qrcodeTable"></div>
<p>Render in canvas</p> <p>Render in canvas</p>
<div id="qrcodeCanvas"></div> <div id="qrcodeCanvas"></div>
<script> <script>
//jQuery('#qrcode').qrcode("this plugin is great"); //jQuery('#qrcode').qrcode("this plugin is great");

View file

@ -147,7 +147,7 @@ img {
<img style="position: absolute; bottom: 10px; right: 10px; border: 0;" src="http://twitter-badges.s3.amazonaws.com/follow_me-c.png" alt="Follow jerome_etienne on Twitter"/> <img style="position: absolute; bottom: 10px; right: 10px; border: 0;" src="http://twitter-badges.s3.amazonaws.com/follow_me-c.png" alt="Follow jerome_etienne on Twitter"/>
</a> </a>
<!-- github ribbon --> <!-- github ribbon -->
<a href="https://github.com/jeromeetienne/jquery-qrcode"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://assets0.github.com/img/ce742187c818c67d98af16f96ed21c00160c234a?repo=&url=http%3A%2F%2Fs3.amazonaws.com%2Fgithub%2Fribbons%2Fforkme_left_gray_6d6d6d.png&path=" alt="Fork me on GitHub"></a> <a href="https://github.com/jeromeetienne/jquery-qrcode"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_left_gray_6d6d6d.png" alt="Fork me on GitHub" /></a>
<!-- twitter share + facebook like --> <!-- twitter share + facebook like -->
<div style="position: absolute; top: 10px; right: 10px; border: 0;"> <div style="position: absolute; top: 10px; right: 10px; border: 0;">

View file

@ -11,7 +11,6 @@
render : "canvas", render : "canvas",
width : 256, width : 256,
height : 256, height : 256,
margin : 4,
typeNumber : -1, typeNumber : -1,
correctLevel : QRErrorCorrectLevel.H, correctLevel : QRErrorCorrectLevel.H,
background : "#ffffff", background : "#ffffff",
@ -31,24 +30,15 @@
var ctx = canvas.getContext('2d'); var ctx = canvas.getContext('2d');
// compute tileW/tileH based on options.width/options.height // compute tileW/tileH based on options.width/options.height
var margin = options.margin; var tileW = options.width / qrcode.getModuleCount();
var tileW = options.width / (qrcode.getModuleCount() + 2*options.margin); var tileH = options.height / qrcode.getModuleCount();
var tileH = options.height / (qrcode.getModuleCount() + 2*options.margin);
var isDark = function(x, y) {
x -= margin; y -= margin;
if(x < 0 || x >= qrcode.getModuleCount() || y < 0 || y >= qrcode.getModuleCount())
return false;
else
return qrcode.isDark(x, y);
}
// draw in the canvas // draw in the canvas
for( var row = 0; row < qrcode.getModuleCount()+2*margin; row++ ){ for( var row = 0; row < qrcode.getModuleCount(); row++ ){
for( var col = 0; col < qrcode.getModuleCount()+2*margin; col++ ){ for( var col = 0; col < qrcode.getModuleCount(); col++ ){
ctx.fillStyle = isDark(row, col) ? options.foreground : options.background; ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background;
var w = (Math.ceil((col+1)*tileW) - Math.floor(col*tileW)); var w = (Math.ceil((col+1)*tileW) - Math.floor(col*tileW));
var h = (Math.ceil((row+1)*tileH) - Math.floor(row*tileH)); var h = (Math.ceil((row+1)*tileW) - Math.floor(row*tileW));
ctx.fillRect(Math.round(col*tileW),Math.round(row*tileH), w, h); ctx.fillRect(Math.round(col*tileW),Math.round(row*tileH), w, h);
} }
} }
@ -72,26 +62,17 @@
.css('background-color', options.background); .css('background-color', options.background);
// compute tileS percentage // compute tileS percentage
var margin = options.margin; var tileW = options.width / qrcode.getModuleCount();
var tileW = options.width / (qrcode.getModuleCount() + 2*margin); var tileH = options.height / qrcode.getModuleCount();
var tileH = options.height / (qrcode.getModuleCount() + 2*margin);
var isDark = function(x, y) {
x -= margin; y -= margin;
if(x < 0 || x >= qrcode.getModuleCount() || y < 0 || y >= qrcode.getModuleCount())
return false;
else
return qrcode.isDark(x, y);
}
// draw in the table // draw in the table
for(var row = 0; row < (qrcode.getModuleCount() + 2*margin); row++ ){ for(var row = 0; row < qrcode.getModuleCount(); row++ ){
var $row = $('<tr></tr>').css('height', tileH+"px").appendTo($table); var $row = $('<tr></tr>').css('height', tileH+"px").appendTo($table);
for(var col = 0; col < (qrcode.getModuleCount() + 2*margin); col++ ){ for(var col = 0; col < qrcode.getModuleCount(); col++ ){
$('<td></td>') $('<td></td>')
.css('width', tileW+"px") .css('width', tileW+"px")
.css('background-color', isDark(row, col) ? options.foreground : options.background) .css('background-color', qrcode.isDark(row, col) ? options.foreground : options.background)
.appendTo($row); .appendTo($row);
} }
} }
@ -102,7 +83,7 @@
return this.each(function(){ return this.each(function(){
var element = options.render == "canvas" ? createCanvas() : createTable(); var element = options.render == "canvas" ? createCanvas() : createTable();
$(element).appendTo(this); jQuery(element).appendTo(this);
}); });
}; };
})( jQuery ); })( jQuery );