mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-21 09:09:01 +00:00
parent
cbb3d1198b
commit
e61a05a87b
4 changed files with 16 additions and 20 deletions
|
|
@ -25,8 +25,8 @@ export const getBalanceText = balance => {
|
|||
export const getVolumeText = volume => `Volume: ${volume}%`;
|
||||
|
||||
export const getPositionText = (duration, seekToPercent) => {
|
||||
const newElapsedStr = getTimeStr(duration * seekToPercent / 100);
|
||||
const durationStr = getTimeStr(duration);
|
||||
const newElapsedStr = getTimeStr(duration * seekToPercent / 100, false);
|
||||
const durationStr = getTimeStr(duration, false);
|
||||
return `Seek to: ${newElapsedStr}/${durationStr} (${seekToPercent}%)`;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -161,11 +161,6 @@ exports[`PlaylistWindow renders to snapshot 1`] = `
|
|||
className="playlist-running-time-display draggable"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
className=" character character-48"
|
||||
>
|
||||
0
|
||||
</div>
|
||||
<div
|
||||
className=" character character-48"
|
||||
>
|
||||
|
|
@ -196,11 +191,6 @@ exports[`PlaylistWindow renders to snapshot 1`] = `
|
|||
>
|
||||
0
|
||||
</div>
|
||||
<div
|
||||
className=" character character-48"
|
||||
>
|
||||
0
|
||||
</div>
|
||||
<div
|
||||
className=" character character-58"
|
||||
>
|
||||
|
|
|
|||
18
js/utils.js
18
js/utils.js
|
|
@ -10,14 +10,20 @@ export const getTimeObj = time => {
|
|||
};
|
||||
};
|
||||
|
||||
export const getTimeStr = time => {
|
||||
const timeObj = getTimeObj(time);
|
||||
export const getTimeStr = (time, truncate = true) => {
|
||||
const {
|
||||
minutesFirstDigit,
|
||||
minutesSecondDigit,
|
||||
secondsFirstDigit,
|
||||
secondsSecondDigit
|
||||
} = getTimeObj(time);
|
||||
|
||||
return [
|
||||
timeObj.minutesFirstDigit,
|
||||
timeObj.minutesSecondDigit,
|
||||
truncate ? minutesFirstDigit || "" : minutesFirstDigit,
|
||||
minutesSecondDigit,
|
||||
":",
|
||||
timeObj.secondsFirstDigit,
|
||||
timeObj.secondsSecondDigit
|
||||
secondsFirstDigit,
|
||||
secondsSecondDigit
|
||||
].join("");
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ describe("getTimeStr", () => {
|
|||
const expected = "20:34";
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
it("pads with zeros", () => {
|
||||
it("pads with only one zero", () => {
|
||||
const actual = getTimeStr(5);
|
||||
const expected = "00:05";
|
||||
const expected = "0:05";
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
it("truncates extra minutes", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue