Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/TorrentManager.js')
-rw-r--r--lib/TorrentManager.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/TorrentManager.js b/lib/TorrentManager.js
index 265ef26..8c3e570 100644
--- a/lib/TorrentManager.js
+++ b/lib/TorrentManager.js
@@ -69,18 +69,28 @@ TorrentManager.prototype.add = function (uri) {
// TODO: Add the torrent to the public DHT so peers know to find up
})
+ torrent.on('metadata', this.updateUI.bind(this))
+
this.dht.setInfoHash(torrent.infoHash)
this.dht.findPeers(MAX_PEERS) // TODO: should the DHT be concerned with max peers?
this.updateUI()
+
+ var t = this.torrents['d2474e86c95b19b8bcfdb92bc12c9d44667cfa36']
+ $('.downloadMetadata').click(function () {
+ t.downloadMetadata()
+ })
}
// TODO: show multiple torrents
TorrentManager.prototype.updateUI = function () {
// console.log('Peer ID: ' + this.peerId.toString('utf8'))
// console.log('Node ID: ' + this.nodeId.toString('hex'))
- $('.infoHash span').text(this.torrents['d2474e86c95b19b8bcfdb92bc12c9d44667cfa36'].infoHash)
- $('.displayName span').text(this.torrents['d2474e86c95b19b8bcfdb92bc12c9d44667cfa36'].displayName)
+
+ var t = this.torrents['d2474e86c95b19b8bcfdb92bc12c9d44667cfa36']
+
+ $('.infoHash span').text(t.infoHash)
+ $('.displayName span').text(t.displayName)
$('.dhtNodes span').text(Object.keys(this.dht.nodes).length)
$('.dhtPeers span').text(Object.keys(this.dht.peers).length)
@@ -91,5 +101,6 @@ TorrentManager.prototype.updateUI = function () {
connectedPeers += torrent.numPeers
}
$('.connectedPeers span').text(connectedPeers)
+ $('.downloadMetadata').toggleClass('highlight', !!t.metadata)
}