fix a bug in statistics dialog

This commit is contained in:
rolux 2012-10-27 19:28:47 +02:00
parent ef20c39bd9
commit 31533bcb62

View file

@ -34,7 +34,6 @@ pandora.ui.statisticsDialog = function() {
}, },
dialogHeight = Math.round((window.innerHeight - 48) * 0.9), dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
dialogWidth = Math.round(window.innerWidth * 0.9), dialogWidth = Math.round(window.innerWidth * 0.9),
names = Object.keys(colors.system).concat(Object.keys(colors.browser)),
tabs = [ tabs = [
{id: 'seen', title: 'First Seen & Last Seen', selected: true}, {id: 'seen', title: 'First Seen & Last Seen', selected: true},
{id: 'locations', title: 'Locations'}, {id: 'locations', title: 'Locations'},
@ -446,7 +445,7 @@ pandora.ui.statisticsDialog = function() {
['system', 'browser'].forEach(function(key) { ['system', 'browser'].forEach(function(key) {
Ox.Chart({ Ox.Chart({
color: function(value) { color: function(value) {
var name = version ? getName(value) : value, var name = version ? getName(key, value) : value,
color = colors[key][name]; color = colors[key][name];
if (pandora.user.ui.theme == 'classic') { if (pandora.user.ui.theme == 'classic') {
color = getColor(color); color = getColor(color);
@ -455,7 +454,7 @@ pandora.ui.statisticsDialog = function() {
}, },
data: data[mode][key + version], data: data[mode][key + version],
formatKey: function(value) { formatKey: function(value) {
var name = version ? getName(value) : value, var name = version ? getName(key, value) : value,
$element = $('<div>'); $element = $('<div>');
$element.append( $element.append(
$('<div>') $('<div>')
@ -510,7 +509,7 @@ pandora.ui.statisticsDialog = function() {
Ox.Chart({ Ox.Chart({
color: function(value) { color: function(value) {
var color = Ox.zip(value.split(' / ').map(function(v, i) { var color = Ox.zip(value.split(' / ').map(function(v, i) {
v = version ? getName(v) : v; v = version ? getName(key, v) : v;
return colors[i == 0 ? 'system' : 'browser'][v]; return colors[i == 0 ? 'system' : 'browser'][v];
})).map(function(c) { })).map(function(c) {
return Math.round(Ox.sum(c) / 2); return Math.round(Ox.sum(c) / 2);
@ -548,7 +547,7 @@ pandora.ui.statisticsDialog = function() {
) )
); );
value.split(' / ').forEach(function(value, i) { value.split(' / ').forEach(function(value, i) {
value = version ? getName(value) : value; value = version ? getName(key, value) : value;
$element.append( $element.append(
$('<img>') $('<img>')
.attr({ .attr({
@ -609,9 +608,9 @@ pandora.ui.statisticsDialog = function() {
return Ox.rgb(hsl); return Ox.rgb(hsl);
} }
function getName(version) { function getName(key, version) {
var name = ''; var name = '';
Ox.forEach(names, function(v) { Ox.forEach(Object.keys(colors[key]), function(v) {
if (new RegExp('^' + v).test(version)) { if (new RegExp('^' + v).test(version)) {
name = v; name = v;
return false; return false;