Вход Регистрация
Файл: wmon_dist/media/js/domready.js
Строк: 166
<?php
Date
.prototype.monthNames = [
    
"January""February""March",
    
"April""May""June",
    
"July""August""September",
    
"October""November""December"
];

Date.prototype.getMonthName = function() {
    return 
this.monthNames[this.getMonth()];
};
Date.prototype.getShortMonthName = function () {
    return 
this.getMonthName().substr(03);
};

Dygraph.prototype.parseFloat_ = function(xopt_line_noopt_line) {
  var 
val parseFloat(x);
  if (!
isNaN(val)) return val;
  return 
x;
};

window.addEvent('domready',function(){

    var 
hosts JSON.decode(Cookie.read('showhosts')) || [];

    $$(
'div.hostname').addEvent('click',function(){
        
this.getParent('div.navbar').getNext('div.container-fluid').toggleClass('hide');
    
        if(
hosts.indexOf(this.get('rel'))!=-1hosts.erase(this.get('rel'));
        else 
hosts.push(this.get('rel'));
    
        
Cookie.write('showhosts'JSON.encode(hosts));
    });

    $$(
'div.host[rel]').each(function(host){
        var 
= new Dygraph(
            
host.getElement('div.chart'),
            
host.get('data-csv'),
            {
                
labels: ['time','01min','05min','15min','status','top','space'],
                
visibility: [true,true,true,false,false,false],
                
labelsKMBtrue,
                
legend'always',
                
colors: ["rgb(51,204,204)","rgb(255,100,100)","#00DD55"],
                
width'100%',
                
height200,
                
ylabel'Load',
                
yLabelWidth:12,
                
yAxisLabelWidth20,
                
valueRange: [0,5],
                
labelsDivWidth180,
                
labelsDivStyles: {'backgroundColor''transparent'},
                
labelsSeparateLinestrue,
                
labelsShowZeroValues:false,
                
xValueParser: function(x) { return 1000*(+x); }, 
                
axes: {
                    
x: {
                        
tickerDygraph.dateTicker,
                        
valueFormatterDygraph.dateString_
                        
axisLabelFormatter: function(d) {
                            var 
curr_date d.getDate();
                            var 
curr_month d.getShortMonthName(); 
                            var 
curr_year d.getFullYear();
                            var 
curr_hour = (d.getHours()<10 '0':'') + d.getHours();
                            var 
curr_min = (d.getMinutes()<10 '0':'') + d.getMinutes();
                            return 
curr_hour+':'+curr_min+"n"+curr_date "." curr_month;
                        }
                    },
                },
                
highlightCallback: function(eventxpoints,row) {
                    var 
data g.getValue(row,5)
                    if(
datadata data.replace(/["']/g,'');
                    else return;
                    host.getElement('div.top table.current').addClass('hide')
                    host.getElement('div.top table.highlight').removeClass('hide')
                    var tbody = '';
                    data.split('|').each(function(row){
                        var tr = '<tr>';
                        row.split('+').each(function(d){
                            tr+= '<td>'+d+'</td>';
                        });
                        tr+= '</tr>';
                        tbody+=tr;
                    });
                    host.getElement('div.top table.highlight tbody').set('html',tbody);
                    host.getElement('div.top table.highlight').setStyle('background','#FFFFCC')
                },
                unhighlightCallback: function(e, point) {
                    host.getElement('div.top table.current').removeClass('hide');
                    host.getElement('div.top table.highlight').addClass('hide')
                        .setStyle('background','');
                },
                drawCallback :function(dygraph, is_initial){
                    if(is_initial){
                        var status = null;
                        var annotations = [];
                        dygraph.rawData_.each(function(el){
                            var s = el[4].replace(/'/g,'').toInt();
                            if(isNaN(s) || status==null) {
                                status = s;
                                return;
                            }
                            if(status != s){
                                annotations.push( {
                                    series: '05min',
                                    x: el[0]/1000,
                                    text:'services status changed',
                                    status: s,
                                    width:16,
                                    height:16,
                                    tickHeight:20,
                                    icon:'media/images/warning.png',
                                    mouseOverHandler: function(annotation, point, dygraph, event) {
                                        if(annotation.status!=undefined){
                                            var x = 1;
                                            host.getElement('div.services table').setStyle('background','#FFFFCC')
                                            host.getElements('div.services table tr td:last-child span').each(function(chk){
                                                chk.store('current',chk.className+'|'+chk.get('text'));
                                                if(annotation.status & x) chk.removeClass('label-success').addClass('label-important blink').set('text','down');
                                                else chk.removeClass('label-important blink').addClass('label-success').set('text','up');
                                                x=x*2;
                                            });
                                        }
                                        
                                    },
                                    mouseOutHandler: function(annotation, point, dygraph, event) {
                                        host.getElement('div.services table').setStyle('background','')
                                        host.getElements('div.services table tr td:last-child span').each(function(chk){
                                            var cur = chk.retrieve('current').split('|');
                                            chk.className = cur[0];
                                            chk.set('text',cur[1]);
                                        });
                                    }
                                } );
                            }
                            status = s;
                        });
                        g.setAnnotations(annotations);
                    }
                }
            }    
        );
    });

    hosts.each(function(el){
        if($$('div.hostname[rel='+el+']')) {
            $$('div.hostname[rel='+el+']').getParent('div.navbar')
                .getNext('div.container-fluid')
                .addClass('hide');
        }
    });

});
?>
Онлайн: 3
Реклама