diff --git a/application.coffee b/application.coffee index efbaec8..215c470 100644 --- a/application.coffee +++ b/application.coffee @@ -5,6 +5,9 @@ $ -> text = window.location.hash.substring 1 $('textarea').val text generateQRCode() + $('a', '#download').bind 'click', -> + window.location.href = $('canvas', '#qrarea')[0].toDataURL('image/png').replace('image/png', 'image/octet-stream') + if window.location.hash $(window).trigger 'hashchange' generateQRCode() diff --git a/application.js b/application.js index 6cae806..c40779e 100644 --- a/application.js +++ b/application.js @@ -10,6 +10,9 @@ $('textarea').val(text); return generateQRCode(); }); + $('a', '#download').bind('click', function() { + return window.location.href = $('canvas', '#qrarea')[0].toDataURL('image/png').replace('image/png', 'image/octet-stream'); + }); if (window.location.hash) $(window).trigger('hashchange'); return generateQRCode(); }); diff --git a/index.html b/index.html index 84f24ae..ca9aee9 100644 --- a/index.html +++ b/index.html @@ -24,6 +24,7 @@

+
(Download QRCode as PNG)
Fork me on GitHub diff --git a/style.css b/style.css index bd58d48..ee3726d 100644 --- a/style.css +++ b/style.css @@ -58,6 +58,12 @@ input { width: 256px; } +#download { + font-size: 0.9em; + text-align: center; + margin: 0.5em; +} + #footer { border-top: 1px dotted #eee; color: rgba(204, 204, 204, 0.8);