Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added qr code generation #104

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var thunky = require('thunky')
var uploadElement = require('upload-element')
var WebTorrent = require('webtorrent')
var xhr = require('xhr')
var qr = require('node-qr-image')

var util = require('./util')

Expand Down Expand Up @@ -166,6 +167,10 @@ function onTorrent (torrent) {
'<a href="' + torrent.magnetURI + '" target="_blank">[Magnet URI]</a> ' +
'<a href="' + torrent.torrentFileBlobURL + '" target="_blank" download="' + torrentFileName + '">[Download .torrent]</a>'
)

util.log(
'QR Code: <img class="qr" src="data:image/png;base64,' + qr.imageSync(location.href + '#' + torrent.infoHash, { type: 'png' }).toString('base64') + '">'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small bug: If there's already a hash in the URL, this will add a second one.

)

function updateSpeed () {
var progress = (100 * torrent.progress).toFixed(1)
Expand Down
4 changes: 4 additions & 0 deletions css/main.styl
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ iframe
width: 1000px
max-width: 100%
height: 600px

.qr
width: 100px
height: 100px
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"jade": "^1.5.0",
"listify": "^1.0.0",
"nib": "^1.0.3",
"node-qr-image": "0.0.1",
"pretty-bytes": "^3.0.0",
"run-parallel": "^1.0.0",
"stylus": "^0.54.0",
Expand Down
Loading