/usr/share/smokeping/www/smokeping-zoom.js is in smokeping 2.6.11-4.
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 | /*++ from bonsai.js ++ urlObj +++++++++++++++++++++++++++++++++++++++++*/
function urlObj(url) {
var urlBaseAndParameters;
urlBaseAndParameters = url.split("?");
this.urlBase = urlBaseAndParameters[0];
this.urlParameters = urlBaseAndParameters[1].split(/[;&]/);
this.getUrlBase = urlObjGetUrlBase;
}
/*++ from bonsai.js ++ urlObjGetUrlBase +++++++++++++++++++++++++++++++*/
function urlObjGetUrlBase() {
return this.urlBase;
}
// example with minimum dimensions
var myCropper;
var StartEpoch = 0;
var EndEpoch = 0;
function changeRRDImage(coords,dimensions){
var SelectLeft = Math.min(coords.x1,coords.x2);
var SelectRight = Math.max(coords.x1,coords.x2);
if (SelectLeft == SelectRight)
return; // abort if nothing is selected.
var RRDLeft = 67; // difference between left border of RRD image and content
var RRDRight = 26; // difference between right border of RRD image and content
var RRDImgWidth = $('zoom').getDimensions().width; // Width of the Smokeping RRD Graphik
var RRDImgUsable = RRDImgWidth - RRDRight - RRDLeft;
var form = $('range_form');
if (StartEpoch == 0)
StartEpoch = +$F('epoch_start');
if (EndEpoch == 0)
EndEpoch = +$F('epoch_end');
var DivEpoch = EndEpoch - StartEpoch;
var Target = $F('target');
var Hierarchy = $F('hierarchy');
// construct Image URL
var myURLObj = new urlObj(document.URL);
var myURL = myURLObj.getUrlBase();
// Generate Selected Range in Unix Timestamps
var LeftFactor = 1;
var RightFactor = 1;
if (SelectLeft < RRDLeft)
LeftFactor = 10;
StartEpoch = Math.floor(StartEpoch + (SelectLeft - RRDLeft) * DivEpoch / RRDImgUsable * LeftFactor );
if (SelectRight > RRDImgWidth - RRDRight)
RightFactor = 10;
EndEpoch = Math.ceil(EndEpoch + (SelectRight - (RRDImgWidth - RRDRight) ) * DivEpoch / RRDImgUsable * RightFactor);
$('zoom').src = myURL + '?displaymode=a;start=' + StartEpoch + ';end=' + EndEpoch + ';target=' + Target + ';hierarchy=' + Hierarchy;
myCropper.setParams();
};
Event.observe(
window,
'load',
function() {
if ( $('zoom') != null ){
myCropper = new Cropper.Img(
'zoom',
{
minHeight: $('zoom').getDimensions().height,
maxHeight: $('zoom').getDimensions().height,
onEndCrop: changeRRDImage
}
)
}
}
);
|