From d5c98d16091de59e826e91e28cea65f403b39331 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 27 Oct 2022 08:01:48 +0200 Subject: human readable filesize --- client-web/source/resource/file.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'client-web/source/resource') diff --git a/client-web/source/resource/file.ts b/client-web/source/resource/file.ts index fedce7b..2b4c7fc 100644 --- a/client-web/source/resource/file.ts +++ b/client-web/source/resource/file.ts @@ -5,7 +5,7 @@ */ /// -import { ebutton, ediv, espan, sleep } from "../helper.ts"; +import { display_filesize, ebutton, ediv, espan, sleep } from "../helper.ts"; import { log } from "../logger.ts"; import { StreamDownload } from "../sw/download_stream.ts"; import { LocalResource, ResourceHandlerDecl } from "./mod.ts"; @@ -25,7 +25,7 @@ export const resource_file: ResourceHandlerDecl = { return { info, el: ediv({}, - espan(`File: ${JSON.stringify(info.label)}`), + espan(`File: ${JSON.stringify(info.label)} (${display_filesize(info.size!)})`), download_button, ), on_statechange(_s) { }, @@ -34,7 +34,7 @@ export const resource_file: ResourceHandlerDecl = { const download = StreamDownload( info.size!, info.label ?? "file", position => { - display.status = `${position} / ${info.size}` + display.status = `${display_filesize(position)} / ${display_filesize(info.size!)}` } ); @@ -114,7 +114,7 @@ function file_res_inner(file: File): LocalResource { for (let i = 0; i < chunk.length; i += MAX_CHUNK_SIZE) { channel.send(chunk.slice(i, Math.min(i + MAX_CHUNK_SIZE, chunk.length))) } - display.status = `${position} / ${file.size} (buffer: ${channel.bufferedAmount})` + display.status = `${display_filesize(position)} / ${display_filesize(file.size!)}; (buffer=${display_filesize(channel.bufferedAmount)})` } const feed_until_full = async () => { // this has to do with a bad browser implementation -- cgit v1.2.3-70-g09d2