42 lines
949 B
Plaintext
42 lines
949 B
Plaintext
|
function indexOf(str, val) {
|
||
|
if (str.indexOf(val) != -1) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function formatCount(count){
|
||
|
var counter = parseInt(count)
|
||
|
if(counter > 100000000){
|
||
|
return (counter / 100000000).toFixed(1) + '亿'
|
||
|
}else if(counter > 10000){
|
||
|
return (counter / 10000).toFixed(1) + '万'
|
||
|
}else{
|
||
|
return counter
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// 12->12 5->05
|
||
|
function padLeftZero(str){
|
||
|
str = str + ''
|
||
|
return ("00" + str).slice(str.length)
|
||
|
}
|
||
|
|
||
|
function formatDuration(duration, isMilliseconds) {
|
||
|
isMilliseconds = isMilliseconds === undefined
|
||
|
if (isMilliseconds) {
|
||
|
duration = duration / 1000
|
||
|
}
|
||
|
|
||
|
var minute = Math.floor(duration / 60)
|
||
|
var second = Math.floor(duration) % 60
|
||
|
|
||
|
return padLeftZero(minute) + ":" + padLeftZero(second)
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
indexOf: indexOf,
|
||
|
formatCount:formatCount,
|
||
|
formatDuration:formatDuration
|
||
|
}
|