68 lines
2.0 KiB
Plaintext
68 lines
2.0 KiB
Plaintext
<%include partials/header.ejs %>
|
|
|
|
<div class="container">
|
|
<p id='#drag'>Drop a file to make it a torrent file:</p>
|
|
<div class="card drop-div" id="_drop"></div>
|
|
|
|
<div class="card">
|
|
<div id="seed-result"></div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<%include partials/footer.ejs %>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
seeding();
|
|
});
|
|
|
|
// You can pass in a DOM node or a selector string!
|
|
let seeding = () => {
|
|
DragDrop('.drop-div', function (files, pos, fileList, directories) {
|
|
console.log('Here are the dropped files', files)
|
|
console.log('Dropped at coordinates', pos.x, pos.y)
|
|
console.log('Here is the raw FileList object if you need it:', fileList)
|
|
console.log('Here is the list of directories:', directories)
|
|
|
|
var client = new WebTorrent()
|
|
|
|
client.seed(files, function (torrent) {
|
|
console.log(torrent);
|
|
console.log('Client is seeding ' + torrent.magnetURI)
|
|
|
|
let t = ``;
|
|
|
|
t += `Client is seeding <strong>${torrent.magnetURI}</strong>`;
|
|
|
|
t += `<p>Name: ${torrent.name}</p>`;
|
|
t += `<p>Path: ${torrent.path}</p>`;
|
|
var hexdata = torrent.torrentFile.toString('hex');
|
|
t += `<p>Torrent: ${hexdata}</p>`;
|
|
t += `<p></p>`;
|
|
|
|
t += `<h5>Files hash</h5>`;
|
|
for (let h = 0; h < torrent._hashes.length; h++) {
|
|
const hash = torrent._hashes[h];
|
|
t += `<p>${hash}</p>`;
|
|
}
|
|
|
|
t += `<h5>Peers</h5>`;
|
|
for (let p = 0; p < torrent._peers.length; p++) {
|
|
const peer = torrent._peers[p];
|
|
t += `<p>Peer: ${peer}</p>`;
|
|
}
|
|
|
|
t += `<h5>Trackers</h5>`;
|
|
for (let r = 0; r < torrent.discovery._announce.length; r++) {
|
|
const tracker = torrent.discovery._announce[r];
|
|
t += `<p>${tracker}</p>`;
|
|
}
|
|
|
|
$("#seed-result").html(t);
|
|
|
|
})
|
|
})
|
|
}
|
|
|
|
</script> |