Add Example Buttons and Tweak Placeholders

This commit is contained in:
Leo Herzog
2020-11-13 14:22:20 -05:00
parent f3f9d8bab9
commit 4efac83d39
8 changed files with 202 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
Copyright 2020 Leo Herzog
Copyright © 2020 Leo Herzog
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@@ -29,7 +29,7 @@ This project wouldn't be possible without the fantastic work of:
The MIT License (MIT)
Copyright (c) 2020 Leo Herzog
Copyright © 2020 Leo Herzog
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@@ -37,8 +37,6 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- - - -
## About Me
<a href="https://herzog.tech/" target="_blank">

View File

@@ -37884,6 +37884,10 @@ const mime = require('mime-types');
const WebTorrent = require('webtorrent');
const tippy = require('tippy.js').default;
var examples = document.getElementById('examples');
var example1 = document.getElementById('example1');
var example2 = document.getElementById('example2');
var example3 = document.getElementById('example3');
var properties = document.getElementById('properties');
var originalSourceIcon = document.getElementById('originalSourceIcon');
var source;
@@ -37973,6 +37977,26 @@ function start() {
});
});
example1.addEventListener('click', function(event) {
event.preventDefault();
notyf.success("Parsing Ubuntu 20.04 Magnet URL");
parse("magnet:?xt=urn:btih:9fc20b9e98ea98b4a35e6223041a5ef94ea27809&dn=ubuntu-20.04-desktop-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce");
});
example2.addEventListener('click', async function(event) {
event.preventDefault();
notyf.success("Fetching and Parsing &ldquo;The WIRED CD&rdquo; Torrent File...");
parseRemote("https://webtorrent.io/torrents/wired-cd.torrent");
});
example3.addEventListener('click', async function(event) {
event.preventDefault();
notyf.success("Parsing Jack Johnson Archive.org Torrent File");
let response = await fetch("jj2008-06-14.mk4_archive.torrent");
let arrayBuffer = await response.arrayBuffer();
parse(Buffer.from(arrayBuffer));
});
let copyurl = new clipboard('#copyURL');
copyurl.on('success', function(e) {
notyf.success('Copied site URL to clipboard!');
@@ -38054,7 +38078,7 @@ function parse(toLoad) {
function parseRemote(toLoad) {
parser.remote(toLoad, function(err, result) {
if (err) {
notyf.error('Problem remotely fetching file or parsing result');
notyf.error('Problem remotely fetching that file or parsing result');
console.warn(err);
resetProperties();
return;
@@ -38161,6 +38185,7 @@ function display() {
copyURL.setAttribute('data-clipboard-text', window.location.origin + "#" + parser.toMagnetURI(parsed));
copyMagnet.setAttribute('data-clipboard-text', parser.toMagnetURI(parsed));
examples.style.display = 'none';
properties.style.display = 'flex';
window.location.hash = parser.toMagnetURI(parsed);
@@ -38250,6 +38275,7 @@ function propertyChange(e) {
function resetProperties() {
document.getElementById('magnet').value = "";
document.getElementById('torrent').value = "";
examples.style.display = 'flex';
properties.style.display = 'none';
name.value = "";
created.value = "";

2
bundle.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -59,15 +59,24 @@
</header>
<div id="startButtons">
<input id="magnet" type="text" placeholder="Enter Magnet URL" aria-label="Enter Magnet URL and press enter" />
<input id="magnet" type="text" placeholder="Enter URL" aria-label="Enter URL and press enter" />
<label for="magnet" class="sr-only">
Enter Magnet link and press enter
Enter URL and press enter
</label>
<input id="torrent" type="file" aria-label="Select Torrent file" />
<label for="torrent">
<span class="fas fa-cloud-upload" aria-hidden="true"></span> Select Torrent File
</label>
</div>
<div id="examples">
<div>...or, try some examples!</div>
<button id="example1" aria-label="Load Magnet Example"><span class="fal fa-magnet" aria-hidden="true"></span> Magnet URL</button>
<button id="example2" aria-label="Load URL to Torrent File Example"><span class="fal fa-link" aria-hidden="true"></span> URL to Torrent File</button>
<button id="example3" aria-label="Load Torrent File Example"><span class="fal fa-file-alt" aria-hidden="true"></span> Torrent File</button>
</div>
<div id="properties" style="display:none">

File diff suppressed because one or more lines are too long

View File

@@ -6,6 +6,10 @@ const mime = require('mime-types');
const WebTorrent = require('webtorrent');
const tippy = require('tippy.js').default;
var examples = document.getElementById('examples');
var example1 = document.getElementById('example1');
var example2 = document.getElementById('example2');
var example3 = document.getElementById('example3');
var properties = document.getElementById('properties');
var originalSourceIcon = document.getElementById('originalSourceIcon');
var source;
@@ -95,6 +99,26 @@ function start() {
});
});
example1.addEventListener('click', function(event) {
event.preventDefault();
notyf.success("Parsing Ubuntu 20.04 Magnet URL");
parse("magnet:?xt=urn:btih:9fc20b9e98ea98b4a35e6223041a5ef94ea27809&dn=ubuntu-20.04-desktop-amd64.iso&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce");
});
example2.addEventListener('click', async function(event) {
event.preventDefault();
notyf.success("Fetching and Parsing &ldquo;The WIRED CD&rdquo; Torrent File...");
parseRemote("https://webtorrent.io/torrents/wired-cd.torrent");
});
example3.addEventListener('click', async function(event) {
event.preventDefault();
notyf.success("Parsing Jack Johnson Archive.org Torrent File");
let response = await fetch("jj2008-06-14.mk4_archive.torrent");
let arrayBuffer = await response.arrayBuffer();
parse(Buffer.from(arrayBuffer));
});
let copyurl = new clipboard('#copyURL');
copyurl.on('success', function(e) {
notyf.success('Copied site URL to clipboard!');
@@ -176,7 +200,7 @@ function parse(toLoad) {
function parseRemote(toLoad) {
parser.remote(toLoad, function(err, result) {
if (err) {
notyf.error('Problem remotely fetching file or parsing result');
notyf.error('Problem remotely fetching that file or parsing result');
console.warn(err);
resetProperties();
return;
@@ -283,6 +307,7 @@ function display() {
copyURL.setAttribute('data-clipboard-text', window.location.origin + "#" + parser.toMagnetURI(parsed));
copyMagnet.setAttribute('data-clipboard-text', parser.toMagnetURI(parsed));
examples.style.display = 'none';
properties.style.display = 'flex';
window.location.hash = parser.toMagnetURI(parsed);
@@ -372,6 +397,7 @@ function propertyChange(e) {
function resetProperties() {
document.getElementById('magnet').value = "";
document.getElementById('torrent').value = "";
examples.style.display = 'flex';
properties.style.display = 'none';
name.value = "";
created.value = "";

View File

@@ -140,7 +140,7 @@ footer > a {
justify-content: space-evenly;
}
#startButtons > * {
#startButtons > *, #examples > button {
width: 440px;
height: 40px;
line-height: 22px;
@@ -166,6 +166,23 @@ label[for="torrent"] {
cursor: pointer;
}
#examples {
width: 100%;
height: 180px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
}
#examples > button {
background: var(--light-blue);
width: 440px;
height: 40px;
line-height: 22px;
text-align: center;
}
#properties {
position: relative;
max-width: 960px;
@@ -338,7 +355,7 @@ input {
text-align: center;
}
#announce > * > *, #urlList > * > *, #addTracker, #addWebseed {
#announce > * > *, #urlList > * > *, #addTracker, #addWebseed, #examples > button {
width: 80vw;
}