Skip to content

Instantly share code, notes, and snippets.

@goliatone
Created June 23, 2014 19:49
Show Gist options
  • Save goliatone/09cef5fd2262e0392c86 to your computer and use it in GitHub Desktop.
Save goliatone/09cef5fd2262e0392c86 to your computer and use it in GitHub Desktop.
var D = {
digitize: function(obj) {
var data = [];
$.each(obj, function(i, value) {
value = value.toString();
if (value.length == 1) {
value = '0' + value;
}
for (var x = 0; x < value.length; x++) {
data.push(value.charAt(x));
}
});
if (data.length > this.minimumDigits) {
this.minimumDigits = data.length;
}
if (this.minimumDigits > data.length) {
data.unshift('0');
}
return data;
},
getMinuteCounter: function() {
var obj = this.digitize([
this.getMinutes(),
this.getSeconds(true)
]);
return obj;
},
getSeconds: function(mod) {
var seconds = this.time;
if (mod) {
if (seconds == 60) {
seconds = 0;
} else {
seconds = seconds % 60;
}
}
return Math.ceil(seconds);
},
getMinutes: function(mod) {
var minutes = this.time / 60;
if (mod) {
minutes = minutes % 60;
}
return Math.floor(minutes);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment