diff --git a/.eslintrc.json b/.eslintrc.json index 195c0ed6..a31962b9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,8 +10,6 @@ }, "rules": { "max-len": 0, - "no-undef": 0, - "one-var": 0, - "vars-on-top": 0 + "no-undef": 0 } } diff --git a/modules/jquery.qrcode.js b/modules/jquery.qrcode.js index 0510afe1..801aa29d 100644 --- a/modules/jquery.qrcode.js +++ b/modules/jquery.qrcode.js @@ -1,5 +1,7 @@ ( function ( $ ) { $.fn.qrcode = function ( options ) { + var createCanvas, createTable; + // if options is string, if ( typeof options === 'string' ) { options = { text: options }; @@ -17,28 +19,30 @@ foreground: '#000000' }, options ); - var createCanvas = function () { + createCanvas = function () { + var qrcode, canvas, ctx, tileW, tileH, row, col, w, h; + // create the qrcode itself - var qrcode = new QRCode( options.typeNumber, options.correctLevel ); + qrcode = new QRCode( options.typeNumber, options.correctLevel ); qrcode.addData( options.text ); qrcode.make(); // create canvas element - var canvas = document.createElement( 'canvas' ); + canvas = document.createElement( 'canvas' ); canvas.width = options.width; canvas.height = options.height; - var ctx = canvas.getContext( '2d' ); + 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(); + tileW = options.width / qrcode.getModuleCount(); + 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++ ) { + for ( row = 0; row < qrcode.getModuleCount(); row++ ) { + for ( col = 0; col < qrcode.getModuleCount(); col++ ) { ctx.fillStyle = qrcode.isDark( row, col ) ? options.foreground : options.background; - var w = ( Math.ceil( ( col + 1 ) * tileW ) - Math.floor( col * tileW ) ); - var h = ( Math.ceil( ( row + 1 ) * tileW ) - Math.floor( row * tileW ) ); + w = ( Math.ceil( ( col + 1 ) * tileW ) - Math.floor( col * tileW ) ); + h = ( Math.ceil( ( row + 1 ) * tileW ) - Math.floor( row * tileW ) ); ctx.fillRect( Math.round( col * tileW ), Math.round( row * tileH ), w, h ); } } @@ -47,14 +51,16 @@ }; // from Jon-Carlos Rivera (https://github.com/imbcmdth) - var createTable = function () { + createTable = function () { + var qrcode, $table, tileW, tileH, row, col, $row; + // create the qrcode itself - var qrcode = new QRCode( options.typeNumber, options.correctLevel ); + qrcode = new QRCode( options.typeNumber, options.correctLevel ); qrcode.addData( options.text ); qrcode.make(); // create table element - var $table = $( '