Database Reference
In-Depth Information
bindCounter($(elt).attr("data-counter"),$(elt))
});
}
Next, find the directional indicator, change the amount fields included in
the counter metric, and bind the whole thing to a custom event of the
form data:<counter name> . Found in public/javascripts/
dashboard.js , the implementation is as follows:
function bindCounter(counterName,$elt) {
$elt.text("--");
var $dir = $('span[data-direction='+counterName+']');
var $chg = $('span[data-change='+counterName+']');
var last = NaN;
$(document).on('data:'+counterName,function(event,data)
{
$elt.text(data);
if(isFinite(last)) {
var diff = data - last;
if(diff > 0) {
$dir.removeClass("glyphicon-arrow-down");
$dir.addClass("glyphicon-arrow-up");
} else {
$dir.removeClass("glyphicon-arrow-up");
$dir.addClass("glyphicon-arrow-down");
}
diff = Math.abs(diff);
if($chg.hasClass("percentage")) {
diff = Math.round(1000*diff/last)/10;
$chg.text(diff+"%");
} else {
$chg.text(diff);
}
}
last = data;
});
$chg.on('click',function() {
Search WWH ::




Custom Search