From 4648126f031ab3bb9626557af92f686d75493fe5 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 7 Dec 2024 09:45:47 +0700 Subject: [PATCH] Use toFixed(1) in stats --- dist/better-xcloud.lite.user.js | 12 ++++++------ dist/better-xcloud.user.js | 12 ++++++------ src/utils/html.ts | 2 +- src/utils/stream-stats-collector.ts | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dist/better-xcloud.lite.user.js b/dist/better-xcloud.lite.user.js index a32750b..a83d192 100755 --- a/dist/better-xcloud.lite.user.js +++ b/dist/better-xcloud.lite.user.js @@ -764,7 +764,7 @@ function clearDataSet($elm) { var FILE_SIZE_UNITS = ["B", "KB", "MB", "GB", "TB"]; function humanFileSize(size) { let i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024)); - return (size / Math.pow(1024, i)).toFixed(2) + " " + FILE_SIZE_UNITS[i]; + return (size / Math.pow(1024, i)).toFixed(1) + " " + FILE_SIZE_UNITS[i]; } function secondsToHm(seconds) { let h = Math.floor(seconds / 3600), m = Math.floor(seconds % 3600 / 60) + 1; @@ -2000,7 +2000,7 @@ class StreamStatsCollector { current: 0, grades: [30, 40, 60], toString() { - return `${this.current.toFixed(2)}ms`; + return `${this.current.toFixed(1)}ms`; } }, fps: { @@ -2013,14 +2013,14 @@ class StreamStatsCollector { btr: { current: 0, toString() { - return `${this.current.toFixed(2)} Mbps`; + return `${this.current.toFixed(1)} Mbps`; } }, fl: { received: 0, dropped: 0, toString() { - let framesDroppedPercentage = (this.dropped * 100 / (this.dropped + this.received || 1)).toFixed(2); + let framesDroppedPercentage = (this.dropped * 100 / (this.dropped + this.received || 1)).toFixed(1); return framesDroppedPercentage === "0.00" ? this.dropped.toString() : `${this.dropped} (${framesDroppedPercentage}%)`; } }, @@ -2028,7 +2028,7 @@ class StreamStatsCollector { received: 0, dropped: 0, toString() { - let packetsLostPercentage = (this.dropped * 100 / (this.dropped + this.received || 1)).toFixed(2); + let packetsLostPercentage = (this.dropped * 100 / (this.dropped + this.received || 1)).toFixed(1); return packetsLostPercentage === "0.00" ? this.dropped.toString() : `${this.dropped} (${packetsLostPercentage}%)`; } }, @@ -2037,7 +2037,7 @@ class StreamStatsCollector { total: 0, grades: [6, 9, 12], toString() { - return isNaN(this.current) ? "??ms" : `${this.current.toFixed(2)}ms`; + return isNaN(this.current) ? "??ms" : `${this.current.toFixed(1)}ms`; } }, dl: { diff --git a/dist/better-xcloud.user.js b/dist/better-xcloud.user.js index 7683f33..e85f80d 100755 --- a/dist/better-xcloud.user.js +++ b/dist/better-xcloud.user.js @@ -820,7 +820,7 @@ function renderPresetsList($select, allPresets, selectedValue, addOffValue = !1) var FILE_SIZE_UNITS = ["B", "KB", "MB", "GB", "TB"]; function humanFileSize(size) { let i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024)); - return (size / Math.pow(1024, i)).toFixed(2) + " " + FILE_SIZE_UNITS[i]; + return (size / Math.pow(1024, i)).toFixed(1) + " " + FILE_SIZE_UNITS[i]; } function secondsToHm(seconds) { let h = Math.floor(seconds / 3600), m = Math.floor(seconds % 3600 / 60) + 1; @@ -2109,7 +2109,7 @@ class StreamStatsCollector { current: 0, grades: [30, 40, 60], toString() { - return `${this.current.toFixed(2)}ms`; + return `${this.current.toFixed(1)}ms`; } }, fps: { @@ -2122,14 +2122,14 @@ class StreamStatsCollector { btr: { current: 0, toString() { - return `${this.current.toFixed(2)} Mbps`; + return `${this.current.toFixed(1)} Mbps`; } }, fl: { received: 0, dropped: 0, toString() { - let framesDroppedPercentage = (this.dropped * 100 / (this.dropped + this.received || 1)).toFixed(2); + let framesDroppedPercentage = (this.dropped * 100 / (this.dropped + this.received || 1)).toFixed(1); return framesDroppedPercentage === "0.00" ? this.dropped.toString() : `${this.dropped} (${framesDroppedPercentage}%)`; } }, @@ -2137,7 +2137,7 @@ class StreamStatsCollector { received: 0, dropped: 0, toString() { - let packetsLostPercentage = (this.dropped * 100 / (this.dropped + this.received || 1)).toFixed(2); + let packetsLostPercentage = (this.dropped * 100 / (this.dropped + this.received || 1)).toFixed(1); return packetsLostPercentage === "0.00" ? this.dropped.toString() : `${this.dropped} (${packetsLostPercentage}%)`; } }, @@ -2146,7 +2146,7 @@ class StreamStatsCollector { total: 0, grades: [6, 9, 12], toString() { - return isNaN(this.current) ? "??ms" : `${this.current.toFixed(2)}ms`; + return isNaN(this.current) ? "??ms" : `${this.current.toFixed(1)}ms`; } }, dl: { diff --git a/src/utils/html.ts b/src/utils/html.ts index e531b61..af2569b 100755 --- a/src/utils/html.ts +++ b/src/utils/html.ts @@ -300,7 +300,7 @@ export function renderPresetsList($select: HTMLSelectEle const FILE_SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB']; export function humanFileSize(size: number) { const i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024)); - return (size / Math.pow(1024, i)).toFixed(2) + ' ' + FILE_SIZE_UNITS[i]; + return (size / Math.pow(1024, i)).toFixed(1) + ' ' + FILE_SIZE_UNITS[i]; } export function secondsToHm(seconds: number) { diff --git a/src/utils/stream-stats-collector.ts b/src/utils/stream-stats-collector.ts index 03a315a..2015a90 100755 --- a/src/utils/stream-stats-collector.ts +++ b/src/utils/stream-stats-collector.ts @@ -104,7 +104,7 @@ export class StreamStatsCollector { current: 0, grades: [30, 40, 60], toString() { - return `${this.current.toFixed(2)}ms`; + return `${this.current.toFixed(1)}ms`; }, }, @@ -119,7 +119,7 @@ export class StreamStatsCollector { [StreamStat.BITRATE]: { current: 0, toString() { - return `${this.current.toFixed(2)} Mbps`; + return `${this.current.toFixed(1)} Mbps`; }, }, @@ -127,7 +127,7 @@ export class StreamStatsCollector { received: 0, dropped: 0, toString() { - const framesDroppedPercentage = (this.dropped * 100 / ((this.dropped + this.received) || 1)).toFixed(2); + const framesDroppedPercentage = (this.dropped * 100 / ((this.dropped + this.received) || 1)).toFixed(1); return framesDroppedPercentage === '0.00' ? this.dropped.toString() : `${this.dropped} (${framesDroppedPercentage}%)`; }, }, @@ -136,7 +136,7 @@ export class StreamStatsCollector { received: 0, dropped: 0, toString() { - const packetsLostPercentage = (this.dropped * 100 / ((this.dropped + this.received) || 1)).toFixed(2); + const packetsLostPercentage = (this.dropped * 100 / ((this.dropped + this.received) || 1)).toFixed(1); return packetsLostPercentage === '0.00' ? this.dropped.toString() : `${this.dropped} (${packetsLostPercentage}%)`; }, }, @@ -146,7 +146,7 @@ export class StreamStatsCollector { total: 0, grades: [6, 9, 12], toString() { - return isNaN(this.current) ? '??ms' : `${this.current.toFixed(2)}ms`; + return isNaN(this.current) ? '??ms' : `${this.current.toFixed(1)}ms`; }, },