handle BSD and UNIX, just in case

This commit is contained in:
rolux 2012-03-27 09:41:03 +00:00
parent 8a1fd4afda
commit e2fc9c35f9
2 changed files with 105 additions and 105 deletions

View file

@ -7,9 +7,11 @@ pandora.ui.statisticsDialog = function() {
var colors = { var colors = {
system: { system: {
'Android': [0, 255, 0], 'Android': [0, 255, 0],
'BSD': [255, 0, 0],
'iOS': [0, 128, 255], 'iOS': [0, 128, 255],
'Linux': [255, 128, 0], 'Linux': [255, 128, 0],
'Mac OS X': [0, 255, 255], 'Mac OS X': [0, 255, 255],
'UNIX': [255, 255, 0],
'Windows': [0, 0, 255] 'Windows': [0, 0, 255]
}, },
browser: { browser: {
@ -23,15 +25,7 @@ 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 = { names = Ox.merge(Object.keys(colors.system), Object.keys(colors.browser)),
system: [
'Android', 'iOS', 'Linux', 'Mac OS X', 'Windows'
],
browser: [
'Chrome Frame', 'Chrome', 'Firefox',
'Internet Explorer', 'Opera', 'Safari'
]
},
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'},
@ -167,25 +161,19 @@ pandora.ui.statisticsDialog = function() {
['system', 'browser'].forEach(function(key) { ['system', 'browser'].forEach(function(key) {
var version = item[key]; var version = item[key];
if (version) { if (version) {
name[key] = ''; name[key] = getName(version);
Ox.forEach(names[key], function(v) {
if (new RegExp('^' + v).test(version)) {
name[key] = v;
return false;
}
});
if (name[key]) { if (name[key]) {
data[mode][key][name[key]] = (data[mode][key][name[key]] || 0) + 1; data[mode][key][name[key]] = (data[mode][key][name[key]] || 0) + 1;
key = key + 'version'; key = key + 'version';
data[mode][key][version] = (data[mode][key][version] || 0) + 1; data[mode][key][version] = (data[mode][key][version] || 0) + 1;
}/* else { }
Ox.print("^^^^^^", version)
}*/
} }
}); });
if (name.system && name.browser) { if (name.system && name.browser) {
name = name.system + ' / ' + name.browser; name = name.system + ' / ' + name.browser;
data[mode].systemandbrowser[name] = (data[mode].systemandbrowser[name] || 0) + 1; data[mode].systemandbrowser[name] = (data[mode].systemandbrowser[name] || 0) + 1;
name = item.system + ' / ' + item.browser;
data[mode].systemandbrowserversion[name] = (data[mode].systemandbrowserversion[name] || 0) + 1;
} }
} }
}); });
@ -415,16 +403,8 @@ 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 color, name = value; var name = version ? getName(value) : value,
if (version) { color = colors[key][name];
Ox.forEach(names[key], function(v) {
if (new RegExp('^' + v).test(value)) {
name = v;
return false;
}
});
}
color = colors[key][name];
if (pandora.user.ui.theme == 'classic') { if (pandora.user.ui.theme == 'classic') {
color = color.map(function(c) { color = color.map(function(c) {
return c - 64; return c - 64;
@ -434,24 +414,8 @@ pandora.ui.statisticsDialog = function() {
}, },
data: data[mode][key + version], data: data[mode][key + version],
formatKey: function(value) { formatKey: function(value) {
var index, var name = version ? getName(value) : value,
name = value,
$element = $('<div>'); $element = $('<div>');
if (version) {
Ox.forEach(names[key], function(v) {
if (new RegExp('^' + v).test(value)) {
name = v;
return false;
}
});
/*
text = value.substr(name.length + 1);
index = text.indexOf('(')
if (index > -1) {
text = Ox.sub(text, index + 1, -1);
}
*/
}
$element.append( $element.append(
$('<div>') $('<div>')
.css({ .css({
@ -463,7 +427,13 @@ pandora.ui.statisticsDialog = function() {
overflow: 'hidden', overflow: 'hidden',
textOverflow: 'ellipsis' textOverflow: 'ellipsis'
}) })
.html(value.replace('(Windows ', '(')) .html(
value
.replace(/BSD \((.+)\)/, '$1')
.replace(/Linux \((.+)\)/, '$1')
.replace(/UNIX \((.+)\)/, '$1')
.replace(/Windows (NT \d+\.\d+) \((.+)\)/, 'Windows $2 ($1)')
)
).append( ).append(
$('<img>') $('<img>')
.attr({ .attr({
@ -496,67 +466,82 @@ pandora.ui.statisticsDialog = function() {
.appendTo($content); .appendTo($content);
top += Ox.len(data[mode][key + version]) * 16 + 32; top += Ox.len(data[mode][key + version]) * 16 + 32;
}); });
if (i == 0) { 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;
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);
}); });
if (pandora.user.ui.theme == 'classic') { if (pandora.user.ui.theme == 'classic') {
color = color.map(function(c) { color = color.map(function(c) {
return c - 64; return c - 64;
});
}
return color;
},
data: data[mode].systemandbrowser,
formatKey: function(value) {
var $element = $('<div>')
.append(
$('<div>')
.css({
float: 'left',
width: '152px',
height: '14px',
marginLeft: '-4px',
marginRight: '4px',
overflow: 'hidden',
textOverflow: 'ellipsis'
})
.html(value)
);
value.split(' / ').forEach(function(value, i) {
$element.append(
$('<img>')
.attr({
src: Ox.UI.PATH + 'png/'
+ (i == 0 ? 'system' : 'browser')
+ value.replace(/ /g, '') + '128.png'
})
.css({
width: '14px',
height: '14px',
margin: '0 1px 0 1px'
})
);
}); });
return $element; }
}, return color;
keyWidth: 192, },
sort: {key: 'value', operator: '-'}, data: data[mode]['systemandbrowser' + version],
title: 'Operating Systems & Browsers', formatKey: function(value) {
width: chartWidth var $element = $('<div>')
}) .append(
.css({ $('<div>')
position: 'absolute', .css({
left: '16px', float: 'left',
top: top + 'px' width: '152px',
}) height: '14px',
.appendTo($content); marginLeft: '-4px',
top += Ox.len(data[mode].systemandbrowser) * 16 + 32; marginRight: '4px',
} overflow: 'hidden',
textOverflow: 'ellipsis'
})
.html(
version
? value
.replace(/BSD \((.+)\)/, '$1')
.replace(/Linux \((.+)\)/, '$1')
.replace(/(Mac OS X \d+\.\d+) \(.+\)/, '$1')
.replace(/UNIX \((.+)\)/, '$1')
.replace(/Windows NT \d+\.\d+ \((.+)\)/, 'Windows $1')
.replace(/Chrome Frame/, 'CF')
.replace(/Internet Explorer/, 'IE')
: value
)
);
value.split(' / ').forEach(function(value, i) {
value = version ? getName(value) : value;
$element.append(
$('<img>')
.attr({
src: Ox.UI.PATH + 'png/'
+ (i == 0 ? 'system' : 'browser')
+ value.replace(/ /g, '') + '128.png'
})
.css({
width: '14px',
height: '14px',
margin: '0 1px 0 1px'
})
);
});
return $element;
},
keyWidth: 192,
sort: version == ''
? {key: 'value', operator: '-'}
: {key: 'key', operator: '+'},
title: version == ''
? 'Operating Systems & Browsers'
: 'Operating System & Browser Versions',
width: chartWidth
})
.css({
position: 'absolute',
left: '16px',
top: top + 'px'
})
.appendTo($content);
top += Ox.len(data[mode]['systemandbrowser' + version]) * 16 + 32;
}); });
} }
$('<div>') $('<div>')
@ -579,6 +564,17 @@ pandora.ui.statisticsDialog = function() {
}); });
function getName(version) {
var name = '';
Ox.forEach(names, function(v) {
if (new RegExp('^' + v).test(version)) {
name = v;
return false;
}
});
return name;
}
return $dialog; return $dialog;
}; };

