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

Improve code examples #538

Merged
merged 4 commits into from Dec 27, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

examples: simplify

  • Loading branch information
feross committed Dec 27, 2015
commit dc2601ed144b5348e6afa30496d380514836f5d2
@@ -4,21 +4,10 @@ var client = new WebTorrent()

var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d'

client.add(magnetUri, function (torrent) {
// Got torrent metadata!
console.log('Torrent info hash:', torrent.infoHash)
client.add(torrentId, function (torrent) {
// Torrents can contain many files. Let's use the first.
var file = torrent.files[0]

torrent.files.forEach(function (file) {
// Get a url for each file
file.getBlobURL(function (err, url) {
if (err) throw err

// Add a link to the page
var a = document.createElement('a')
a.download = file.name
a.href = url
a.textContent = 'Download ' + file.name
document.body.appendChild(a)
})
})
// Display the file by adding it to the DOM. Supports video, audio, image, etc. files
file.appendTo('body')
})
@@ -5,8 +5,8 @@ var client = new WebTorrent()

// When user drops files on the browser, create a new torrent and start seeding it!
dragDrop('body', function (files) {
client.seed(files, function onTorrent (torrent) {
client.seed(files, function (torrent) {
// Client is seeding the file!
console.log('Torrent info hash:', torrent.infoHash)
console.log('Torrent magnet link:', torrent.magnetURI)
})
})

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.