/usr/share/criterion/templates/js/jquery.criterion.js is in libghc-criterion-dev 0.6.2.0-3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | (function ($) {
$.zip = function(a,b) {
var x = Math.min(a.length,b.length);
var c = new Array(x);
for (var i = 0; i < x; i++)
c[i] = [a[i],b[i]];
return c;
};
$.mean = function(ary) {
var m = 0, i = 0;
while (i < ary.length) {
var j = i++;
m += (ary[j] - m) / i;
}
return m;
};
$.timeUnits = function(secs) {
if (secs < 0) return timeUnits(-secs);
else if (secs >= 1e9) return [1e-9, "Gs"];
else if (secs >= 1e6) return [1e-6, "Ms"];
else if (secs >= 1) return [1, "s"];
else if (secs >= 1e-3) return [1e3, "ms"];
else if (secs >= 1e-6) return [1e6, "\u03bcs"];
else if (secs >= 1e-9) return [1e9, "ns"];
else if (secs >= 1e-12) return [1e12, "ps"];
};
$.scaleTimes = function(ary) {
var s = $.timeUnits($.mean(ary));
return [$.scaleBy(s[0], ary), s[1]];
};
$.scaleBy = function(x, ary) {
var nary = new Array(ary.length);
for (var i = 0; i < ary.length; i++)
nary[i] = ary[i] * x;
return nary;
};
$.renderTime = function(text) {
var x = parseFloat(text);
var t = $.timeUnits(x);
x *= t[0];
if (x >= 1000 || x <= -1000) return x.toFixed() + " " + t[1];
var prec = 5;
if (x < 0) prec++;
return x.toString().substring(0,prec) + " " + t[1];
};
$.unitFormatter = function(units) {
var ticked = 0;
return function(val,axis) {
var s = val.toFixed(axis.tickDecimals);
if (ticked > 1)
return s;
else {
ticked++;
return s + ' ' + units;
}
};
};
$.addTooltip = function(name, renderText) {
function showTooltip(x, y, contents) {
$('<div id="tooltip">' + contents + '</div>').css( {
position: 'absolute',
display: 'none',
top: y + 5,
left: x + 5,
border: '1px solid #fdd',
padding: '2px',
'background-color': '#fee',
opacity: 0.80
}).appendTo("body").fadeIn(200);
};
var pp = null;
$(name).bind("plothover", function (event, pos, item) {
$("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2));
if (item) {
if (pp != item.dataIndex) {
pp = item.dataIndex;
$("#tooltip").remove();
var x = item.datapoint[0].toFixed(2),
y = item.datapoint[1].toFixed(2);
showTooltip(item.pageX, item.pageY, renderText(x,y));
}
}
else {
$("#tooltip").remove();
pp = null;
}
});
};
})(jQuery);
|