deemixer/public/js/app/utils.js

34 lines
800 B
JavaScript
Raw Normal View History

function isValidURL(text){
2020-04-14 14:48:13 +00:00
if (text.toLowerCase().startsWith("http")){
if (text.toLowerCase().indexOf("deezer.com") >= 0 || text.toLowerCase().indexOf("open.spotify.com") >= 0)
return true
2020-04-14 14:48:13 +00:00
}else if (text.toLowerCase().startsWith("spotify:"))
return true
return false
}
2020-04-14 14:48:13 +00:00
2020-04-09 10:24:49 +00:00
function convertDuration(duration) {
//convert from seconds only to mm:ss format
var mm, ss
mm = Math.floor(duration / 60)
ss = duration - (mm * 60)
//add leading zero if ss < 0
if (ss < 10) {
ss = "0" + ss
}
return mm + ":" + ss
}
function convertDurationSeparated(duration){
var hh, mm, ss
mm = Math.floor(duration / 60)
hh = Math.floor(mm / 60)
ss = duration - (mm * 60)
mm -= hh*60
return [hh, mm, ss]
}
function numberWithDots(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}