download-with-webtorrent-button
Advanced tools
Comparing version 1.0.0 to 1.0.5
@@ -1,1 +0,1 @@ | ||
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t){function n(){"use strict";function e(e){var o=e.currentTarget;return o.classList.contains("init")?t(e):o.classList.contains("downloading")?n(e):o.classList.contains("ready")?r(e):!o.classList.contains("seeding")||r(e)}function t(e){var t=e.currentTarget;t.classList.remove("init"),t.classList.add("downloading");try{var n=t.innerText,r=new WebTorrent;return r.on("error",function(e){console.error("ERROR: "+e.message)}),"auto"===t.dataset.webtorrent&&(t.dataset.webtorrent="https://webtorrentify.now.sh/?href="+t.href,t.title="Generating .torrent file..."),r.add(t.dataset.webtorrent,function(e){function r(){var r=e.numPeers-1;r+=1===r?" peer":" peers";var i=Math.round(100*e.progress)+"%";t.style="background-size: 28px 28px, "+i+" 100%, 100%;",e.done?e.done&&t.classList.contains("seeding")&&(t.innerText=o.name+" - Ready",t.title="Seeding ("+r+")"):t.innerText.endsWith(" - Ready")||(t.innerText=n+" - "+i,t.title="Downloading ("+r+")")}console.log(e);var o;o=1===e.files.length||void 0===t.dataset.file?e.files[0]:e.files.find(function(e){return e.name===t.dataset.file}),r(),setInterval(r,500),o.getBlobURL(function(e,n){if(e)return void window.alert("WebTorrent error: source getBlobURL");t.classList.remove("downloading"),t.classList.add("ready"),t.innerText=o.name+" - Ready",t.title="Click to save file",t.download=o.name,t.href=n})}),e.preventDefault(),!1}catch(e){return console.log(e),!0}}function n(e){return e.preventDefault(),!1}function r(e){var t=e.currentTarget;return t.classList.remove("ready"),t.classList.add("seeding"),!0}for(var o=document.querySelectorAll("a[data-webtorrent]"),i=0;i<o.length;i++){var a=o[i];if(WebTorrent.WEBRTC_SUPPORT)a.title="Download with WebTorrent",a.addEventListener("click",e);else if(a.classList.add("no-webrtc"),"auto"!==a.dataset.webtorrent){a.title="";var s=document.createElement("a");s.href=a.dataset.webtorrent,s.innerText="alternate Bittorrent link",a.appendChild(s)}else a.title="Download";a.classList.add("init")}}window&&(window.registerWebtorrentLinks=n,n())},function(e,t){},function(e,t,n){n(0),e.exports=n(1)}]); | ||
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t){function n(){"use strict";function e(e){var o=e.currentTarget;return o.classList.contains("init")?t(e):o.classList.contains("downloading")?n(e):o.classList.contains("ready")?r(e):!o.classList.contains("seeding")||r(e)}function t(e){var t=e.currentTarget;t.classList.remove("init"),t.classList.add("downloading");try{var n=t.innerText,r=new WebTorrent;return r.on("error",function(e){console.error("ERROR: "+e.message)}),"auto"===t.dataset.webtorrent&&(t.dataset.webtorrent="https://webtorrentify.now.sh/?href="+t.href,t.title="Generating .torrent file..."),r.add(t.dataset.webtorrent,function(e){function r(){var r=e.numPeers;r+=1===r?" peer":" peers";var i=Math.floor(100*e.progress)+"%";t.style="background-size: 28px 28px, "+i+" 100%, 100%;",e.done?e.done&&t.classList.contains("seeding")&&(t.innerText=o.name+" - Ready",t.title="Seeding ("+r+")"):t.innerText.endsWith(" - Ready")||(t.innerText=n+" - "+i,t.title="Downloading ("+r+")")}console.log(e);var o;o=1===e.files.length||void 0===t.dataset.file?e.files[0]:e.files.find(function(e){return e.name===t.dataset.file}),r(),setInterval(r,500),o.getBlobURL(function(e,n){if(e)return void window.alert("WebTorrent error: source getBlobURL");t.classList.remove("downloading"),t.classList.add("ready"),t.innerText=o.name+" - Ready",t.title="Click to save file",t.download=o.name,t.href=n})}),e.preventDefault(),!1}catch(e){return console.log(e),!0}}function n(e){return e.preventDefault(),!1}function r(e){var t=e.currentTarget;return t.classList.remove("ready"),t.classList.add("seeding"),!0}for(var o=document.querySelectorAll("a[data-webtorrent]"),i=0;i<o.length;i++){var a=o[i];if(WebTorrent.WEBRTC_SUPPORT)a.title="Download with WebTorrent",a.addEventListener("click",e);else if(a.classList.add("no-webrtc"),"auto"!==a.dataset.webtorrent){a.title="";var s=document.createElement("a");s.href=a.dataset.webtorrent,s.innerText="alternate Bittorrent link",a.appendChild(s)}else a.title="Download";a.classList.add("init")}}window&&(window.registerWebtorrentLinks=n,n())},function(e,t){},function(e,t,n){n(0),e.exports=n(1)}]); |
@@ -75,5 +75,5 @@ /* global WebTorrent */ | ||
function progress () { | ||
var numPeers = torrent.numPeers - 1 // Don't count yourself | ||
var numPeers = torrent.numPeers | ||
numPeers += (numPeers === 1 ? ' peer' : ' peers') | ||
var percent = Math.round(torrent.progress * 100) + '%' | ||
var percent = Math.floor(torrent.progress * 100) + '%' | ||
// Nifty progress bar using CSS gradient backgrounds | ||
@@ -80,0 +80,0 @@ a.style = 'background-size: 28px 28px, ' + percent + ' 100%, 100%;' |
{ | ||
"name": "download-with-webtorrent-button", | ||
"version": "1.0.0", | ||
"version": "1.0.5", | ||
"description": "Transform ordinary download links into super-powered WebTorrent ones!", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92522