Permalink
Browse files

fix error in table renderer

  • Loading branch information...
1 parent 98d788a commit 7cfa67a142aedaa540f301baadc969f6e12fc827 @jeromeetienne committed Nov 11, 2011
Showing with 8 additions and 9 deletions.
  1. +4 −1 examples/basic.html
  2. +4 −8 src/jquery.qrcode.js
View
5 examples/basic.html
@@ -4,7 +4,10 @@
</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>
+
+<!--<script type="text/javascript" src="../jquery.qrcode.min.js"></script>
+--><script type="text/javascript" src="../src/jquery.qrcode.js"></script>
+<script type="text/javascript" src="../src/qrcode.js"></script>
<div id="qrcode"></div>
<script>
View
12 src/jquery.qrcode.js
@@ -48,30 +48,26 @@
var qrcode = new QRCode(options.typeNumber, options.correctLevel);
qrcode.addData(options.text);
qrcode.make();
-
- var border_width = (options.width + options.height) / 20; // 10% of the average(width, height)
-
// create table element
var $table = $('<table></table>')
.css("width", options.width+"px")
.css("height", options.height+"px")
.css("border", "0px")
.css("border-collapse", "collapse")
- //.css("margin", border_width+"px")
.css('background-color', "#ffffff");
// compute tileS percentage
- var tileW = 100 / qrcode.getModuleCount();
- var tileH = 100 / qrcode.getModuleCount();
+ var tileW = options.width / qrcode.getModuleCount();
+ var tileH = options.height / qrcode.getModuleCount();
// draw in the table
for(var row = 0; row < qrcode.getModuleCount(); row++ ){
- var $row = $('<tr></tr>').css('height', tileH+"%").appendTo($table);
+ var $row = $('<tr></tr>').css('height', tileH+"px").appendTo($table);
for(var col = 0; col < qrcode.getModuleCount(); col++ ){
$('<td></td>')
- .css('width', tileW+"%")
+ .css('width', tileW+"px")
.css('background-color', qrcode.isDark(row, col) ? "#000000" : "#ffffff")
.appendTo($row);
}

0 comments on commit 7cfa67a

Please sign in to comment.