Generated minified JS and some formatting

This commit is contained in:
Cristian Deluxe 2016-12-07 06:23:25 +01:00
parent 3533615be4
commit 23f940fede
6 changed files with 217 additions and 191 deletions

View File

@ -1,198 +1,199 @@
function refreshZoom(query, form, image, divOverlay) {
//INIT
var qs = new Querystring(query);
init();
var scale = refreshImg();
var start_epoch = (+qs.get("rst_start_epoch", form.start_epoch.value));
var stop_epoch = (+qs.get("rst_stop_epoch", form.stop_epoch.value));
var initial_left;
var initial_top;
//form.btnMaj.onclick = majDates;
form.plugin_name.onblur = refreshImg;
form.start_iso8601.onblur = majDates;
form.stop_iso8601.onblur = majDates;
form.start_epoch.onblur = refreshImg;
form.stop_epoch.onblur = refreshImg;
form.lower_limit.onblur = refreshImg;
form.upper_limit.onblur = refreshImg;
form.size_x.onblur = refreshImg;
form.size_y.onblur = refreshImg;
form.btnReset.onclick = reset;
// Sets the onClick handler
image.onclick = click;
var clickCounter = 0;
//FUNCTIONS
function init(){
form.plugin_name.value = qs.get("plugin_name", "localdomain/localhost.localdomain/if_eth0");
form.start_epoch.value = qs.get("start_epoch", "1236561663");
form.stop_epoch.value = qs.get("stop_epoch", "1237561663");
form.lower_limit.value = qs.get("lower_limit", "");
form.upper_limit.value = qs.get("upper_limit", "");
form.size_x.value = qs.get("size_x", "");
form.size_y.value = qs.get("size_y", "");
updateStartStop();
}
function reset(event){
//INIT
var qs = new Querystring(query);
init();
//Can be not the initial ones in case of manual refresh
form.start_epoch.value = start_epoch;
form.stop_epoch.value = stop_epoch;
updateStartStop();
//Redraw
scale = refreshImg();
//Reset gui
clickCounter = 0;
initial_left = 0;
initial_top = 0;
image.onmousemove = undefined;
form.start_iso8601.disabled = false;
form.stop_iso8601.disabled = false;
form.start_epoch.disabled = false;
form.stop_epoch.disabled = false;
}
function refreshImg(event) {
image.src = qs.get("cgiurl_graph", "/munin-cgi/munin-cgi-graph") + "/"
+ form.plugin_name.value
+ "-pinpoint=" + parseInt(form.start_epoch.value) + "," + parseInt(form.stop_epoch.value)
+ ".png"
+ "?"
+ "&lower_limit=" + form.lower_limit.value
+ "&upper_limit=" + form.upper_limit.value
+ "&size_x=" + form.size_x.value
+ "&size_y=" + form.size_y.value
;
var scale = refreshImg();
var start_epoch = (+qs.get("rst_start_epoch", form.start_epoch.value));
var stop_epoch = (+qs.get("rst_stop_epoch", form.stop_epoch.value));
var initial_left;
var initial_top;
return ((+form.stop_epoch.value) - (+form.start_epoch.value)) / (+form.size_x.value);
}
//form.btnMaj.onclick = majDates;
form.plugin_name.onblur = refreshImg;
form.start_iso8601.onblur = majDates;
form.stop_iso8601.onblur = majDates;
form.start_epoch.onblur = refreshImg;
form.stop_epoch.onblur = refreshImg;
form.lower_limit.onblur = refreshImg;
form.upper_limit.onblur = refreshImg;
form.size_x.onblur = refreshImg;
form.size_y.onblur = refreshImg;
form.btnReset.onclick = reset;
function updateStartStop() {
form.start_iso8601.value = new Date(form.start_epoch.value * 1000).formatDate(Date.DATE_ISO8601);
form.stop_iso8601.value = new Date(form.stop_epoch.value * 1000).formatDate(Date.DATE_ISO8601);
}
// Sets the onClick handler
image.onclick = click;
var clickCounter = 0;
function divMouseMove(event) {
var delta_x;
var size_x;
//FUNCTIONS
function init() {
form.plugin_name.value = qs.get("plugin_name", "localdomain/localhost.localdomain/if_eth0");
form.start_epoch.value = qs.get("start_epoch", "1236561663");
form.stop_epoch.value = qs.get("stop_epoch", "1237561663");
form.lower_limit.value = qs.get("lower_limit", "");
form.upper_limit.value = qs.get("upper_limit", "");
form.size_x.value = qs.get("size_x", "");
form.size_y.value = qs.get("size_y", "");
// Handling the borders (X1>X2 ou X1<X2)
var posX = getCoordinatesOnImage(event)[0];
var current_width = posX - initial_left;
if (current_width < 0) {
delta_x = posX - 63; // the Y Axis is 63px from the left border
size_x = - current_width;
} else {
delta_x = initial_left - 63; // the Y Axis is 63px from the left border
size_x = current_width;
}
// Compute the epochs UNIX (only for horizontal)
form.start_epoch.value = start_epoch + scale * delta_x;
form.stop_epoch.value = start_epoch + scale * ( delta_x + size_x );
// update !
updateStartStop();
}
function startZoom(event) {
var pos = getCoordinatesOnImage(event);
initial_left = pos[0];
initial_top = pos[1];
// Fix the handles
form.start_iso8601.disabled = true;
form.stop_iso8601.disabled = true;
form.start_epoch.disabled = true;
form.stop_epoch.disabled = true;
image.onmousemove = divMouseMove;
}
function endZoom(event) {
image.onmousemove = undefined;
form.start_iso8601.disabled = false;
form.stop_iso8601.disabled = false;
form.start_epoch.disabled = false;
form.stop_epoch.disabled = false;
}
function fillDate(date, default_date) {
return date + default_date.substring(date.length, default_date.length);
}
function majDates(event) {
var default_date = "2009-01-01T00:00:00+0100";
var start_manual = fillDate(form.start_iso8601.value, default_date);
var stop_manual = fillDate(form.stop_iso8601.value, default_date);
var dateRegex = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d{4})/;
if (dateRegex.test(start_manual)) {
var date_parsed = new Date(start_manual.replace(dateRegex, "$2 $3, $1 $4:$5:$6"));
form.start_epoch.value = date_parsed.getTime() / 1000;
updateStartStop();
}
if (dateRegex.test(stop_manual)) {
var date_parsed = new Date(stop_manual.replace(dateRegex, "$2 $3, $1 $4:$5:$6"));
form.stop_epoch.value = date_parsed.getTime() / 1000;
function reset(event) {
init();
//Can be not the initial ones in case of manual refresh
form.start_epoch.value = start_epoch;
form.stop_epoch.value = stop_epoch;
updateStartStop();
//Redraw
scale = refreshImg();
//Reset gui
clickCounter = 0;
initial_left = 0;
initial_top = 0;
image.onmousemove = undefined;
form.start_iso8601.disabled = false;
form.stop_iso8601.disabled = false;
form.start_epoch.disabled = false;
form.stop_epoch.disabled = false;
}
//form.submit();
refreshImg();
}
function refreshImg(event) {
image.src = qs.get("cgiurl_graph", "/munin-cgi/munin-cgi-graph") + "/"
+ form.plugin_name.value
+ "-pinpoint=" + parseInt(form.start_epoch.value) + "," + parseInt(form.stop_epoch.value)
+ ".png"
+ "?"
+ "&lower_limit=" + form.lower_limit.value
+ "&upper_limit=" + form.upper_limit.value
+ "&size_x=" + form.size_x.value
+ "&size_y=" + form.size_y.value
;
function click(event) {
switch ((clickCounter++) % 2) {
case 0:
startZoom(event);
break;
case 1:
endZoom(event);
break;
return ((+form.stop_epoch.value) - (+form.start_epoch.value)) / (+form.size_x.value);
}
}
//Coordinates on image
function findPosition(oElement){
if(typeof( oElement.offsetParent ) != "undefined"){
for(var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent){
posX += oElement.offsetLeft;
posY += oElement.offsetTop;
}
return [ posX, posY ];
function updateStartStop() {
form.start_iso8601.value = new Date(form.start_epoch.value * 1000).formatDate(Date.DATE_ISO8601);
form.stop_iso8601.value = new Date(form.stop_epoch.value * 1000).formatDate(Date.DATE_ISO8601);
}
else{
return [ oElement.x, oElement.y ];
function divMouseMove(event) {
var delta_x;
var size_x;
// Handling the borders (X1>X2 ou X1<X2)
var posX = getCoordinatesOnImage(event)[0];
var current_width = posX - initial_left;
if (current_width < 0) {
delta_x = posX - 63; // the Y Axis is 63px from the left border
size_x = -current_width;
} else {
delta_x = initial_left - 63; // the Y Axis is 63px from the left border
size_x = current_width;
}
// Compute the epochs UNIX (only for horizontal)
form.start_epoch.value = start_epoch + scale * delta_x;
form.stop_epoch.value = start_epoch + scale * ( delta_x + size_x );
// update !
updateStartStop();
}
}
function getCoordinatesOnImage(event){
var posX = 0;
var posY = 0;
var imgPos;
imgPos = findPosition(image);
if (!event) var event = window.event;
if (event.pageX || event.pageY){
posX = event.pageX;
posY = event.pageY;
function startZoom(event) {
var pos = getCoordinatesOnImage(event);
initial_left = pos[0];
initial_top = pos[1];
// Fix the handles
form.start_iso8601.disabled = true;
form.stop_iso8601.disabled = true;
form.start_epoch.disabled = true;
form.stop_epoch.disabled = true;
image.onmousemove = divMouseMove;
}
function endZoom(event) {
image.onmousemove = undefined;
form.start_iso8601.disabled = false;
form.stop_iso8601.disabled = false;
form.start_epoch.disabled = false;
form.stop_epoch.disabled = false;
}
function fillDate(date, default_date) {
return date + default_date.substring(date.length, default_date.length);
}
function majDates(event) {
var default_date = "2009-01-01T00:00:00+0100";
var start_manual = fillDate(form.start_iso8601.value, default_date);
var stop_manual = fillDate(form.stop_iso8601.value, default_date);
var dateRegex = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d{4})/;
if (dateRegex.test(start_manual)) {
var date_parsed = new Date(start_manual.replace(dateRegex, "$2 $3, $1 $4:$5:$6"));
form.start_epoch.value = date_parsed.getTime() / 1000;
}
if (dateRegex.test(stop_manual)) {
var date_parsed = new Date(stop_manual.replace(dateRegex, "$2 $3, $1 $4:$5:$6"));
form.stop_epoch.value = date_parsed.getTime() / 1000;
}
//form.submit();
refreshImg();
}
function click(event) {
switch ((clickCounter++) % 2) {
case 0:
startZoom(event);
break;
case 1:
endZoom(event);
break;
}
}
//Coordinates on image
function findPosition(oElement) {
if (typeof( oElement.offsetParent ) != "undefined") {
for (var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent) {
posX += oElement.offsetLeft;
posY += oElement.offsetTop;
}
return [posX, posY];
}
else {
return [oElement.x, oElement.y];
}
}
function getCoordinatesOnImage(event) {
var posX = 0;
var posY = 0;
var imgPos;
imgPos = findPosition(image);
if (!event) var event = window.event;
if (event.pageX || event.pageY) {
posX = event.pageX;
posY = event.pageY;
}
else if (event.clientX || event.clientY) {
posX = event.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
posY = event.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
}
posX = posX - imgPos[0];
posY = posY - imgPos[1];
return [posX, posY];
}
else if (event.clientX || event.clientY){
posX = event.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
posY = event.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
}
posX = posX - imgPos[0];
posY = posY - imgPos[1];
return [ posX, posY ];
}
};

View File

@ -0,0 +1,6 @@
function refreshZoom(t,a,g,w){function m(){a.plugin_name.value=c.get("plugin_name","localdomain/localhost.localdomain/if_eth0");a.start_epoch.value=c.get("start_epoch","1236561663");a.stop_epoch.value=c.get("stop_epoch","1237561663");a.lower_limit.value=c.get("lower_limit","");a.upper_limit.value=c.get("upper_limit","");a.size_x.value=c.get("size_x","");a.size_y.value=c.get("size_y","");h()}function e(b){g.src=c.get("cgiurl_graph","/munin-cgi/munin-cgi-graph")+"/"+a.plugin_name.value+"-pinpoint="+
parseInt(a.start_epoch.value)+","+parseInt(a.stop_epoch.value)+".png?&lower_limit="+a.lower_limit.value+"&upper_limit="+a.upper_limit.value+"&size_x="+a.size_x.value+"&size_y="+a.size_y.value;return(+a.stop_epoch.value-+a.start_epoch.value)/+a.size_x.value}function h(){a.start_iso8601.value=(new Date(1E3*a.start_epoch.value)).formatDate(Date.DATE_ISO8601);a.stop_iso8601.value=(new Date(1E3*a.stop_epoch.value)).formatDate(Date.DATE_ISO8601)}function u(b){var d;b=n(b)[0];d=b-f;0>d?(b-=63,d=-d):b=f-
63;a.start_epoch.value=k+l*b;a.stop_epoch.value=k+l*(b+d);h()}function p(a,d){return a+d.substring(a.length,d.length)}function q(b){var d=p(a.start_iso8601.value,"2009-01-01T00:00:00+0100");b=p(a.stop_iso8601.value,"2009-01-01T00:00:00+0100");var c=/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d{4})/;c.test(d)&&(d=new Date(d.replace(c,"$2 $3, $1 $4:$5:$6")),a.start_epoch.value=d.getTime()/1E3);c.test(b)&&(d=new Date(b.replace(c,"$2 $3, $1 $4:$5:$6")),a.stop_epoch.value=d.getTime()/1E3);e()}function n(a){var d=
0,c=0,b;b=g;if("undefined"!=typeof b.offsetParent){for(var e=0,f=0;b;b=b.offsetParent)e+=b.offsetLeft,f+=b.offsetTop;b=[e,f]}else b=[b.x,b.y];a||(a=window.event);if(a.pageX||a.pageY)d=a.pageX,c=a.pageY;else if(a.clientX||a.clientY)d=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,c=a.clientY+document.body.scrollTop+document.documentElement.scrollTop;d-=b[0];c-=b[1];return[d,c]}var c=new Querystring(t);m();var l=e(),k=+c.get("rst_start_epoch",a.start_epoch.value),v=+c.get("rst_stop_epoch",
a.stop_epoch.value),f;a.plugin_name.onblur=e;a.start_iso8601.onblur=q;a.stop_iso8601.onblur=q;a.start_epoch.onblur=e;a.stop_epoch.onblur=e;a.lower_limit.onblur=e;a.upper_limit.onblur=e;a.size_x.onblur=e;a.size_y.onblur=e;a.btnReset.onclick=function(b){m();a.start_epoch.value=k;a.stop_epoch.value=v;h();l=e();f=r=0;g.onmousemove=void 0;a.start_iso8601.disabled=!1;a.stop_iso8601.disabled=!1;a.start_epoch.disabled=!1;a.stop_epoch.disabled=!1};g.onclick=function(b){switch(r++%2){case 0:f=n(b)[0];a.start_iso8601.disabled=
!0;a.stop_iso8601.disabled=!0;a.start_epoch.disabled=!0;a.stop_epoch.disabled=!0;g.onmousemove=u;break;case 1:g.onmousemove=void 0,a.start_iso8601.disabled=!1,a.stop_iso8601.disabled=!1,a.start_epoch.disabled=!1,a.stop_epoch.disabled=!1}};var r=0};

View File

@ -0,0 +1,16 @@
formatdate.js:187: WARNING - Suspicious code. This code lacks side-effects. Is there a bug?
h.length == 1? h = "0"+h:1;
^
formatdate.js:188: WARNING - Suspicious code. This code lacks side-effects. Is there a bug?
m.length == 1? m = "0"+m:1;
^
0 error(s), 2 warning(s)
Date.prototype.formatDate=function(h,f){function k(a){return void 0!=g[a]?g[a]():a}var l="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),m="Sun Mon Tue Wed Thu Fri Sat".split(" "),n="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),p="January February March April May June July August September October November December".split(" "),g={a:function(){return 11<b.getHours()?"pm":"am"},A:function(){return this.a().toUpperCase()},B:function(){var a=60*(b.getTimezoneOffset()+
60),a=3600*b.getHours()+60*b.getMinutes()+b.getSeconds()+a,a=Math.floor(a/86.4);1E3<a&&(a-=1E3);0>a&&(a+=1E3);1==String(a).length&&(a="00"+a);2==String(a).length&&(a="0"+a);return a},c:function(){return this.Y()+"-"+this.m()+"-"+this.d()+"T"+this.H()+":"+this.i()+":"+this.s()+this.P()},d:function(){var a=String(this.j());return 1==a.length?"0"+a:a},D:function(){return m[b.getDay()]},F:function(){return p[b.getMonth()]},g:function(){return 0==b.getHours()?12:12<b.getHours()?b.getHours()-12:b.getHours()},
G:function(){return b.getHours()},h:function(){var a=String(this.g());return 1==a.length?"0"+a:a},H:function(){var a=String(this.G());return 1==a.length?"0"+a:a},i:function(){var a=String(b.getMinutes());return 1==a.length?"0"+a:a},I:function(){return(new Date("January 1 "+this.Y()+" 00:00:00")).getTimezoneOffset()==b.getTimezoneOffset()?0:1},j:function(){return b.getDate()},l:function(){return l[b.getDay()]},L:function(){var a=this.Y();return 0==a%4&&0!=a%100||0==a%4&&0==a%100&&0==a%400?1:0},m:function(){var a=
String(this.n());return 1==a.length?"0"+a:a},M:function(){return n[b.getMonth()]},n:function(){return b.getMonth()+1},N:function(){var a=this.w();return 0==a?7:a},O:function(){var a=Math.abs(b.getTimezoneOffset()),e=String(Math.floor(a/60)),a=String(a%60);1==e.length?e="0"+e:1;1==a.length?a="0"+a:1;return 0>b.getTimezoneOffset()?"+"+e+a:"-"+e+a},P:function(){var a=this.O();return a.substr(0,3)+":"+a.substr(3,2)},r:function(){return this.D()+", "+this.d()+" "+this.M()+" "+this.Y()+" "+this.H()+":"+
this.i()+":"+this.s()+" "+this.O()},s:function(){var a=String(b.getSeconds());return 1==a.length?"0"+a:a},S:function(){switch(b.getDate()){case 1:return"st";case 2:return"nd";case 3:return"rd";case 21:return"st";case 22:return"nd";case 23:return"rd";case 31:return"st";default:return"th"}},t:function(){return 1==this.L()&&2==this.n()?29:[null,31,28,31,30,31,30,31,31,30,31,30,31][this.n()]},U:function(){return Math.round(b.getTime()/1E3)},w:function(){return b.getDay()},W:function(){var a=this.N(),
b=this.z(),c=364+this.L()-b;if(2>=c&&a<=3-c)return 1;if(2>=b&&5<=a)return(new Date(this.Y()-1,11,31)).formatDate("W");a=(new Date(this.Y(),0,1)).getDay();a=0!=a?a-1:6;return 3>=a?1+Math.floor((b+a)/7):1+Math.floor((b-(7-a))/7)},y:function(){var a=String(this.Y());return a.substring(a.length-2,a.length)},Y:function(){if(b.getFullYear){var a=(new Date("January 1 2001 00:00:00 +0000")).getFullYear();if(2001==a)return b.getFullYear()}a=b.getYear();a%=100;return a+(38>a?2E3:1900)},z:function(){var a="January 1 "+
this.Y()+" 00:00:00 GMT"+this.O(),a=new Date(a),a=b.getTime()-a.getTime();return Math.floor(a/1E3/60/60/24)},Z:function(){return-60*b.getTimezoneOffset()}},b;b=f?new Date(f):this;for(var c=h.split(""),d=0;d<c.length;)"%"==c[d]?c.splice(d,1):c[d]=k(c[d]),d++;return c.join("")};Date.DATE_ATOM="Y-m-d%TH:i:sP";Date.DATE_ISO8601="Y-m-d%TH:i:sO";Date.DATE_RFC2822="D, d M Y H:i:s O";Date.DATE_W3C="Y-m-d%TH:i:sP";

View File

@ -1,31 +1,31 @@
/*
* Sanitize all tab links
*/
$( "ul#tabs>li>a" ).each(function( index ) {
var eid = $( this ).attr('href').replace(/[^#\w]/gi,'_');
$( this ).attr('href', eid);
$("ul#tabs>li>a").each(function (index) {
var eid = $(this).attr('href').replace(/[^#\w]/gi, '_');
$(this).attr('href', eid);
});
/*
* Sanitize all tab ids
*/
$( "div#munin_nodeview_tab>div" ).each(function( index ) {
var eid = $( this ).attr('id').replace(/[^\w]/gi,'_');
$( this ).attr('id', eid);
$("div#munin_nodeview_tab>div").each(function (index) {
var eid = $(this).attr('id').replace(/[^\w]/gi, '_');
$(this).attr('id', eid);
});
/*
* Update the URL with selected tab and active selected tab on page refresh
*/
$(document).ready(function() {
if(location.hash) {
$(document).ready(function () {
if (location.hash) {
$('a[href="' + location.hash + '"]').tab('show');
}
$(document.body).on("click", "a[data-toggle=tab]", function(event) {
$(document.body).on("click", "a[data-toggle=tab]", function (event) {
location.hash = this.getAttribute("href");
});
});
$(window).on('popstate', function() {
$(window).on('popstate', function () {
var anchor = location.hash || $("a[data-toggle=tab]").first().attr("href");
$('a[href="' + anchor + '"]').tab('show');
});

View File

@ -0,0 +1,2 @@
$("ul#tabs>li>a").each(function(a){a=$(this).attr("href").replace(/[^#\w]/gi,"_");$(this).attr("href",a)});$("div#munin_nodeview_tab>div").each(function(a){a=$(this).attr("id").replace(/[^\w]/gi,"_");$(this).attr("id",a)});$(document).ready(function(){location.hash&&$('a[href="'+location.hash+'"]').tab("show");$(document.body).on("click","a[data-toggle=tab]",function(a){location.hash=this.getAttribute("href")})});
$(window).on("popstate",function(){var a=location.hash||$("a[data-toggle=tab]").first().attr("href");$('a[href="'+a+'"]').tab("show")});

View File

@ -0,0 +1 @@
function Querystring(a){this.params={};var b=window.location.search;null==a&&(a=b.substring(1,b.length));if(0!=a.length)for(a=a.replace(/\+/g," "),a=a.split("&"),b=0;b<a.length;b++){var c=a[b].split("="),d=decodeURIComponent(c[0]),c=2==c.length?decodeURIComponent(c[1]):d;this.params[d]=c}}Querystring.prototype.get=function(a,b){var c=this.params[a];return null!=c?c:b};Querystring.prototype.contains=function(a){return null!=this.params[a]};