Commit 2f7c4147 authored by robertDouglass's avatar robertDouglass
Browse files

simplifying stats output a bit

parent 7f8e7ca1
// $Id$
Drupal.memcacheHoverData = function() {
$('div.memcache_data').each(function() {
var fadeArea = $(this).find('pre'), staticOffsetY = null, staticOffsetX = null;
$(this).find('p').mouseover(hoverOver);
$(this).find('p').mousemove(hoverMove);
$(this).find('p').mouseout(hoverOut);
function hoverOver(e) {
staticOffsetX = -$(this)[0].offsetWidth;
staticOffsetY = -fadeArea[0].offsetHeight - $(this)[0].offsetHeight;
fadeArea.css('opacity', 1.00);
};
function hoverMove(e) {
fadeArea.css('left', Math.round(Drupal.mousePosition(e).x + staticOffsetX) + "px");
fadeArea.css('top', Math.round(Drupal.mousePosition(e).y + staticOffsetY) + "px");
};
function hoverOut(e) {
fadeArea.css('opacity', 0.00);
};
// Do this on initial load
fadeArea.css('opacity', 0.00);
});
};
if (Drupal.jsEnabled) {
$(document).ready(Drupal.memcacheHoverData);
}
......@@ -77,20 +77,20 @@ function memcache_admin_stats($cluster = NULL, $type = 'default') {
if (is_array($stats) && count($stats)) {
$output = "";
foreach ($stats as $server => $stats) {
if ($stats) {
$output .= theme('memcache_admin_stats_table', $server, $stats);
foreach ($stats as $server => $values) {
if (is_array($values)) {
$output .= theme('memcache_admin_stats_table', $server, $values);
}
else {
drupal_set_message(t('Unable to connect to server: %server', array('%server' => $server)), 'error');
drupal_set_message(t('Unable to connect to server: %server', array('%server' => $server)));
}
}
}
else {
$output = '';
drupal_set_message(t('There seem to be no stats for this bin...'), 'error');
drupal_set_message(t('There seem to be no stats for this bin...'));
}
}
......@@ -104,25 +104,18 @@ function theme_memcache_admin_stats_table($server, $stats) {
foreach ($stats as $key => $value) {
if (is_array($value)) {
drupal_add_css(drupal_get_path('module', 'memcache_admin') . '/style.css');
$id = 'memcache_'.$key;
$value = '<div class="memcache_data" id="'.$id.'">';
$value .= '<pre>' . serialize($value) . '</pre>';
$value .= '<p>Hover here for data</p>';
$value .= '</div>';
drupal_add_js(drupal_get_path('module', 'memcache_admin') . '/hover_script.js');
$rs = array();
foreach ($value as $k => $v) {
$rs[] = array($k, $v);
}
$rows[] = array($key, theme('table', array('',''), $rs));
}
else {
$rows[] = array($key, $value);
}
$row = array();
$row[] = array('data' => $key);
$row[] = array('data' => $value);
$rows[] = $row;
}
return theme('table', array('Property', 'Value'), $rows, array(), $server);
return theme('table', array(t('Property'), t('Value')), $rows, array(), $server);
}
......
/* $Id$ */
div.memcache_data pre {
position: absolute;
width: 400px;
padding: 4px;
background: #ccc;
border: 1px solid #333;
display:block;
}
div.memcache_data p {
margin: 0px;
padding: 10px;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment