Continue Lining Up Columns

This commit is contained in:
Leo Herzog committed 2020-11-09 17:02:10 -05:00
1 parent 9365ab1338
commit a7ac84adf0
5 files changed
+111 -60

No files matched your search

+10 -8
View File
@@ -33819,14 +33819,15 @@ function display() {
tracker.addEventListener('input', propertyChange); tracker.addEventListener('input', propertyChange);
row.appendChild(tracker); row.appendChild(tracker);
let remove = document.createElement('a'); let remove = document.createElement('a');
remove.className = 'remove';
remove.dataset.index = i; remove.dataset.index = i;
remove.innerHTML = '<span class="far fa-trash"></span>'; remove.innerHTML = '<span class="far fa-trash"></span>';
remove.addEventListener('click', removeRow); remove.addEventListener('click', removeRow);
row.appendChild(remove); row.appendChild(remove);
announce.appendChild(row); announce.appendChild(row);
} }
} else { // } else {
announce.innerHTML = "<em>No trackers specified in the URL/File provided</em>"; // announce.innerHTML = "<em>No trackers specified in the URL/File provided</em>";
} }
urlList.innerHTML = ""; urlList.innerHTML = "";
@@ -33842,15 +33843,16 @@ function display() {
webseed.dataset.group = 'urlList'; webseed.dataset.group = 'urlList';
webseed.addEventListener('input', propertyChange); webseed.addEventListener('input', propertyChange);
row.appendChild(webseed); row.appendChild(webseed);
let remove = document.createElement('button'); let remove = document.createElement('a');
remove.className = 'remove';
remove.dataset.index = i; remove.dataset.index = i;
remove.innerHTML = '<span class="fas fa-minus"></span>'; remove.innerHTML = '<span class="far fa-trash"></span>';
remove.addEventListener('click', removeRow); remove.addEventListener('click', removeRow);
row.appendChild(remove); row.appendChild(remove);
urlList.appendChild(row); urlList.appendChild(row);
} }
} else { // } else {
urlList.innerHTML = "<em>No webseed URLs in the URL/File provided</em>"; // urlList.innerHTML = "<em>No webseed URLs in the URL/File provided</em>";
} }
files.innerHTML = ""; files.innerHTML = "";
@@ -33866,9 +33868,9 @@ function display() {
} else { } else {
getFiles.style.display = "block"; getFiles.style.display = "block";
if (client.torrents.length > 0) { if (client.torrents.length > 0) {
files.innerHTML = "<em>Attempting fetching files from Webtorrent...</em>"; files.innerHTML = '<input type="text" placeholder="Attempting fetching files from Webtorrent..." disabled>';
} else { } else {
files.innerHTML = "<em>Files information isn't included in the URL/File provided</em>"; files.innerHTML = '<input type="text" placeholder="Not included in the URL/File provided" disabled>';
} }
downloadTorrent.removeEventListener('click', saveTorrent); downloadTorrent.removeEventListener('click', saveTorrent);
downloadTorrent.disabled = true; downloadTorrent.disabled = true;
+1 -1
View File
@@ -78,4 +78,4 @@ const i=e("debug")("torrent-discovery"),s=e("bittorrent-dht/client"),r=e("events
/*! ut_metadata. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */ /*! ut_metadata. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
const{EventEmitter:i}=e("events"),s=e("bencode"),r=e("bitfield").default,a=e("debug")("ut_metadata"),o=e("simple-sha1"),c=16384;t.exports=e=>{class t extends i{constructor(t){super(),this._wire=t,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new r(0,{grow:1e3}),n.isBuffer(e)&&this.setMetadata(e)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||1e7<e.metadata_size||e.metadata_size<=0?this.emit("warning",new Error("Peer gave invalid metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/c),this._remainingRejects=2*this._numPieces,void this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(e){let t,n;try{const i=e.toString(),r=i.indexOf("ee")+2;t=s.decode(i.substring(0,r)),n=e.slice(r)}catch(e){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(e){if(this._metadataComplete)return!0;a("set metadata");try{const t=s.decode(e).info;t&&(e=s.encode(t))}catch(e){}return(!this._infoHash||this._infoHash===o.sync(e))&&(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",s.encode({info:s.decode(this.metadata)})),!0)}_send(e,t){let i=s.encode(e);n.isBuffer(t)&&(i=n.concat([i,t])),this._wire.extended("ut_metadata",i)}_request(e){this._send({msg_type:0,piece:e})}_data(e,t,n){const i={msg_type:1,piece:e};"number"==typeof n&&(i.total_size=n),this._send(i,t)}_reject(e){this._send({msg_type:2,piece:e})}_onRequest(e){if(!this._metadataComplete)return void this._reject(e);const t=e*c;let n=t+c;n>this._metadataSize&&(n=this._metadataSize);const i=this.metadata.slice(t,n);this._data(e,i,this._metadataSize)}_onData(e,t,n){t.length>c||!this._fetching||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))}_requestPieces(){if(this._fetching){this.metadata=n.alloc(this._metadataSize);for(let e=0;e<this._numPieces;e++)this._request(e)}}_checkDone(){let e=!0;for(let t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(!e)return;this.setMetadata(this.metadata)||this._failedMetadata()}_failedMetadata(){this._bitfield=new r(0,{grow:1e3}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return t.prototype.name="ut_metadata",t}}).call(this)}).call(this,e("buffer").Buffer)},{bencode:6,bitfield:300,buffer:59,debug:301,events:97,"simple-sha1":241}],300:[function(e,t,n){arguments[4][11][0].apply(n,arguments)},{dup:11}],301:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":302,_process:186,dup:12}],302:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:303}],303:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],304:[function(e,t,n){(function(e){(function(){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var i=!1;return function(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],305:[function(e,t,n){(function(n){(function(){const i=e("binary-search"),s=e("events"),r=e("mp4-stream"),a=e("mp4-box-encoding"),o=e("range-slice-stream");class c{constructor(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}const l=1;t.exports=class extends s{constructor(e){super(),this._tracks=[],this._file=e,this._decoder=null,this._findMoov(0)}_findMoov(e){this._decoder&&this._decoder.destroy();let t=0;this._decoder=r.decode();const n=this._file.createReadStream({start:e});n.pipe(this._decoder);const i=s=>{"moov"===s.type?(this._decoder.removeListener("box",i),this._decoder.decode((e=>{n.destroy();try{this._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,this.emit("error",e)}}))):s.length<4096?(t+=s.length,this._decoder.ignore()):(this._decoder.removeListener("box",i),t+=s.length,n.destroy(),this._decoLine truncated const{EventEmitter:i}=e("events"),s=e("bencode"),r=e("bitfield").default,a=e("debug")("ut_metadata"),o=e("simple-sha1"),c=16384;t.exports=e=>{class t extends i{constructor(t){super(),this._wire=t,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new r(0,{grow:1e3}),n.isBuffer(e)&&this.setMetadata(e)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||1e7<e.metadata_size||e.metadata_size<=0?this.emit("warning",new Error("Peer gave invalid metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/c),this._remainingRejects=2*this._numPieces,void this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(e){let t,n;try{const i=e.toString(),r=i.indexOf("ee")+2;t=s.decode(i.substring(0,r)),n=e.slice(r)}catch(e){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(e){if(this._metadataComplete)return!0;a("set metadata");try{const t=s.decode(e).info;t&&(e=s.encode(t))}catch(e){}return(!this._infoHash||this._infoHash===o.sync(e))&&(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",s.encode({info:s.decode(this.metadata)})),!0)}_send(e,t){let i=s.encode(e);n.isBuffer(t)&&(i=n.concat([i,t])),this._wire.extended("ut_metadata",i)}_request(e){this._send({msg_type:0,piece:e})}_data(e,t,n){const i={msg_type:1,piece:e};"number"==typeof n&&(i.total_size=n),this._send(i,t)}_reject(e){this._send({msg_type:2,piece:e})}_onRequest(e){if(!this._metadataComplete)return void this._reject(e);const t=e*c;let n=t+c;n>this._metadataSize&&(n=this._metadataSize);const i=this.metadata.slice(t,n);this._data(e,i,this._metadataSize)}_onData(e,t,n){t.length>c||!this._fetching||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))}_requestPieces(){if(this._fetching){this.metadata=n.alloc(this._metadataSize);for(let e=0;e<this._numPieces;e++)this._request(e)}}_checkDone(){let e=!0;for(let t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(!e)return;this.setMetadata(this.metadata)||this._failedMetadata()}_failedMetadata(){this._bitfield=new r(0,{grow:1e3}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return t.prototype.name="ut_metadata",t}}).call(this)}).call(this,e("buffer").Buffer)},{bencode:6,bitfield:300,buffer:59,debug:301,events:97,"simple-sha1":241}],300:[function(e,t,n){arguments[4][11][0].apply(n,arguments)},{dup:11}],301:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":302,_process:186,dup:12}],302:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:303}],303:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],304:[function(e,t,n){(function(e){(function(){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var i=!1;return function(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],305:[function(e,t,n){(function(n){(function(){const i=e("binary-search"),s=e("events"),r=e("mp4-stream"),a=e("mp4-box-encoding"),o=e("range-slice-stream");class c{constructor(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}const l=1;t.exports=class extends s{constructor(e){super(),this._tracks=[],this._file=e,this._decoder=null,this._findMoov(0)}_findMoov(e){this._decoder&&this._decoder.destroy();let t=0;this._decoder=r.decode();const n=this._file.createReadStream({start:e});n.pipe(this._decoder);const i=s=>{"moov"===s.type?(this._decoder.removeListener("box",i),this._decoder.decode((e=>{n.destroy();try{this._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,this.emit("error",e)}}))):s.length<4096?(t+=s.length,this._decoder.ignore()):(this._decoder.removeListener("box",i),t+=s.length,n.destroy(),this._decoLine truncated
/*! webtorrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */ /*! webtorrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
const{EventEmitter:r}=e("events"),a=e("simple-concat"),o=e("create-torrent"),c=e("debug")("webtorrent"),l=e("bittorrent-dht/client"),p=e("load-ip-set"),u=e("run-parallel"),d=e("parse-torrent"),h=e("path"),f=e("simple-peer"),m=e("randombytes"),g=e("speedometer"),v=e("./lib/conn-pool"),b=e("./lib/torrent"),x=e("./package.json").version,_=x.replace(/\d*./g,(e=>("0"+e%100).slice(-2))).slice(0,4),y=`-WW${_}-`;class w extends r{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:s.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=s.from(y+m(9).toString("base64")).toString("hex"),this.peerIdBuffer=s.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:s.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=m(20).toString("hex"),this.nodeIdBuffer=s.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=void 0!==e.tracker?e.tracker:{},this.torrents=[],this.maxConns=Number(e.maxConns)||55,this.utp=!0===e.utp,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=e.wrtc),i.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=i.WRTC)),"function"==typeof v?this._connPool=new v(this):n.nextTick((()=>{this._onListening()})),this._downloadSpeed=g(),this._uploadSpeed=g(),!1!==e.dht&&"function"==typeof l?(this.dht=new l(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",(e=>{this._destroy(e)})),this.dht.once("listening",(()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)})),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const t=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof p&&null!=e.blocklist?p(e.blocklist,{headers:{"user-agent":`WebTorrent/${x} (https://webtorrent.io)`}},((e,n)=>{if(e)return this.error("Failed to load blocklist: "+e.message);this.blocked=n,t()})):n.nextTick(t)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter((e=>1!==e.progress));return e.reduce(((e,t)=>e+t.downloaded),0)/(e.reduce(((e,t)=>e+(t.length||0)),0)||1)}get ratio(){return this.torrents.reduce(((e,t)=>e+t.uploaded),0)/(this.torrents.reduce(((e,t)=>e+t.received),0)||1)}get(e){if(e instanceof b){if(this.torrents.includes(e))return e}else{let t;try{t=d(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n=(()=>{})){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const i=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===r.infoHash&&e!==r)return void r._destroy(new Error("Cannot add duplicate torrent "+r.infoHash))},s=()=>{this.destroyed||(n(r),this.emit("torrent",r))};this._debug("add"),t=t?Object.assign({},t):{};const r=new b(e,this,t);return this.torrents.push(r),r.once("_infoHash",i),r.once("ready",s),r.once("close",(function e(){r.removeListener("_infoHash",i),r.removeListener("ready",s),r.removeListener("close",e)})),r}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),(t=t?Object.assign({},t):{}).skipVerify=!0;const i="string"==typeof e;i&&(t.path=h.dirname(e)),t.createdBy||(t.createdBy="WebTorrent/"+_);const s=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},r=this.add(null,t,(e=>{const t=[t=>{if(i)return t();e.load(c,t)}];this.dht&&t.push((t=>{e.once("dhtAnnounce",t)})),u(t,(t=>{if(!this.destroyed)return t?e._destroy(t):void s(e)}))}));let c;var l;return l=e,"undefined"!=typeof FileList&&l instanceof FileList?e=Array.from(e):Array.isArray(e)||(e=[e]),u(e.map((e=>t=>{!function(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}(e)?t(null,e):a(e,t)})),((e,n)=>{if(!this.destroyed)return e?r._destroy(e):void o.parseInput(n,t,((e,i)=>{if(!this.destroyed){if(e)return r._destroy(e);c=i.map((e=>e.getStream)),o(n,t,((e,t)=>{if(this.destroyed)return;if(e)return r._destroy(e);const n=this.get(t);n?r._destroy(new Error("Cannot add duplicate torrent "+n.infoHash)):r._onTorrentId(t)}))}}))})),r}remove(e,t,n){if("function"==typeof t)return this.remove(e,null,t);this._debug("remove");if(!this.get(e))throw new Error("No torrent with id "+e);this._remove(e,t,n)}_remove(e,tLine truncated const{EventEmitter:r}=e("events"),a=e("simple-concat"),o=e("create-torrent"),c=e("debug")("webtorrent"),l=e("bittorrent-dht/client"),p=e("load-ip-set"),u=e("run-parallel"),d=e("parse-torrent"),h=e("path"),f=e("simple-peer"),m=e("randombytes"),g=e("speedometer"),v=e("./lib/conn-pool"),b=e("./lib/torrent"),x=e("./package.json").version,_=x.replace(/\d*./g,(e=>("0"+e%100).slice(-2))).slice(0,4),y=`-WW${_}-`;class w extends r{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:s.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=s.from(y+m(9).toString("base64")).toString("hex"),this.peerIdBuffer=s.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:s.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=m(20).toString("hex"),this.nodeIdBuffer=s.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=void 0!==e.tracker?e.tracker:{},this.torrents=[],this.maxConns=Number(e.maxConns)||55,this.utp=!0===e.utp,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=e.wrtc),i.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=i.WRTC)),"function"==typeof v?this._connPool=new v(this):n.nextTick((()=>{this._onListening()})),this._downloadSpeed=g(),this._uploadSpeed=g(),!1!==e.dht&&"function"==typeof l?(this.dht=new l(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",(e=>{this._destroy(e)})),this.dht.once("listening",(()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)})),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const t=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof p&&null!=e.blocklist?p(e.blocklist,{headers:{"user-agent":`WebTorrent/${x} (https://webtorrent.io)`}},((e,n)=>{if(e)return this.error("Failed to load blocklist: "+e.message);this.blocked=n,t()})):n.nextTick(t)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter((e=>1!==e.progress));return e.reduce(((e,t)=>e+t.downloaded),0)/(e.reduce(((e,t)=>e+(t.length||0)),0)||1)}get ratio(){return this.torrents.reduce(((e,t)=>e+t.uploaded),0)/(this.torrents.reduce(((e,t)=>e+t.received),0)||1)}get(e){if(e instanceof b){if(this.torrents.includes(e))return e}else{let t;try{t=d(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n=(()=>{})){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const i=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===r.infoHash&&e!==r)return void r._destroy(new Error("Cannot add duplicate torrent "+r.infoHash))},s=()=>{this.destroyed||(n(r),this.emit("torrent",r))};this._debug("add"),t=t?Object.assign({},t):{};const r=new b(e,this,t);return this.torrents.push(r),r.once("_infoHash",i),r.once("ready",s),r.once("close",(function e(){r.removeListener("_infoHash",i),r.removeListener("ready",s),r.removeListener("close",e)})),r}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),(t=t?Object.assign({},t):{}).skipVerify=!0;const i="string"==typeof e;i&&(t.path=h.dirname(e)),t.createdBy||(t.createdBy="WebTorrent/"+_);const s=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},r=this.add(null,t,(e=>{const t=[t=>{if(i)return t();e.load(c,t)}];this.dht&&t.push((t=>{e.once("dhtAnnounce",t)})),u(t,(t=>{if(!this.destroyed)return t?e._destroy(t):void s(e)}))}));let c;var l;return l=e,"undefined"!=typeof FileList&&l instanceof FileList?e=Array.from(e):Array.isArray(e)||(e=[e]),u(e.map((e=>t=>{!function(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}(e)?t(null,e):a(e,t)})),((e,n)=>{if(!this.destroyed)return e?r._destroy(e):void o.parseInput(n,t,((e,i)=>{if(!this.destroyed){if(e)return r._destroy(e);c=i.map((e=>e.getStream)),o(n,t,((e,t)=>{if(this.destroyed)return;if(e)return r._destroy(e);const n=this.get(t);n?r._destroy(new Error("Cannot add duplicate torrent "+n.infoHash)):r._onTorrentId(t)}))}}))})),r}remove(e,t,n){if("function"==typeof t)return this.remove(e,null,t);this._debug("remove");if(!this.get(e))throw new Error("No torrent with id "+e);this._remove(e,t,n)}_remove(e,tLine truncated
+35 -24
View File
@@ -29,14 +29,14 @@
<header> <header>
<h1 id="logo">Torrent<span class="fad fa-magnet fa-fw"></span>Parts</h1> <h1 id="logo">Torrent<span class="fad fa-magnet fa-fw"></span>Parts</h1>
<iframe src="https://ghbtns.com/github-btn.html?user=leoherzog&repo=TorrentParts&type=star&count=true" frameborder="0" scrolling="0" width="90" height="20" title="GitHub"></iframe> <iframe src="https://ghbtns.com/github-btn.html?user=leoherzog&repo=TorrentParts&type=star&count=true" frameborder="0" scrolling="0" width="100" height="20" title="GitHub"></iframe>
</header> </header>
<div id="startButtons"> <div id="startButtons">
<input id="magnet" type="text" placeholder="Enter Magnet URL" /> <input id="magnet" type="text" placeholder="Enter Magnet URL" />
<input id="torrent" type="file" /> <input id="torrent" type="file" />
<label for="torrent"> <label for="torrent">
<span class="fas fa-cloud-upload"></span> Upload Torrent <span class="fas fa-cloud-upload"></span> Select Torrent File
</label> </label>
</div> </div>
@@ -44,34 +44,44 @@
<div id="properties" style="display:none"> <div id="properties" style="display:none">
<button id="reset"> <button id="reset">
<span class="far fa-times fa-fw"></span> <span class="far fa-times"></span>
</button> </button>
<div id="download"> <div id="download">
<button id="copyURL"> <button id="copyURL">
<span class="fas fa-share-alt fa-fw fa-2x" data-fa-transform="left-1"></span> <span class="fas fa-share-alt fa-2x" data-fa-transform="left-1"></span>
</button> </button>
<button id="copyMagnet"> <button id="copyMagnet">
<span class="fas fa-magnet fa-fw fa-2x" data-fa-transform="down-1"></span> <span class="fas fa-magnet fa-2x" data-fa-transform="down-1"></span>
</button> </button>
<button id="downloadTorrent"> <button id="downloadTorrent">
<span class="fas fa-file-download fa-fw fa-2x"></span> <span class="fas fa-file-download fa-2x"></span>
</button> </button>
</div> </div>
<div class="property"> <div class="property">
<label for="hash">Unique Hash</label> <div class="labels">
<input id="hash" type="text" placeholder="" disabled/> <label for="hash">Unique Hash</label>
</div>
<div class="content">
<input id="hash" type="text" placeholder="" disabled/>
</div>
</div> </div>
<div class="property"> <div class="property">
<label for="name"><span id="originalSourceIcon"></span>Torrent Name</label> <div class="labels">
<input id="name" type="text" placeholder="Unspecified" /> <label for="name"><span id="originalSourceIcon"></span>Torrent Name</label>
</div>
<div class="content">
<input id="name" type="text" placeholder="Unspecified" />
</div>
</div> </div>
<div class="property"> <div class="property">
<label for="created">Created</label> <div class="labels">
<div> <label for="created">Created</label>
</div>
<div class="content">
<input id="created" type="text" placeholder="Time unspecified" disabled /> <input id="created" type="text" placeholder="Time unspecified" disabled />
<br /> <br />
<input id="createdBy" type="text" placeholder="Client unspecified" disabled /> <input id="createdBy" type="text" placeholder="Client unspecified" disabled />
@@ -79,19 +89,21 @@
</div> </div>
<div class="property"> <div class="property">
<label for="comment">Comment</label> <div class="labels">
<input id="comment" type="text" placeholder="Unspecified" /> <label for="comment">Comment</label>
</div>
<div class="content">
<input id="comment" type="text" placeholder="Unspecified" />
</div>
</div> </div>
<div class="property"> <div class="property">
<div> <div class="labels">
<label for="announce">Tracker URLs</label> <label for="announce">Tracker URLs</label>
<br />
<a id="addTrackers">Add Known Working Trackers</a> <a id="addTrackers">Add Known Working Trackers</a>
<br />
<a id="removeTrackers">Remove All</a> <a id="removeTrackers">Remove All</a>
</div> </div>
<div> <div class="content">
<button id="addTracker" data-type="announce"> <button id="addTracker" data-type="announce">
<span class="far fa-plus-circle"></span> Add Tracker <span class="far fa-plus-circle"></span> Add Tracker
</button> </button>
@@ -100,12 +112,11 @@
</div> </div>
<div class="property"> <div class="property">
<div> <div class="labels">
<label for="urlList">Webseed URLs</label> <label for="urlList">Webseed URLs</label>
<br />
<a id="removeWebseeds">Remove All</a> <a id="removeWebseeds">Remove All</a>
</div> </div>
<div> <div class="content">
<button id="addWebseed" data-type="urlList"> <button id="addWebseed" data-type="urlList">
<span class="far fa-plus-circle"></span> Add Webseed <span class="far fa-plus-circle"></span> Add Webseed
</button> </button>
@@ -114,9 +125,9 @@
</div> </div>
<div class="property"> <div class="property">
<div> <div class="labels">
<label for="files">Files</label> <label for="files">Files</label>
<a id="getFiles">Attempt to Fetch Files from WebTorrent</a> <a id="getFiles">Fetch Files List from WebTorrent</a>
</div> </div>
<table id="files"> <table id="files">
<tbody id="filesBody"></tbody> <tbody id="filesBody"></tbody>
@@ -125,7 +136,7 @@
</div> </div>
<script src="bundle.js"></script> <script src="bundle.min.js"></script>
</body> </body>
+10 -8
View File
@@ -156,14 +156,15 @@ function display() {
tracker.addEventListener('input', propertyChange); tracker.addEventListener('input', propertyChange);
row.appendChild(tracker); row.appendChild(tracker);
let remove = document.createElement('a'); let remove = document.createElement('a');
remove.className = 'remove';
remove.dataset.index = i; remove.dataset.index = i;
remove.innerHTML = '<span class="far fa-trash"></span>'; remove.innerHTML = '<span class="far fa-trash"></span>';
remove.addEventListener('click', removeRow); remove.addEventListener('click', removeRow);
row.appendChild(remove); row.appendChild(remove);
announce.appendChild(row); announce.appendChild(row);
} }
} else { // } else {
announce.innerHTML = "<em>No trackers specified in the URL/File provided</em>"; // announce.innerHTML = "<em>No trackers specified in the URL/File provided</em>";
} }
urlList.innerHTML = ""; urlList.innerHTML = "";
@@ -179,15 +180,16 @@ function display() {
webseed.dataset.group = 'urlList'; webseed.dataset.group = 'urlList';
webseed.addEventListener('input', propertyChange); webseed.addEventListener('input', propertyChange);
row.appendChild(webseed); row.appendChild(webseed);
let remove = document.createElement('button'); let remove = document.createElement('a');
remove.className = 'remove';
remove.dataset.index = i; remove.dataset.index = i;
remove.innerHTML = '<span class="fas fa-minus"></span>'; remove.innerHTML = '<span class="far fa-trash"></span>';
remove.addEventListener('click', removeRow); remove.addEventListener('click', removeRow);
row.appendChild(remove); row.appendChild(remove);
urlList.appendChild(row); urlList.appendChild(row);
} }
} else { // } else {
urlList.innerHTML = "<em>No webseed URLs in the URL/File provided</em>"; // urlList.innerHTML = "<em>No webseed URLs in the URL/File provided</em>";
} }
files.innerHTML = ""; files.innerHTML = "";
@@ -203,9 +205,9 @@ function display() {
} else { } else {
getFiles.style.display = "block"; getFiles.style.display = "block";
if (client.torrents.length > 0) { if (client.torrents.length > 0) {
files.innerHTML = "<em>Attempting fetching files from Webtorrent...</em>"; files.innerHTML = '<input type="text" placeholder="Attempting fetching files from Webtorrent..." disabled>';
} else { } else {
files.innerHTML = "<em>Files information isn't included in the URL/File provided</em>"; files.innerHTML = '<input type="text" placeholder="Not included in the URL/File provided" disabled>';
} }
downloadTorrent.removeEventListener('click', saveTorrent); downloadTorrent.removeEventListener('click', saveTorrent);
downloadTorrent.disabled = true; downloadTorrent.disabled = true;
+55 -19
View File
@@ -41,10 +41,12 @@ input:disabled {
color: var(--grey); color: var(--grey);
background: transparent; background: transparent;
border: 0; border: 0;
padding: 8px 0;
} }
::placeholder { ::placeholder {
color: var(--grey); color: var(--grey);
opacity: 0.6;
} }
button { button {
@@ -55,7 +57,6 @@ button {
box-sizing: border-box; box-sizing: border-box;
border-radius: 900px; border-radius: 900px;
text-align: left; text-align: left;
margin: auto;
cursor: pointer; cursor: pointer;
} }
@@ -65,8 +66,11 @@ button:disabled {
} }
a { a {
cursor: pointer; color: var(--grey);
font-size: 85%;
text-decoration: underline; text-decoration: underline;
text-transform: uppercase;
cursor: pointer;
} }
header { header {
@@ -129,6 +133,10 @@ label[for="torrent"] {
} }
#reset { #reset {
width: 32px;
height: 32px;
border-radius: 50%;
text-align: center;
position: absolute; position: absolute;
top: -12px; top: -12px;
right: -12px; right: -12px;
@@ -143,19 +151,34 @@ label[for="torrent"] {
} }
#download > * { #download > * {
width: 60px;
height: 60px;
border-radius: 50%;
text-align: center;
margin: 4px 0; margin: 4px 0;
} }
.property { .property {
width: 100%; margin: 24px 0;
margin: 20px 0px;
display: flex; display: flex;
justify-content: space-around; align-content: flex-start;
align-items: center; justify-content: space-between;
} }
.property:first-child { .property:first-child {
width: 160px; width: 240px;
}
.labels {
width: 280px;
text-align: right;
margin-top: 8px;
display: flex;
flex-direction: column;
}
.content, #files {
width: 460px;
} }
label { label {
@@ -168,30 +191,33 @@ input {
#addTracker, #addWebseed { #addTracker, #addWebseed {
width: 440px; width: 440px;
margin: 0 0 16px 0;
color: var(--light-blue); color: var(--light-blue);
background: var(--dark-blue); background: var(--dark-blue);
border: 1px solid var(--light-blue); border: 1px solid var(--light-blue);
padding: 8px;
box-sizing: border-box; box-sizing: border-box;
border-radius: 900px; border-radius: 900px;
cursor: pointer; cursor: pointer;
} }
#announce > *, #urlList > * { #announce > *, #urlList > * {
margin: 4px 0; margin: 0 0 16px 0;
}
.remove {
/* position: absolute; */
} }
@media (max-width: 1080px) { @media (max-width: 1080px) {
#reset { #reset {
width: auto;
top: 0px; top: 0px;
right: 8px; right: 8px;
} }
#download { #download {
justify-content: center; justify-content: center;
width: 96%; width: 95%;
top: auto; top: auto;
bottom: 16px; bottom: 16px;
left: auto; left: auto;
@@ -200,7 +226,6 @@ input {
} }
#download > * { #download > * {
width: auto;
margin: 0 4px; margin: 0 4px;
} }
@@ -218,24 +243,35 @@ input {
} }
#properties { #properties {
margin: 0; margin: 0 1.5vw;
padding: 0 2vw; padding: 0 1.5vw;
width: 95vw; width: 95vw;
} }
.property { .property {
margin: 8px 0; margin: 12px 0;
flex-direction: column; flex-direction: column;
align-items: center;
} }
.property > label { .property > label {
width: fit-content; margin: 12px 0;
margin: 8px 0;
} }
input, button, #addTracker, #addWebseed { input, button, #addTracker, #addWebseed {
width: 95vw; width: 94vw;
text-align: center;
}
.labels {
margin-bottom: 16px;
align-items: center;
}
.labels, .content, #files {
width: auto;
}
#announce, #urlList {
text-align: center; text-align: center;
} }