<?php 
  
$speed = DB::GET_STRING("SELECT * FROM `PANEL_SPEED` LIMIT 1");
  
ECHO "<div class='panel-desktop-vidget'>";

ECHO "<div class='panel-desktop-vidget-title green-dvt'>";
ECHO LG('Скорость загрузки сайта');
ECHO "</div>";

IF (DB::GET_COLUMN("SELECT COUNT(*) FROM `PANEL_SPEED` WHERE `TIME` > '".TIME()."' LIMIT 1") == 0){
  
  $speed_site2 = "".SCHEME."".HTTP_HOST."";
  $speed_site = SPEED_SITE($speed_site2);
  $speed_balls = SPEED_BALLS($speed_site);

  $interval = TIME() + $speed['INTERVAL'];
  DB::GET_SET("UPDATE `PANEL_SPEED` SET `TIME` = '".$interval."', `TIME_UPDATE` = '".TIME()."', `SPEED_BALLS` = '".$speed_balls."', `SPEED` = '".$speed_site."'");
  REDIRECT('?');
  
}

ECHO "<div class='panel-desktop-vidget-content'>";

ECHO "<div class='panel-desktop-info'>";

ECHO "<center><font size='+2'>".$speed['SPEED_BALLS']." ".LG(SPEED_BALLS_OPTIMIZE($speed['SPEED_BALLS']))." - ".$speed['SPEED']." ".LG('сек').".</font></center>";

?>  
  
<center><canvas width="320" height="120" id="speed"></canvas></center> 
  
<script type="text/javascript">
  
var opts = {
  
  angle: 0,
  lineWidth: 0.2,
  radiusScale: 1,
  
  pointer: {
    
    length: 0.50,
    strokeWidth: 0.050,
    color: '#242729'
    
  },
  
  limitMax: false,
  limitMin: false,
  colorStart: '#6FADCF',
  colorStop: '#8FC0DA',
  strokeColor: '#E0E0E0',
  generateGradient: true,
  highDpiSupport: true,
  
  renderTicks: {
    
    divisions: 2,
    divWidth: 1.5,
    divLength: 0.29,
    divColor: '#282D30',
    subDivisions: 3,
    subLength: 0.5,
    subWidth: 0.5,
    subColor: '#282D30'
    
  },
  
  staticLabels: {
    
    font: "10px sans-serif",
    labels: [0, 500, 1000, 1500, 2000, 2500, 3000],
    fractionDigits: 0,
    color: '#DDE5E9',
    subWidth: 0.9,
    
  },
  
  staticZones: [
    
    {strokeStyle: "#FF3300", min: 0, max: 500},
    {strokeStyle: "#FF9900", min: 500, max: 1000},
    {strokeStyle: "#FFEB00", min: 1000, max: 1500},
    {strokeStyle: "#B3FA34", min: 1500, max: 2000},
    {strokeStyle: "#25F13E", min: 2000, max: 2500},
    {strokeStyle: "#00AA1B", min: 2500, max: 3000},
  
  ]
  
};  

var target = document.getElementById('speed');
var gauge = new Gauge(target).setOptions(opts);

gauge.maxValue = 3000;
gauge.setMinValue(0);
gauge.animationSpeed = 30;
gauge.set(<?=$speed['SPEED_BALLS']?>);

</script> 
  
<? 
  
ECHO "<center><font size='+2'>".SPEED_BALLS_COMMENT($speed['SPEED_BALLS'])."</font><br />";

ECHO "<small>".LG('Посл. обновление').": ".FTIME($speed['TIME_UPDATE'])."</small></center><br />";

ECHO "<a class='panel-button' href='?path=system&section=speed_set'>";
ECHO "".ICONS('gear', 15, 'fa-fw')."</a> ";

ECHO "<a class='panel-button' href='?'>";
ECHO "".ICONS('refresh', 15, 'fa-fw')."</a>";

ECHO "<a class='panel-button' href='?path=system&section=speed' style='float: right;'>";
ECHO "".ICONS('tachometer', 15, 'fa-fw')." ".LG('Измерить сайт')."</a>";

ECHO "</div>";

ECHO "</div>";

ECHO "</div>";

?>