diff --git a/templates/munstrap/static/js/dynazoom.js b/templates/munstrap/static/js/dynazoom.js index 53ed91fa..aa662261 100644 --- a/templates/munstrap/static/js/dynazoom.js +++ b/templates/munstrap/static/js/dynazoom.js @@ -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 X1X2 ou X1a&&(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:12b.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;dli>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'); }); \ No newline at end of file diff --git a/templates/munstrap/static/js/munstrap.min.js b/templates/munstrap/static/js/munstrap.min.js new file mode 100644 index 00000000..142b24ff --- /dev/null +++ b/templates/munstrap/static/js/munstrap.min.js @@ -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")}); diff --git a/templates/munstrap/static/js/querystring.min.js b/templates/munstrap/static/js/querystring.min.js new file mode 100644 index 00000000..e914a94b --- /dev/null +++ b/templates/munstrap/static/js/querystring.min.js @@ -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