Im in need to make a countdown like this:
<div class="countdown" countdown="1482400417">00:10:02</div>
where the countdown attribute is the time when its finished. the difference is showed in hours:minutes:secs , and it updates each second.
How would i do this in angularjs, when i have multiple countdowns like that?
I did a little digging, and i found something that did something simular, but i couldnt understand the code. So ill post the code i found:
Travian.Directive.countdown = function(a) {
return function(c, b, l) {
function g() {
if ("undefined" != typeof a.K()) {
h = b.attr("countdown");
var c = h - a.K();
if (0 > c || isNaN(c)) {
return Travian.tick.unbind(e), e = null, b.text(
la(0)), !1
}
var g = "";
l.showDaysLimit && c >= l.showDaysLimit ? (c = Math
.round(c / 86400), c == f ? g = m : (g =
Travian.translate("ForDays", {
x: c
}), f = c)) : g = la(c, l.countdownShort &&
c < l.countdownShort);
m != g && (m = g, b.text(g))
}
}
var h, e = null,
m = "",
f = 0;
l.showDaysLimit && c.$on("newTranslation", function() {
f = 0
});
l.$observe("countdown", function(a) {
"undefined" != typeof a && null == e && (e =
Travian.tick.bind(g))
});
b.bind("$destroy", function() {
Travian.tick.unbind(e)
})
}
};
Travian.tick = new function() {
var a = {};
(function B() {
window.setTimeout(B, 100);
var b = {}, c;
for(c in a) {
a.hasOwnProperty(c) && "function" === typeof a[c] && (a[c](), b[c] = a[c])
}
a = b
})();
return{bind:function(b, c) {
"function" === typeof b && (c = b, b = na("tick"));
c();
a[b] = c;
return b
}, unbind:function(b) {
a[b] = null
}}
};