time formatting updated

This commit is contained in:
Hamza Zia 2012-06-06 16:09:48 +08:00
parent 4f6c98c563
commit ca3f32a130

View File

@ -165,6 +165,7 @@ function changeLength(len, pref) {
} }
function changeTime(time) { function changeTime(time) {
time = parseInt(time); time = parseInt(time);
if(!time) return "infinite";
if(time < 60) return time + " s"; if(time < 60) return time + " s";
else if(time < 60*60) return (time/60).toFixed(2) + " min"; else if(time < 60*60) return (time/60).toFixed(2) + " min";
else if(time < 60*60*24) return (time/(60*60)).toFixed(2) + " hours"; else if(time < 60*60*24) return (time/(60*60)).toFixed(2) + " hours";
@ -184,7 +185,6 @@ function getTemplateCtx(data) {
} }
var eta = changeTime((data.totalLength-data.completedLength)/data.downloadSpeed); var eta = changeTime((data.totalLength-data.completedLength)/data.downloadSpeed);
if(!eta) eta = "infinite";
return { return {
name: name, name: name,
status: data.status, status: data.status,