diff --git a/static/js/pandora/statisticsDialog.js b/static/js/pandora/statisticsDialog.js index 3ea24860..fb9e5115 100644 --- a/static/js/pandora/statisticsDialog.js +++ b/static/js/pandora/statisticsDialog.js @@ -7,9 +7,11 @@ pandora.ui.statisticsDialog = function() { var colors = { system: { 'Android': [0, 255, 0], + 'BSD': [255, 0, 0], 'iOS': [0, 128, 255], 'Linux': [255, 128, 0], 'Mac OS X': [0, 255, 255], + 'UNIX': [255, 255, 0], 'Windows': [0, 0, 255] }, browser: { @@ -23,15 +25,7 @@ pandora.ui.statisticsDialog = function() { }, dialogHeight = Math.round((window.innerHeight - 48) * 0.9), dialogWidth = Math.round(window.innerWidth * 0.9), - names = { - system: [ - 'Android', 'iOS', 'Linux', 'Mac OS X', 'Windows' - ], - browser: [ - 'Chrome Frame', 'Chrome', 'Firefox', - 'Internet Explorer', 'Opera', 'Safari' - ] - }, + names = Ox.merge(Object.keys(colors.system), Object.keys(colors.browser)), tabs = [ {id: 'seen', title: 'First Seen & Last Seen', selected: true}, {id: 'locations', title: 'Locations'}, @@ -167,25 +161,19 @@ pandora.ui.statisticsDialog = function() { ['system', 'browser'].forEach(function(key) { var version = item[key]; if (version) { - name[key] = ''; - Ox.forEach(names[key], function(v) { - if (new RegExp('^' + v).test(version)) { - name[key] = v; - return false; - } - }); + name[key] = getName(version); if (name[key]) { data[mode][key][name[key]] = (data[mode][key][name[key]] || 0) + 1; key = key + 'version'; data[mode][key][version] = (data[mode][key][version] || 0) + 1; - }/* else { - Ox.print("^^^^^^", version) - }*/ + } } }); if (name.system && name.browser) { name = name.system + ' / ' + name.browser; 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) { Ox.Chart({ color: function(value) { - var color, name = value; - if (version) { - Ox.forEach(names[key], function(v) { - if (new RegExp('^' + v).test(value)) { - name = v; - return false; - } - }); - } - color = colors[key][name]; + var name = version ? getName(value) : value, + color = colors[key][name]; if (pandora.user.ui.theme == 'classic') { color = color.map(function(c) { return c - 64; @@ -434,24 +414,8 @@ pandora.ui.statisticsDialog = function() { }, data: data[mode][key + version], formatKey: function(value) { - var index, - name = value, + var name = version ? getName(value) : value, $element = $('
'); - 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( $('
') .css({ @@ -463,7 +427,13 @@ pandora.ui.statisticsDialog = function() { overflow: 'hidden', 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( $('') .attr({ @@ -496,67 +466,82 @@ pandora.ui.statisticsDialog = function() { .appendTo($content); top += Ox.len(data[mode][key + version]) * 16 + 32; }); - if (i == 0) { - Ox.Chart({ - color: function(value) { - var color = Ox.zip(value.split(' / ').map(function(v, i) { + Ox.Chart({ + color: function(value) { + var color = Ox.zip(value.split(' / ').map(function(v, i) { + v = version ? getName(v) : v; return colors[i == 0 ? 'system' : 'browser'][v]; })).map(function(c) { return Math.round(Ox.sum(c) / 2); }); - if (pandora.user.ui.theme == 'classic') { - color = color.map(function(c) { - return c - 64; - }); - } - return color; - }, - data: data[mode].systemandbrowser, - formatKey: function(value) { - var $element = $('
') - .append( - $('
') - .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( - $('') - .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' - }) - ); + if (pandora.user.ui.theme == 'classic') { + color = color.map(function(c) { + return c - 64; }); - return $element; - }, - keyWidth: 192, - sort: {key: 'value', operator: '-'}, - title: 'Operating Systems & Browsers', - width: chartWidth - }) - .css({ - position: 'absolute', - left: '16px', - top: top + 'px' - }) - .appendTo($content); - top += Ox.len(data[mode].systemandbrowser) * 16 + 32; - } + } + return color; + }, + data: data[mode]['systemandbrowser' + version], + formatKey: function(value) { + var $element = $('
') + .append( + $('
') + .css({ + float: 'left', + width: '152px', + height: '14px', + marginLeft: '-4px', + 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( + $('') + .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; }); } $('
') @@ -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; }; \ No newline at end of file diff --git a/static/js/pandora/usersDialog.js b/static/js/pandora/usersDialog.js index 4b40be6a..ad86e84e 100644 --- a/static/js/pandora/usersDialog.js +++ b/static/js/pandora/usersDialog.js @@ -13,7 +13,8 @@ pandora.ui.usersDialog = function() { formWidth = 256, numberOfUsers = 0, systems = [ - 'Android', 'iOS', 'Linux', 'Mac OS X', 'Windows' + 'Android', 'BSD', 'iOS', 'Linux', + 'Mac OS X', 'UNIX', 'Windows' ], userLevels = Ox.merge( pandora.site.userLevels.map(function(userLevel) { @@ -355,6 +356,7 @@ pandora.ui.usersDialog = function() { }) .bindEvent({ init: function(data) { + Ox.print('DATA::P::', data) numberOfUsers = data.users; $status.html( Ox.formatNumber(data.items) @@ -363,7 +365,9 @@ pandora.ui.usersDialog = function() { $guestsCheckbox.value() ? ' (' + Ox.formatNumber(data.users) + ' registered, ' + Ox.formatNumber(data.guests) + ' guest' - + (data.guests == 1 ? '' : 's') + + (data.guests == 1 ? '' : 's') + ', ' + + Ox.formatNumber(data.robots) + ' robot' + + (data.robots == 1 ? '' : 's') + ')' : '' )