View file

@ -13,7 +13,8 @@ pandora.ui.usersDialog = function() {
formWidth = 256, formWidth = 256,
numberOfUsers = 0, numberOfUsers = 0,
systems = [ systems = [
'Android', 'iOS', 'Linux', 'Mac OS X', 'Windows' 'Android', 'BSD', 'iOS', 'Linux',
'Mac OS X', 'UNIX', 'Windows'
], ],
userLevels = Ox.merge( userLevels = Ox.merge(
pandora.site.userLevels.map(function(userLevel) { pandora.site.userLevels.map(function(userLevel) {
@ -355,6 +356,7 @@ pandora.ui.usersDialog = function() {
}) })
.bindEvent({ .bindEvent({
init: function(data) { init: function(data) {
Ox.print('DATA::P::', data)
numberOfUsers = data.users; numberOfUsers = data.users;
$status.html( $status.html(
Ox.formatNumber(data.items) Ox.formatNumber(data.items)
@ -363,7 +365,9 @@ pandora.ui.usersDialog = function() {
$guestsCheckbox.value() $guestsCheckbox.value()
? ' (' + Ox.formatNumber(data.users) + ' registered, ' ? ' (' + Ox.formatNumber(data.users) + ' registered, '
+ Ox.formatNumber(data.guests) + ' guest' + Ox.formatNumber(data.guests) + ' guest'
+ (data.guests == 1 ? '' : 's') + (data.guests == 1 ? '' : 's') + ', '
+ Ox.formatNumber(data.robots) + ' robot'
+ (data.robots == 1 ? '' : 's')
+ ')' + ')'
: '' : ''
) )