#
Junjie
昨天 5ee674134658e129b4d63cc160490ebc8c3200ef
src/main/webapp/static/js/wrkAnalysis/wrkAnalysis.js
@@ -29,6 +29,11 @@
        return {
            summary: {
                taskCount: 0,
                taskStartTime: null,
                taskStartTime$: "",
                taskEndTime: null,
                taskEndTime$: "",
                taskDurationMs: null,
                avgTotalDurationMs: null,
                avgStationDurationMs: null,
                avgCraneDurationMs: null,
@@ -743,11 +748,7 @@
                if (!isFinite(num)) {
                    return "0s";
                }
                var text = String(num);
                if (text.indexOf(".") >= 0) {
                    text = text.replace(/0+$/, "").replace(/\.$/, "");
                }
                return text + "s";
                return this.formatDurationBySeconds(num);
            },
            formatDuration: function (value) {
                if (value === null || value === undefined || value === "") {
@@ -760,17 +761,40 @@
                if (ms < 1000) {
                    return Math.round(ms) + " ms";
                }
                var totalSeconds = Math.floor(ms / 1000);
                var hours = Math.floor(totalSeconds / 3600);
                var minutes = Math.floor((totalSeconds % 3600) / 60);
                var seconds = totalSeconds % 60;
                return this.formatDurationBySeconds(ms / 1000);
            },
            formatDurationBySeconds: function (seconds) {
                var totalSeconds = Number(seconds || 0);
                if (!isFinite(totalSeconds)) {
                    return "0s";
                }
                var safeSeconds = Math.max(0, totalSeconds);
                if (safeSeconds < 60) {
                    return this.trimTrailingZeros(safeSeconds) + "s";
                }
                var hours = Math.floor(safeSeconds / 3600);
                var minutes = Math.floor((safeSeconds % 3600) / 60);
                var remainSeconds = safeSeconds - hours * 3600 - minutes * 60;
                var secondText = this.trimTrailingZeros(remainSeconds);
                if (hours > 0) {
                    return hours + "h " + this.pad(minutes) + "m " + this.pad(seconds) + "s";
                    return hours + "h" + this.pad(minutes) + "m" + this.padSeconds(secondText) + "s";
                }
                if (minutes > 0) {
                    return minutes + "m " + this.pad(seconds) + "s";
                return minutes + "m" + this.padSeconds(secondText) + "s";
            },
            trimTrailingZeros: function (value) {
                var text = String(Number(Number(value).toFixed(3)));
                if (text.indexOf(".") >= 0) {
                    text = text.replace(/0+$/, "").replace(/\.$/, "");
                }
                return seconds + "s";
                return text;
            },
            padSeconds: function (value) {
                var text = String(value);
                if (text.indexOf(".") >= 0) {
                    var parts = text.split(".");
                    return (parts[0].length < 2 ? "0" + parts[0] : parts[0]) + "." + parts[1];
                }
                return text.length < 2 ? "0" + text : text;
            }
        }
    });