sync with instant.io repo
This commit is contained in:
@@ -4,6 +4,7 @@ var dragDrop = require('drag-drop')
|
|||||||
// var listify = require('listify')
|
// var listify = require('listify')
|
||||||
var path = require('path')
|
var path = require('path')
|
||||||
var prettyBytes = require('pretty-bytes')
|
var prettyBytes = require('pretty-bytes')
|
||||||
|
var throttle = require('throttleit')
|
||||||
var thunky = require('thunky')
|
var thunky = require('thunky')
|
||||||
var uploadElement = require('upload-element')
|
var uploadElement = require('upload-element')
|
||||||
var WebTorrent = require('webtorrent')
|
var WebTorrent = require('webtorrent')
|
||||||
@@ -50,7 +51,7 @@ dragDrop('body', onFiles)
|
|||||||
// Download via input element
|
// Download via input element
|
||||||
document.querySelector('form').addEventListener('submit', function (e) {
|
document.querySelector('form').addEventListener('submit', function (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
downloadTorrent(document.querySelector('form input[name=torrentId]').value)
|
downloadTorrent(document.querySelector('form input[name=torrentId]').value.trim())
|
||||||
})
|
})
|
||||||
|
|
||||||
// Download by URL hash
|
// Download by URL hash
|
||||||
@@ -138,11 +139,16 @@ function onTorrent (torrent) {
|
|||||||
|
|
||||||
var torrentFileName = path.basename(torrent.name, path.extname(torrent.name)) + '.torrent'
|
var torrentFileName = path.basename(torrent.name, path.extname(torrent.name)) + '.torrent'
|
||||||
|
|
||||||
|
util.log('"' + torrentFileName + '" contains ' + torrent.files.length + ' files:')
|
||||||
|
torrent.files.forEach(function (file) {
|
||||||
|
util.log(' - ' + file.name + ' (' + prettyBytes(file.length) + ')')
|
||||||
|
})
|
||||||
|
|
||||||
util.log(
|
util.log(
|
||||||
'Torrent info hash: ' + torrent.infoHash + ' ' +
|
'Torrent info hash: ' + torrent.infoHash + ' ' +
|
||||||
'<a href="/#' + torrent.infoHash + '" onclick="prompt(\'Share this link with anyone you want to download this torrent:\', this.href);return false;">[Share link]</a> ' +
|
'<a href="/#' + torrent.infoHash + '" onclick="prompt(\'Share this link with anyone you want to download this torrent:\', this.href);return false;">[Share link]</a> ' +
|
||||||
'<a href="' + torrent.magnetURI + '" target="_blank">[Magnet URI]</a> ' +
|
'<a href="' + torrent.magnetURI + '" target="_blank">[Magnet URI]</a> ' +
|
||||||
'<a href="' + torrent.torrentFileURL + '" target="_blank" download="' + torrentFileName + '">[Download .torrent]</a>'
|
'<a href="' + torrent.torrentFileBlobURL + '" target="_blank" download="' + torrentFileName + '">[Download .torrent]</a>'
|
||||||
)
|
)
|
||||||
|
|
||||||
function updateSpeed () {
|
function updateSpeed () {
|
||||||
@@ -150,13 +156,13 @@ function onTorrent (torrent) {
|
|||||||
util.updateSpeed(
|
util.updateSpeed(
|
||||||
'<b>Peers:</b> ' + torrent.swarm.wires.length + ' ' +
|
'<b>Peers:</b> ' + torrent.swarm.wires.length + ' ' +
|
||||||
'<b>Progress:</b> ' + progress + '% ' +
|
'<b>Progress:</b> ' + progress + '% ' +
|
||||||
'<b>Download speed:</b> ' + prettyBytes(window.client.downloadSpeed()) + '/s ' +
|
'<b>Download speed:</b> ' + prettyBytes(window.client.downloadSpeed) + '/s ' +
|
||||||
'<b>Upload speed:</b> ' + prettyBytes(window.client.uploadSpeed()) + '/s'
|
'<b>Upload speed:</b> ' + prettyBytes(window.client.uploadSpeed) + '/s'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent.swarm.on('download', updateSpeed)
|
torrent.on('download', throttle(updateSpeed, 250))
|
||||||
torrent.swarm.on('upload', updateSpeed)
|
torrent.on('upload', throttle(updateSpeed, 250))
|
||||||
setInterval(updateSpeed, 5000)
|
setInterval(updateSpeed, 5000)
|
||||||
updateSpeed()
|
updateSpeed()
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"drag-drop": "^2.3.1",
|
"drag-drop": "^2.3.1",
|
||||||
"electron-debug": "^0.5.0",
|
"electron-debug": "^0.5.0",
|
||||||
"pretty-bytes": "^3.0.0",
|
"pretty-bytes": "^3.0.0",
|
||||||
|
"throttleit": "^1.0.0",
|
||||||
"thunky": "^0.1.0",
|
"thunky": "^0.1.0",
|
||||||
"upload-element": "^1.0.1",
|
"upload-element": "^1.0.1",
|
||||||
"webtorrent": "^0.68.0",
|
"webtorrent": "^0.68.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user