fix: Improves formatting and ETA calculation
Corrects formatting for improved readability in download status messages. Adjusts ETA calculation to display seconds instead of milliseconds for greater clarity.
This commit is contained in:
parent
9190171c9e
commit
ee1d360fb5
1 changed files with 16 additions and 18 deletions
|
@ -45,9 +45,8 @@ async function uploadFile(trackerUrl) {
|
||||||
if (!response.ok) throw new Error("Failed to generate mnemonic");
|
if (!response.ok) throw new Error("Failed to generate mnemonic");
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const uploadResult = document.getElementById("uploadResult");
|
const uploadResult = document.getElementById("uploadResult");
|
||||||
const downloadUrl = `${
|
const downloadUrl = `${window.location.origin
|
||||||
window.location.origin
|
}/${data.mnemonic.replaceAll(" ", ".")}`;
|
||||||
}/${data.mnemonic.replaceAll(" ", ".")}`;
|
|
||||||
history.pushState({}, "", `/${data.mnemonic.replaceAll(" ", ".")}`);
|
history.pushState({}, "", `/${data.mnemonic.replaceAll(" ", ".")}`);
|
||||||
uploadResult.innerHTML = `Seeding file. Share this mnemonic: <strong>${data.mnemonic}</strong>
|
uploadResult.innerHTML = `Seeding file. Share this mnemonic: <strong>${data.mnemonic}</strong>
|
||||||
<br>Note that the file will be available for download only as long as you keep this page open.`;
|
<br>Note that the file will be available for download only as long as you keep this page open.`;
|
||||||
|
@ -168,27 +167,26 @@ async function downloadFile(trackerUrl) {
|
||||||
downloadResult.innerHTML = `Downloading:
|
downloadResult.innerHTML = `Downloading:
|
||||||
<strong>${torrent.files[0].name}</strong>
|
<strong>${torrent.files[0].name}</strong>
|
||||||
<br>
|
<br>
|
||||||
<br><strong>Status:</strong> ${
|
<br><strong>Status:</strong> ${torrent.done ? "Completed, seeding" : "Downloading"
|
||||||
torrent.done ? "Completed, seeding" : "Downloading"
|
}
|
||||||
}
|
|
||||||
<br><strong>Peers:</strong> ${torrent.numPeers}
|
<br><strong>Peers:</strong> ${torrent.numPeers}
|
||||||
<br>
|
<br>
|
||||||
<br><strong>Downloaded:</strong> ${(
|
<br><strong>Downloaded:</strong> ${(
|
||||||
torrent.downloaded /
|
torrent.downloaded /
|
||||||
(1024 * 1024)
|
(1024 * 1024)
|
||||||
).toFixed(2)} MB / ${(torrent.length / (1024 * 1024)).toFixed(
|
).toFixed(2)} MB / ${(torrent.length / (1024 * 1024)).toFixed(
|
||||||
2
|
2
|
||||||
)} MB (${progress}%)
|
)} MB (${progress}%)
|
||||||
<br><strong>Speed:</strong> ${(
|
<br><strong>Speed:</strong> ${(
|
||||||
torrent.downloadSpeed /
|
torrent.downloadSpeed /
|
||||||
(1024 * 1024)
|
(1024 * 1024)
|
||||||
).toFixed(2)} MB/s
|
).toFixed(2)} MB/s
|
||||||
<br><strong>ETA:</strong> ${torrent.timeRemaining} seconds
|
<br><strong>ETA:</strong> ${(torrent.timeRemaining / 1000).toFixed(0)} seconds
|
||||||
<br>
|
<br>
|
||||||
<br><strong>Uploaded:</strong> ${(
|
<br><strong>Uploaded:</strong> ${(
|
||||||
torrent.uploaded /
|
torrent.uploaded /
|
||||||
(1024 * 1024)
|
(1024 * 1024)
|
||||||
).toFixed(2)} MB
|
).toFixed(2)} MB
|
||||||
<br><strong>Ratio:</strong> ${torrent.ratio.toFixed(2)}`;
|
<br><strong>Ratio:</strong> ${torrent.ratio.toFixed(2)}`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue