Canvas/table id #22

Anjen1 opened this Issue Apr 2, 2012 · 3 comments


None yet
2 participants

Anjen1 commented Apr 2, 2012


I realize it's easy enough to patch or modify by other means, but it would be nice if the canvas/table id was settable from the command (ie, container_id : 'some text')

The id is nice to have since it makes the object produced by qrcode more easily addressable from secondary or post-processing functions. For instance, I'm pushing the output through a canvas-to-png function right after the QRcode is generated, and the processor wants to access the canvas by id. Needless to say, having the id in place saves a teeny bit of "footwork".

the mod for the canvas is quite simple and...
(starting on line 26 current version...)

26 // create canvas element
27 var canvas = document.createElement('canvas');
28 canvas.width = options.width;
29 canvas.height = options.height;
*30 >>> = "canvas";

and the table mod goes just below in the section that creates the table wrapper.


jeromeetienne commented Apr 2, 2012

can you do a pull request ? and make the id optional in the options. an hardcoded value wont be too flexible

Anjen1 commented Apr 2, 2012

Oh...right. my bad. I agree completely. I was thinking *default values when I typed in the field and meant to show that as an option instead of the fixed value, where the option would be "container_id" or something along those lines.

30 = options.container_id

~line 12 container_id : 'qrCode' (or similar generic default identifier)

and the table looks like it would be fixed by simply appending an attr() call to the end of the css sets

(starting around line 59)
var $table = $('<.table></.table>')
.css("width", options.width+"px")
.css("height", options.height+"px")
.css("border", "0px")
.css("border-collapse", "collapse")
.css('background-color', options.background)

                   .attr('id', options.container_id);

If by pull request you mean for me to change the code and upload back here, I'd be glad to, but I'm kinda newbishly clueless on the collaboration process, (team of one for the most part) so I really don't know how to accomplish it correctly, although willing to learn. If you simply meant for me to grab the source, I have it and have made the changes locally.


jeromeetienne commented Apr 2, 2012

pull request is the way to contribute code on github. you can have more doc here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment