Permalink
Browse files

Initialise

  • Loading branch information...
0 parents commit 7360e38286d375e47b42ae8e0fa71b14be7eafbe @AliasIO committed Dec 30, 2013
@@ -0,0 +1 @@
+conf/imgur.js
@@ -0,0 +1,3 @@
+[submodule "lib/jquery-qrcode"]
+ path = lib/jquery-qrcode
+ url = https://github.com/jeromeetienne/jquery-qrcode.git
Oops, something went wrong.
@@ -0,0 +1 @@
+[bitcoinqrcode.org](http://bitcoinqrcode.org)
@@ -0,0 +1 @@
+var IMGUR_CLIENT_ID = '';
@@ -0,0 +1,75 @@
+h1 {
+ margin-top: 100px;
+}
+
+form {
+ margin: 20px 0;
+}
+
+#qrcode {
+ display: none;
+}
+
+#qrcodes {
+ margin: 30px 0;
+}
+
+#qrcodes div {
+ display: inline-block;
+ position: relative;
+ margin: 0 .5em .5em 0;
+}
+
+#qrcodes .spinner {
+ background: url('../img/spinner.gif') center center no-repeat rgba(255, 255, 255, .8);
+ bottom: 0;
+ left: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+#qrcodes .link {
+ background: rgba(255, 255, 255, .8);
+ bottom: 0;
+ left: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+#qrcodes .link input {
+ left: 5%;
+ margin-top: -17px;
+ position: absolute;
+ text-align: center;
+ top: 50%;
+ width: 90%;
+}
+
+#qrcodes canvas {
+ box-shadow: 0 0 5px rgba(0, 0, 0, .5);
+ -moz-box-shadow: 0 0 5px rgba(0, 0, 0, .5);
+ -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .5);
+ cursor: pointer;
+ display: block !important;
+ padding: 1px;
+ margin: 0 .5em .5em 0;
+}
+
+#fork {
+ background: url('../img/fork.png') right top no-repeat;
+ display: block;
+ height: 149px;
+ position: absolute;
+ right: 0;
+ text-indent: -99999px;
+ top 0;
+ width: 149px;
+}
+
+footer {
+ color: #999;
+ font-size: small;
+ margin-bottom: 100px;
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <meta charset="utf-8">
+
+ <title>Bitcoin QR Code Generator</title>
+
+ <meta name="description" content="">
+ <meta name="keywords" content="">
+
+ <link rel="stylesheet" href="lib/foundation/foundation.min.css">
+ <link rel="stylesheet" href="css/bitcoinqrcode.css">
+ </head>
+ <body>
+ <div class="row">
+ <div class="large-12 columns">
+ <h1>Bitcoin QR Code Generator</h1>
+
+ <p>Click a <a href="http://en.wikipedia.org/wiki/QR_code">QR code</a> to upload it to <a href="http://imgur.com">Imgur</a>. Find out more about <a href="http://bitcoin.org/">Bitcoin</a>.</p>
+
+ <form method="post">
+ <div class="row">
+ <div class="large-9 columns">
+ <label for="address">Bitcoin address:</label>
+
+ <input id="address" type="text" placeholder="18Vm8AvDr9Bkvij6UfVR7MerCyrz3KS3h4">
+ </div>
+ <div class="large-3 columns">
+ <label for="size">Size (px):</label>
+
+ <input id="size" type="text" placeholder="250" value="250">
+ </div>
+ </div>
+ </form>
+
+ <div id="qrcodes"></div>
+
+ <hr>
+
+ <footer>
+ By <a href="http://alias.io">Elbert Alias</a>. Donate Bitcoin: 18Vm8AvDr9Bkvij6UfVR7MerCyrz3KS3h4 <em>&mdash; Thanks!</em>
+
+ <br><br>
+
+ <img src="img/donate.png">
+ <footer>
+
+ <div id="qrcode"></div>
+ </div>
+
+ <a id="fork" href="https://github.com/you">Fork me on Github</a>
+
+ <script src="lib/jquery/jquery-2.0.3.min.js"></script>
+ <script src="lib/jquery-qrcode/src/qrcode.js"></script>
+ <script src="lib/jquery-qrcode/src/jquery.qrcode.js"></script>
+ <script src="conf/imgur.js"></script>
+ <script src="js/bitcoinqrcode.js"></script>
+
+ <!-- Piwik -->
+ <script type="text/javascript">
+ var _paq = _paq || [];
+ _paq.push(["trackPageView"]);
+ _paq.push(["enableLinkTracking"]);
+
+ (function() {
+ var u=(("https:" == document.location.protocol) ? "https" : "http") + "://piwik.alias.io/";
+ _paq.push(["setTrackerUrl", u+"piwik.php"]);
+ _paq.push(["setSiteId", "6"]);
+ var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
+ g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
+ })();
+ </script>
+ <!-- End Piwik Code -->
+ </body>
+</html>
@@ -0,0 +1,152 @@
+(function() {
+ var app, App;
+
+ App = function() {
+ var self = this;
+
+ this.pixels = 37;
+
+ this.sizes = [
+ this.pixels * 6,
+ this.pixels * 3,
+ this.pixels * 2,
+ ];
+
+ this.overlays = [
+ 'pixel.png',
+ 'bitcoin-icon.png',
+ 'bitcoin-coin.png',
+ 'bitcoin-logo.png',
+ 'bitcoin-8bit.png',
+ 'litecoin-coin.png'
+ ];
+
+ this.address = '';
+ this.size = 0;
+
+ $('#qrcodes').on('click', 'input', function() {
+ $(this).select();
+ });
+
+ $('#address, #size').on('change blur keyup mouseup', function() {
+ var
+ address = $('#address').val(),
+ size = Math.min(600, Math.max(100, parseInt($('#size').val())));
+
+ if ( !address ) {
+ address = $('#address').attr('placeholder');
+ }
+
+ if ( !size ) {
+ size = parseInt($('#size').attr('placeholder'), 10);
+ }
+
+ if ( ( address.length >= 27 && address.length <= 34 && address !== self.address ) || ( size && size !== self.size ) ) {
+ $('#qrcode, #qrcodes').html('');
+
+ self.address = address;
+ self.size = size;
+
+ self.update();
+ }
+ })
+ .trigger('change');
+ }
+
+ App.prototype.update = function() {
+ var
+ self = this,
+ qrcode;
+
+ $('#qrcode').qrcode({
+ text: 'bitcoin:' + this.address,
+ width: this.pixels * 26,
+ height: this.pixels * 26
+ });
+
+ qrcode = $('#qrcode canvas').get(0);
+
+ $(self.overlays).each(function(i, overlay) {
+ var
+ canvas = $('<canvas>').get(0),
+ context = canvas.getContext('2d'),
+ size = Math.floor(self.size / self.pixels) * self.pixels
+ offset = Math.floor(( self.size - size ) / 2);
+
+ canvas.width = self.size;
+ canvas.height = self.size;
+
+ context.imageSmoothingEnabled = false;
+ context.mozImageSmoothingEnabled = false;
+ context.webkitImageSmoothingEnabled = false;
+
+ context.drawImage(qrcode, offset, offset, size, size);
+
+ (function() {
+ var image = new Image();
+
+ image.src = 'img/' + overlay;
+
+ $(image).on('load', function() {
+ var wrap = $('<div>');
+
+ context.drawImage(image, offset, offset, size, size);
+
+ $(canvas)
+ .on('click', function() {
+ self.imgur(canvas);
+ })
+ .appendTo(wrap)
+ .show()
+
+ wrap.appendTo('#qrcodes');
+ });
+ }());
+ });
+ };
+
+ App.prototype.imgur = function(canvas) {
+ var
+ image
+ spinner = $('<div class="spinner">');
+
+ spinner.appendTo($(canvas).parent());
+
+ try {
+ var image = canvas.toDataURL('image/png').split(',')[1];
+ } catch(e) {
+ var image = canvas.toDataURL().split(',')[1];
+ }
+
+ $.ajax({
+ url: 'https://api.imgur.com/3/image',
+ type: 'POST',
+ headers: {
+ 'Authorization': 'Client-ID ' + IMGUR_CLIENT_ID
+ },
+ data: {
+ type: 'base64',
+ title: this.address,
+ description: 'Via bitcoinqrcode.org',
+ image: image
+ },
+ dataType: 'json'
+ })
+ .success(function(data) {
+ spinner.hide();
+
+ link = $('<div class="link"><input type="text" value="' + data.data.link + '"></div>');
+
+ link.appendTo($(canvas).parent());
+ })
+ .error(function() {
+ spinner.hide();
+
+ alert('Sorry, the image could not be uploaded. We probably hit Imgur\'s upload limit.\n\nYou can still download the image and upload it yourself.');
+ });
+ }
+
+ $(function() {
+ app = new App();
+ });
+}());
Oops, something went wrong.
Submodule jquery-qrcode added at bf626b
Oops, something went wrong.

0 comments on commit 7360e38

Please sign in to comment.