Skip to content

feat(webserver): unify file size and speed units in default template - #218

Merged
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:feature/issues18
Jun 20, 2026
Merged

feat(webserver): unify file size and speed units in default template#218
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:feature/issues18

Conversation

@ngosang

@ngosang ngosang commented Jun 20, 2026

Copy link
Copy Markdown
Member

The download, shared and search pages each defined their own CastToXBytes function with inconsistent units (kb/KB, mb/MB, " b"/" bytes") and no decimal rounding, so the same value looked different across pages.

Unit formatting is now done client-side in JavaScript: CastToXBytes emits the raw byte count inside a and a shared formatBytes() script at the end of each page renders consistent, human-readable units (Bytes / KB / MB / GB, 1024 divisor, 2 decimals; speed keeps the trailing "/s"). This is required because the webserver's embedded PHP interpreter lacks sprintf/round/number_format, which made server-side formatting impossible. The download totals still accumulate raw bytes via the &$count parameter.

The download, shared and search pages each defined their own CastToXBytes
function with inconsistent units (kb/KB, mb/MB, " b"/" bytes") and no
decimal rounding, so the same value looked different across pages.

Unit formatting is now done client-side in JavaScript: CastToXBytes emits
the raw byte count inside a <span class="js-size"> and a shared formatBytes()
script at the end of each page renders consistent, human-readable units
(Bytes / KB / MB / GB, 1024 divisor, 2 decimals; speed keeps the trailing
"/s"). This is required because the webserver's embedded PHP interpreter
lacks sprintf/round/number_format, which made server-side formatting
impossible. The download totals still accumulate raw bytes via the
&$count parameter.
@ngosang
ngosang merged commit 9374e25 into amule-org:master Jun 20, 2026
10 checks passed
@ngosang
ngosang deleted the feature/issues18 branch June 20, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant