blob: df29b7e9cd1876adc229de738fdeac7942566f95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
function pluralize (n, s) {
return n + " " + (n == 1 ? s : s + "s");
}
function toTime (time) {
var str = [];
time /= 1000;
if (time > 86400) {
str.push( pluralize( Math.floor(time / 86400), "day" ) );
}
if (time > 3600) {
str.push( pluralize( Math.floor(time / 3600) % 24, "hour" ) );
}
if (time > 60) {
str.push( pluralize( Math.floor(time / 60) % 60, "minute" ) );
}
var seconds = Math.floor(100 * (time % 60)) / 100;
seconds = (seconds + "").split(".");
if (seconds.length == 1) seconds[1] = "00";
// if (seconds[0].length == 1) seconds[0] = "0" + seconds[0];
if (seconds[1].length == 1) seconds[1] = seconds[1] + "0";
str.push( pluralize( seconds[0] + "." + seconds[1], "second" ) );
return str.join(", ");
}
|