Renamed and changed convertToMins function to work with larger values

This commit is contained in:
Core 2022-02-07 19:23:22 +00:00
parent 3340fb93df
commit 21026816fe
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
4 changed files with 24 additions and 10 deletions

View file

@ -1242,10 +1242,24 @@ const app = new Vue({
return this.playerLCD.playbackDuration return this.playerLCD.playbackDuration
} }
}, },
convertToMins(time) { convertTime(time) {
let mins = Math.floor(time / 60) if (typeof time !== "number") {
let seconds = (Math.floor(time % 60) / 100).toFixed(2) time = parseInt(time)
return `${mins}:${seconds.replace("0.", "")}` }
const timeGates = {
600: 15,
3600: 14,
36000: 12,
}
for (let key in timeGates) {
if (time < key) {
return new Date(time * 1000).toISOString().substring(timeGates[key], 19)
}
}
return new Date(time * 1000).toISOString().substring(11, 19)
}, },
hashCode(str) { hashCode(str) {
let hash = 0, let hash = 0,

View file

@ -80,8 +80,8 @@
<div class="song-duration" <div class="song-duration"
style="justify-content: space-between; height: 1px;" style="justify-content: space-between; height: 1px;"
:style="[chrome.progresshover ? {'display': 'flex'} : {'display' : 'none'} ]"> :style="[chrome.progresshover ? {'display': 'flex'} : {'display' : 'none'} ]">
<p style="width: auto">{{ convertToMins(getSongProgress()) }}</p> <p style="width: auto">{{ convertTime(getSongProgress()) }}</p>
<p style="width: auto">{{ convertToMins(mk.currentPlaybackDuration) }} <p style="width: auto">{{ convertTime(mk.currentPlaybackDuration) }}
</p> </p>
</div> </div>

View file

@ -41,8 +41,8 @@
<div class="song-progress"> <div class="song-progress">
<div class="song-duration" style="justify-content: space-between; height: 1px;" <div class="song-duration" style="justify-content: space-between; height: 1px;"
:style="[app.chrome.progresshover ? {'display': 'flex'} : {'display' : 'none'} ]"> :style="[app.chrome.progresshover ? {'display': 'flex'} : {'display' : 'none'} ]">
<p style="width: auto">{{ app.convertToMins(app.getSongProgress()) }}</p> <p style="width: auto">{{ app.convertTime(app.getSongProgress()) }}</p>
<p style="width: auto">{{ app.convertToMins(app.mk.currentPlaybackDuration) }}</p> <p style="width: auto">{{ app.convertTime(app.mk.currentPlaybackDuration) }}</p>
</div> </div>
<input type="range" step="0.01" min="0" :style="app.progressBarStyle()" <input type="range" step="0.01" min="0" :style="app.progressBarStyle()"

View file

@ -44,8 +44,8 @@
<div class="song-progress"> <div class="song-progress">
<div class="song-duration" style="justify-content: space-between; height: 1px; margin-bottom: 1px;" <div class="song-duration" style="justify-content: space-between; height: 1px; margin-bottom: 1px;"
:style="[app.chrome.progresshover ? {'display': 'flex'} : {'display' : 'none'} ]"> :style="[app.chrome.progresshover ? {'display': 'flex'} : {'display' : 'none'} ]">
<p style="width: auto">{{ app.convertToMins(app.getSongProgress()) }}</p> <p style="width: auto">{{ app.convertTime(app.getSongProgress()) }}</p>
<p style="width: auto">{{ app.convertToMins(app.mk.currentPlaybackDuration) }}</p> <p style="width: auto">{{ app.convertTime(app.mk.currentPlaybackDuration) }}</p>
</div> </div>
<input type="range" step="0.01" min="0" :style="app.progressBarStyle()" <input type="range" step="0.01" min="0" :style="app.progressBarStyle()"