forked from iamvijaydev/TaskTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domPrototypes.js
35 lines (27 loc) · 842 Bytes
/
domPrototypes.js
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
34
35
// dom prototypes
// remove an entry from element
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
var preFix = function(val) {
return ('' + val).length == 2 ? '' + val : '0' + val;
}
// Convert seconds into HH:MM:SS format
Number.prototype.toHHMMSS = function () {
var ms = this;
var decs = Math.floor(ms % 1000 / 100);
var secs = Math.floor(ms % 60000 / 1000);
var mins = Math.floor(ms % 3600000 / 60000);
var hours = Math.floor(ms % (24 * 3600000) / 3600000);
var time = '';
if(hours > 0) {
time += preFix(hours) + ':';
}
if(mins > 0) {
time += preFix(mins) + ':';
}
time += preFix(secs) + ':' + preFix(decs);
return time;
}