2012-03-22 20:08:51 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
pandora.ui.statisticsDialog = function() {
|
|
|
|
|
|
|
|
var colors = {
|
2012-03-26 19:27:20 +00:00
|
|
|
system: {
|
|
|
|
'Android': [0, 255, 0],
|
2012-10-27 16:57:28 +00:00
|
|
|
'BlackBerry': [64, 64, 64],
|
2012-03-27 09:41:03 +00:00
|
|
|
'BSD': [255, 0, 0],
|
2012-03-26 19:27:20 +00:00
|
|
|
'iOS': [0, 128, 255],
|
2012-10-27 16:57:28 +00:00
|
|
|
'Java': [128, 128, 128],
|
2012-03-26 19:27:20 +00:00
|
|
|
'Linux': [255, 128, 0],
|
|
|
|
'Mac OS X': [0, 255, 255],
|
2012-10-27 16:57:28 +00:00
|
|
|
'Nokia': [255, 0, 255],
|
|
|
|
'PlayStation': [192, 192, 192],
|
2013-07-29 16:23:22 +00:00
|
|
|
'RIM Tablet OS': [64, 64, 64],
|
2012-03-27 10:03:30 +00:00
|
|
|
'Unix': [255, 255, 0],
|
2013-07-29 16:23:22 +00:00
|
|
|
'Wii': [192, 192, 192],
|
2013-07-30 17:03:27 +00:00
|
|
|
'Windows Phone': [0, 0, 128], // has to be before 'Windows'
|
|
|
|
'Windows': [0, 0, 255]
|
2012-03-26 19:27:20 +00:00
|
|
|
},
|
|
|
|
browser: {
|
2012-10-27 16:57:28 +00:00
|
|
|
'Camino': [192, 192, 192],
|
2012-10-27 19:53:28 +00:00
|
|
|
'Chrome Frame': [255, 255, 0], // has to be before 'Chrome'
|
2012-10-27 19:52:37 +00:00
|
|
|
'Chrome': [0, 255, 0],
|
2012-10-27 19:35:20 +00:00
|
|
|
'Chromium': [128, 255, 0],
|
2012-10-27 16:57:28 +00:00
|
|
|
'Epiphany': [128, 128, 128],
|
2012-03-27 10:24:16 +00:00
|
|
|
'Firefox': [255, 128, 0],
|
2012-03-26 19:27:20 +00:00
|
|
|
'Internet Explorer': [0, 0, 255],
|
2012-10-27 16:57:28 +00:00
|
|
|
'Konqueror': [64, 64, 64],
|
|
|
|
'Nokia Browser': [255, 0, 255],
|
2012-03-26 19:27:20 +00:00
|
|
|
'Opera': [255, 0, 0],
|
2012-03-27 10:24:16 +00:00
|
|
|
'Safari': [0, 255, 255],
|
|
|
|
'WebKit': [0, 255, 128]
|
2012-03-26 19:27:20 +00:00
|
|
|
}
|
2012-03-22 20:08:51 +00:00
|
|
|
},
|
|
|
|
dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
|
|
|
|
dialogWidth = Math.round(window.innerWidth * 0.9),
|
|
|
|
tabs = [
|
2013-05-09 10:13:58 +00:00
|
|
|
{id: 'seen', title: Ox._('First Seen & Last Seen'), selected: true},
|
|
|
|
{id: 'locations', title: Ox._('Locations')},
|
|
|
|
{id: 'platforms', title: Ox._('Platforms & Browsers')}
|
2012-03-22 20:08:51 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
$dialog = Ox.Dialog({
|
|
|
|
buttons: [
|
2012-03-23 08:55:22 +00:00
|
|
|
Ox.Button({
|
|
|
|
id: 'manageUsers',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Manage Users...')
|
2012-03-23 08:55:22 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
2012-03-23 09:02:55 +00:00
|
|
|
$dialog.close();
|
|
|
|
pandora.$ui.usersDialog = pandora.ui.usersDialog().open();
|
2012-03-23 08:55:22 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
{},
|
2012-03-22 20:08:51 +00:00
|
|
|
Ox.Button({
|
|
|
|
id: 'close',
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Close')
|
2012-03-22 20:08:51 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
$dialog.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
closeButton: true,
|
2013-11-20 08:12:59 +00:00
|
|
|
content: Ox.LoadingScreen().start(),
|
2012-03-22 20:08:51 +00:00
|
|
|
height: dialogHeight,
|
2012-03-22 20:30:31 +00:00
|
|
|
maximizeButton: true,
|
2012-03-22 20:08:51 +00:00
|
|
|
minHeight: 256,
|
|
|
|
minWidth: 512,
|
|
|
|
removeOnClose: true,
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Statistics'),
|
2012-03-22 20:08:51 +00:00
|
|
|
width: dialogWidth
|
2012-03-23 09:22:03 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resizeend: function(data) {
|
|
|
|
dialogWidth = data.width;
|
|
|
|
$tabPanel.$element.replaceElement(1,
|
|
|
|
$tabPanel.options('content')($tabPanel.selected())
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$tabPanel;
|
2012-03-22 20:08:51 +00:00
|
|
|
|
2014-01-19 06:44:19 +00:00
|
|
|
pandora.api.statistics(function(result) {
|
|
|
|
|
2013-10-22 15:58:47 +00:00
|
|
|
var data = result.data,
|
2012-03-22 20:08:51 +00:00
|
|
|
flagCountry = {},
|
2012-03-23 09:22:03 +00:00
|
|
|
$guestsCheckbox;
|
2012-03-22 20:08:51 +00:00
|
|
|
|
|
|
|
['all', 'registered'].forEach(function(mode) {
|
|
|
|
|
|
|
|
var keys, firstKey, lastKey;
|
|
|
|
keys = Object.keys(data[mode].month).map(function(key) {
|
2012-05-24 09:56:52 +00:00
|
|
|
return key.slice(0, 7);
|
2012-03-22 20:08:51 +00:00
|
|
|
}).sort();
|
|
|
|
firstKey = keys[0].split('-').map(function(str) {
|
|
|
|
return parseInt(str, 10);
|
|
|
|
});
|
2012-10-06 13:34:30 +00:00
|
|
|
lastKey = Ox.formatDate(new Date(), '%F').split('-').map(function(str) {
|
2012-03-22 20:08:51 +00:00
|
|
|
return parseInt(str, 10);
|
|
|
|
});
|
|
|
|
Ox.loop(firstKey[0], lastKey[0] + 1, function(year) {
|
|
|
|
['firstseen', 'lastseen'].forEach(function(key) {
|
|
|
|
var key = [year, key].join('-');
|
2013-01-01 12:40:16 +00:00
|
|
|
data[mode].year[key] = data[mode].year[key] || {};
|
2012-03-22 20:08:51 +00:00
|
|
|
});
|
|
|
|
Ox.loop(
|
|
|
|
year == firstKey[0] ? firstKey[1] : 1,
|
|
|
|
year == lastKey[0] ? lastKey[1] + 1 : 13,
|
|
|
|
function(month) {
|
|
|
|
['firstseen', 'lastseen'].forEach(function(key) {
|
|
|
|
var key = [year, Ox.pad(month, 2), key].join('-');
|
|
|
|
data[mode].month[key] = data[mode].month[key] || 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2012-10-06 13:34:30 +00:00
|
|
|
keys = Object.keys(data[mode].day).sort();
|
|
|
|
firstKey = keys[0].split('-').map(function(str) {
|
|
|
|
return parseInt(str, 10);
|
|
|
|
});
|
|
|
|
Ox.loop(firstKey[0], lastKey[0] + 1, function(year) {
|
|
|
|
Ox.loop(
|
|
|
|
year == firstKey[0] ? firstKey[1] : 1,
|
|
|
|
year == lastKey[0] ? lastKey[1] + 1 : 13,
|
|
|
|
function(month) {
|
|
|
|
Ox.loop(
|
|
|
|
year == firstKey[0] && month == firstKey[1] ? firstKey[2] : 1,
|
|
|
|
year == lastKey[0] && month == lastKey[1] ? lastKey[2] + 1
|
|
|
|
: Ox.getDaysInMonth(year, month) + 1,
|
|
|
|
function(day) {
|
|
|
|
var key = [year, Ox.pad(month, 2), Ox.pad(day, 2)].join('-');
|
|
|
|
data[mode].day[key] = data[mode].day[key] || {};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2012-03-22 20:08:51 +00:00
|
|
|
flagCountry[mode] = {};
|
|
|
|
['continent', 'region'].forEach(function(key) {
|
|
|
|
flagCountry[mode][key] = {};
|
|
|
|
Ox.forEach(data[mode][key], function(regionValue, regionKey) {
|
2012-03-25 21:12:13 +00:00
|
|
|
regionKey = regionKey.split(', ').pop();
|
2012-03-22 20:08:51 +00:00
|
|
|
var max = 0;
|
|
|
|
Ox.forEach(data[mode].country, function(countryValue, countryKey) {
|
2012-03-25 21:12:13 +00:00
|
|
|
countryKey = countryKey.split(', ').pop();
|
2012-03-22 20:08:51 +00:00
|
|
|
if (
|
2012-03-26 10:55:49 +00:00
|
|
|
(Ox.getCountryByName(countryKey) || {})[key] == regionKey
|
2012-03-22 20:08:51 +00:00
|
|
|
&& countryValue > max
|
|
|
|
) {
|
|
|
|
flagCountry[mode][key][regionKey] = countryKey;
|
|
|
|
max = countryValue;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$guestsCheckbox = Ox.Checkbox({
|
2013-05-09 10:13:58 +00:00
|
|
|
title: Ox._('Include Guests'),
|
2012-03-22 20:08:51 +00:00
|
|
|
value: false
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px'})
|
|
|
|
.bindEvent({
|
|
|
|
change: function() {
|
|
|
|
$tabPanel.$element.replaceElement(1,
|
|
|
|
$tabPanel.options('content')($tabPanel.selected())
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$tabPanel = Ox.TabPanel({
|
|
|
|
content: function(id) {
|
2012-03-23 09:22:03 +00:00
|
|
|
var chartWidth = dialogWidth - 32 - Ox.UI.SCROLLBAR_SIZE,
|
|
|
|
mode = $guestsCheckbox.options('value') ? 'all' : 'registered',
|
2012-03-22 20:08:51 +00:00
|
|
|
top = 16,
|
|
|
|
$content = Ox.Element()
|
|
|
|
.css({
|
|
|
|
padding: '16px',
|
|
|
|
overflowY: 'auto',
|
2013-02-10 12:38:39 +00:00
|
|
|
background: pandora.user.ui.theme == 'oxlight' ? 'rgb(240, 240, 240)'
|
|
|
|
: pandora.user.ui.theme == 'oxmedium' ? 'rgb(160, 160, 160)'
|
2012-03-22 20:08:51 +00:00
|
|
|
: 'rgb(16, 16, 16)'
|
|
|
|
});
|
|
|
|
if (id == 'seen') {
|
2012-10-05 11:19:58 +00:00
|
|
|
['year', 'month', 'lastdays', 'topdays', 'weekday', 'hour'].forEach(function(key) {
|
|
|
|
var isDate = ['year', 'month'].indexOf(key) > -1,
|
|
|
|
isDay = ['lastdays', 'topdays'].indexOf(key) > -1;
|
2012-03-22 20:08:51 +00:00
|
|
|
Ox.Chart({
|
2012-03-26 19:27:20 +00:00
|
|
|
color: function(value) {
|
2012-03-27 07:14:59 +00:00
|
|
|
var split = value.split('-'),
|
2012-10-05 11:19:58 +00:00
|
|
|
color = isDate ? Ox.rgb(
|
2012-03-27 07:14:59 +00:00
|
|
|
Ox.mod(8 - parseInt(split[1], 10), 12) * 30, 1, 0.5
|
2012-06-24 15:41:44 +00:00
|
|
|
) : Ox.rgb(
|
2012-03-27 07:14:59 +00:00
|
|
|
(Math.abs(11.5 - parseInt(split[0], 10)) - 0.5) * -11, 1, 0.5
|
2012-06-24 15:41:44 +00:00
|
|
|
);
|
2013-02-10 12:38:39 +00:00
|
|
|
if (pandora.user.ui.theme == 'oxlight') {
|
2012-10-09 08:26:04 +00:00
|
|
|
color = getColor(color);
|
2012-03-27 07:14:59 +00:00
|
|
|
}
|
|
|
|
return color;
|
2012-03-26 19:27:20 +00:00
|
|
|
},
|
2012-10-05 11:19:58 +00:00
|
|
|
data: data[mode][isDay ? 'day' : key],
|
2012-03-22 20:08:51 +00:00
|
|
|
formatKey: function(value) {
|
2012-03-25 21:12:13 +00:00
|
|
|
var ret, split;
|
2012-10-05 11:19:58 +00:00
|
|
|
if (isDate) {
|
2012-03-25 21:12:13 +00:00
|
|
|
split = value.split('-');
|
|
|
|
ret = (split.pop() == 'firstseen' ? 'First' : 'Last') + ': '
|
|
|
|
+ (key == 'year' ? '' : Ox.MONTHS[parseInt(split[1], 10) - 1])
|
|
|
|
+ ' ' + split[0];
|
2012-10-05 11:19:58 +00:00
|
|
|
} else if (isDay) {
|
|
|
|
split = value.split('-');
|
|
|
|
ret = Ox.SHORT_WEEKDAYS[parseInt(Ox.formatDate(value, '%u')) - 1] + ', '
|
|
|
|
+ Ox.SHORT_MONTHS[parseInt(split[1], 10) - 1] + ' '
|
|
|
|
+ parseInt(split[2], 10) + ', ' + split[0];
|
2012-03-25 21:12:13 +00:00
|
|
|
} else {
|
2012-10-05 11:19:58 +00:00
|
|
|
ret = key == 'weekday'
|
2012-06-13 13:17:08 +00:00
|
|
|
? Ox.WEEKDAYS[parseInt(value, 10) - 1]
|
2012-03-25 21:12:13 +00:00
|
|
|
: value + ':00';
|
|
|
|
}
|
|
|
|
return ret;
|
2012-03-22 20:08:51 +00:00
|
|
|
},
|
|
|
|
keyAlign: 'right',
|
|
|
|
keyWidth: 128,
|
2012-10-05 11:19:58 +00:00
|
|
|
limit: isDay ? 30 : 0,
|
|
|
|
rows: isDate ? 2 : 1,
|
|
|
|
sort: {
|
|
|
|
key: key == 'topdays' ? 'value' : 'key',
|
|
|
|
operator: isDate || isDay ? '-' : '+'
|
|
|
|
},
|
2013-05-10 14:18:14 +00:00
|
|
|
title: key == 'lastdays' ? Ox._('Last 30 Days')
|
|
|
|
: key == 'topdays' ? Ox._('Top 30 Days')
|
|
|
|
: Ox._(Ox.toTitleCase(key) + 's'),
|
2012-03-22 20:08:51 +00:00
|
|
|
width: chartWidth
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: '16px',
|
|
|
|
top: top + 'px'
|
|
|
|
})
|
|
|
|
.appendTo($content);
|
2013-02-20 08:57:52 +00:00
|
|
|
top += (isDay ? Math.min(Ox.len(data[mode].day), 30) : Ox.len(data[mode][key])) * 16 + 32;
|
2012-03-22 20:08:51 +00:00
|
|
|
});
|
|
|
|
} else if (id == 'locations') {
|
|
|
|
['continent', 'region', 'country', 'city'].forEach(function(key) {
|
|
|
|
Ox.Chart({
|
2012-03-26 19:27:20 +00:00
|
|
|
color: function(value) {
|
2012-03-27 07:14:59 +00:00
|
|
|
var color = Ox.getGeoColor(
|
2012-03-26 19:27:20 +00:00
|
|
|
key == 'continent' ? value : value.split(', ')[1]
|
|
|
|
);
|
2013-02-10 12:38:39 +00:00
|
|
|
if (pandora.user.ui.theme == 'oxlight') {
|
2012-10-09 08:26:04 +00:00
|
|
|
color = getColor(color);
|
2012-03-27 07:14:59 +00:00
|
|
|
}
|
|
|
|
return color;
|
2012-03-26 19:27:20 +00:00
|
|
|
},
|
2012-03-22 20:08:51 +00:00
|
|
|
data: data[mode][key],
|
|
|
|
formatKey: function(value) {
|
2012-03-25 21:12:13 +00:00
|
|
|
var city, country, split = value.split(', ');
|
|
|
|
if (key == 'continent' || key == 'region') {
|
|
|
|
country = flagCountry[mode][key][Ox.last(split)];
|
2012-03-22 20:08:51 +00:00
|
|
|
} else {
|
2012-03-25 21:12:13 +00:00
|
|
|
country = split[2];
|
|
|
|
city = key == 'city' ? split[3] : ''
|
2012-03-22 20:08:51 +00:00
|
|
|
}
|
|
|
|
return $('<div>')
|
|
|
|
.append(
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: '104px',
|
|
|
|
height: '14px',
|
|
|
|
marginLeft: '-4px',
|
|
|
|
marginRight: '4px',
|
|
|
|
overflow: 'hidden',
|
|
|
|
textOverflow: 'ellipsis'
|
|
|
|
})
|
|
|
|
.html(
|
2012-03-26 09:57:59 +00:00
|
|
|
Ox.last(split)
|
2012-03-22 20:08:51 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
.append(
|
2012-03-25 21:12:13 +00:00
|
|
|
Ox.Element({
|
|
|
|
element: '<img>',
|
|
|
|
tooltip: mode == 'all' && (key == 'continent' || key == 'region')
|
|
|
|
? Ox.wordwrap(
|
2012-05-22 15:07:34 +00:00
|
|
|
Ox.COUNTRIES.filter(function(country) {
|
2012-03-25 21:12:13 +00:00
|
|
|
return country[key] == split[key == 'continent' ? 0 : 1]
|
|
|
|
&& country.code.length == 2
|
2012-05-22 15:07:34 +00:00
|
|
|
&& !country.exception
|
2012-03-25 21:12:13 +00:00
|
|
|
&& !country.disputed
|
2012-05-22 15:07:34 +00:00
|
|
|
&& !country.dissolved;
|
|
|
|
}).map(function(country) {
|
|
|
|
return country.name;
|
2012-03-25 21:12:13 +00:00
|
|
|
}).sort().join(', '),
|
|
|
|
64, '<br>', true
|
|
|
|
).split(', ').map(function(country) {
|
|
|
|
return Ox.values(Ox.map(data.all.country, function(value, key) {
|
|
|
|
return key.split(', ').pop()
|
|
|
|
})).indexOf(country.replace(/<br>/g, '')) > -1
|
|
|
|
? '<span class="OxBright">' + country + '</span>'
|
|
|
|
: country
|
|
|
|
}).join(', ')
|
|
|
|
: ''
|
|
|
|
})
|
2012-03-22 20:08:51 +00:00
|
|
|
.attr({
|
|
|
|
src: Ox.getFlagByGeoname(country, 16)
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: '14px',
|
|
|
|
height: '14px',
|
|
|
|
borderRadius: '4px',
|
|
|
|
margin: '0 1px 0 1px'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
|
|
|
keyAlign: 'right',
|
|
|
|
keyWidth: 128,
|
2013-03-25 04:09:35 +00:00
|
|
|
limit: 1000,
|
2012-03-22 20:08:51 +00:00
|
|
|
sort: {key: 'value', operator: '-'},
|
2013-03-25 04:09:35 +00:00
|
|
|
title: (
|
|
|
|
Ox.endsWith(key, 'y')
|
2012-05-22 13:15:16 +00:00
|
|
|
? Ox.toTitleCase(key).slice(0, -1) + 'ies'
|
2013-03-25 04:09:35 +00:00
|
|
|
: Ox.toTitleCase(key) + 's'
|
|
|
|
) + ' (' + (
|
|
|
|
Ox.len(data[mode][key]) > 1000
|
|
|
|
? '1,000 of '
|
|
|
|
: ''
|
|
|
|
) + Ox.formatNumber(Ox.len(data[mode][key])) + ')',
|
2012-03-22 20:08:51 +00:00
|
|
|
width: chartWidth
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: '16px',
|
|
|
|
top: top + 'px'
|
|
|
|
})
|
|
|
|
.appendTo($content);
|
2013-05-08 11:53:33 +00:00
|
|
|
top += Math.min(Ox.len(data[mode][key]), 1000) * 16 + 32;
|
2012-03-22 20:08:51 +00:00
|
|
|
});
|
2012-10-27 17:01:13 +00:00
|
|
|
} else if (id == 'platforms') {
|
2012-03-22 20:08:51 +00:00
|
|
|
['', 'version'].forEach(function(version, i) {
|
|
|
|
['system', 'browser'].forEach(function(key) {
|
|
|
|
Ox.Chart({
|
2012-03-26 19:27:20 +00:00
|
|
|
color: function(value) {
|
2012-10-27 17:28:47 +00:00
|
|
|
var name = version ? getName(key, value) : value,
|
2012-03-27 09:41:03 +00:00
|
|
|
color = colors[key][name];
|
2013-02-10 12:38:39 +00:00
|
|
|
if (pandora.user.ui.theme == 'oxlight') {
|
2012-10-09 08:26:04 +00:00
|
|
|
color = getColor(color);
|
2012-03-27 07:14:59 +00:00
|
|
|
}
|
|
|
|
return color;
|
2012-03-26 19:27:20 +00:00
|
|
|
},
|
2012-03-22 20:08:51 +00:00
|
|
|
data: data[mode][key + version],
|
|
|
|
formatKey: function(value) {
|
2012-10-27 17:28:47 +00:00
|
|
|
var name = version ? getName(key, value) : value,
|
2012-03-22 20:08:51 +00:00
|
|
|
$element = $('<div>');
|
|
|
|
$element.append(
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: '168px',
|
|
|
|
height: '14px',
|
|
|
|
marginLeft: '-4px',
|
|
|
|
marginRight: '4px',
|
|
|
|
overflow: 'hidden',
|
|
|
|
textOverflow: 'ellipsis'
|
|
|
|
})
|
2012-03-27 09:41:03 +00:00
|
|
|
.html(
|
|
|
|
value
|
|
|
|
.replace(/BSD \((.+)\)/, '$1')
|
|
|
|
.replace(/Linux \((.+)\)/, '$1')
|
2012-03-27 10:03:30 +00:00
|
|
|
.replace(/Unix \((.+)\)/, '$1')
|
2012-03-27 09:41:03 +00:00
|
|
|
.replace(/Windows (NT \d+\.\d+) \((.+)\)/, 'Windows $2 ($1)')
|
|
|
|
)
|
2012-03-22 20:08:51 +00:00
|
|
|
).append(
|
|
|
|
$('<img>')
|
|
|
|
.attr({
|
|
|
|
src: Ox.UI.PATH + 'png/' + key
|
|
|
|
+ name.replace(/ /g, '') + '128.png'
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
float: 'left',
|
|
|
|
width: '14px',
|
|
|
|
height: '14px',
|
|
|
|
margin: '0 1px 0 1px'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
return $element;
|
|
|
|
},
|
|
|
|
keyWidth: 192,
|
|
|
|
sort: version == ''
|
|
|
|
? {key: 'value', operator: '-'}
|
|
|
|
: {key: 'key', operator: '+'},
|
2013-05-10 14:18:14 +00:00
|
|
|
title: Ox._(key == 'system'
|
2012-10-27 17:01:13 +00:00
|
|
|
? (version == '' ? 'Platforms' : 'Platform Versions')
|
2013-05-10 14:18:14 +00:00
|
|
|
: (version == '' ? 'Browsers' : 'Browser Versions')),
|
2012-03-22 20:08:51 +00:00
|
|
|
width: chartWidth
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: '16px',
|
|
|
|
top: top + 'px'
|
|
|
|
})
|
|
|
|
.appendTo($content);
|
|
|
|
top += Ox.len(data[mode][key + version]) * 16 + 32;
|
|
|
|
});
|
2012-03-27 09:41:03 +00:00
|
|
|
Ox.Chart({
|
|
|
|
color: function(value) {
|
|
|
|
var color = Ox.zip(value.split(' / ').map(function(v, i) {
|
2012-10-27 17:34:22 +00:00
|
|
|
var key = ['system', 'browser'][i];
|
2012-10-27 17:28:47 +00:00
|
|
|
v = version ? getName(key, v) : v;
|
2012-10-27 17:34:22 +00:00
|
|
|
return colors[key][v];
|
2012-03-26 19:27:20 +00:00
|
|
|
})).map(function(c) {
|
|
|
|
return Math.round(Ox.sum(c) / 2);
|
2012-03-27 07:14:59 +00:00
|
|
|
});
|
2013-02-10 12:38:39 +00:00
|
|
|
if (pandora.user.ui.theme == 'oxlight') {
|
2012-10-09 08:26:04 +00:00
|
|
|
color = getColor(color);
|
2012-03-27 09:41:03 +00:00
|
|
|
}
|
|
|
|
return color;
|
|
|
|
},
|
|
|
|
data: data[mode]['systemandbrowser' + version],
|
|
|
|
formatKey: function(value) {
|
|
|
|
var $element = $('<div>')
|
|
|
|
.append(
|
|
|
|
$('<div>')
|
|
|
|
.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')
|
2012-03-27 10:03:30 +00:00
|
|
|
.replace(/Unix \((.+)\)/, '$1')
|
2012-03-27 09:41:03 +00:00
|
|
|
.replace(/Windows NT \d+\.\d+ \((.+)\)/, 'Windows $1')
|
|
|
|
.replace(/Chrome Frame/, 'CF')
|
|
|
|
.replace(/Internet Explorer/, 'IE')
|
|
|
|
: value
|
|
|
|
)
|
|
|
|
);
|
|
|
|
value.split(' / ').forEach(function(value, i) {
|
2012-10-27 17:34:22 +00:00
|
|
|
var key = ['system', 'browser'][i];
|
2012-10-27 17:28:47 +00:00
|
|
|
value = version ? getName(key, value) : value;
|
2012-03-27 09:41:03 +00:00
|
|
|
$element.append(
|
|
|
|
$('<img>')
|
|
|
|
.attr({
|
2012-10-27 17:34:22 +00:00
|
|
|
src: Ox.UI.PATH + 'png/' + key
|
2012-03-27 09:41:03 +00:00
|
|
|
+ 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 == ''
|
2013-05-10 14:18:14 +00:00
|
|
|
? Ox._('Platforms & Browsers')
|
|
|
|
: Ox._('Platform & Browser Versions'),
|
2012-03-27 09:41:03 +00:00
|
|
|
width: chartWidth
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: '16px',
|
|
|
|
top: top + 'px'
|
|
|
|
})
|
|
|
|
.appendTo($content);
|
|
|
|
top += Ox.len(data[mode]['systemandbrowser' + version]) * 16 + 32;
|
2012-03-22 20:08:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
$('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
top: top - 16 + 'px',
|
|
|
|
width: '1px',
|
|
|
|
height: '16px'
|
|
|
|
})
|
|
|
|
.appendTo($content);
|
|
|
|
return $content;
|
|
|
|
},
|
|
|
|
tabs: tabs
|
|
|
|
});
|
|
|
|
|
2012-05-22 13:15:16 +00:00
|
|
|
$tabPanel.find('.OxButtonGroup').css({width: '512px'});
|
2012-03-22 20:08:51 +00:00
|
|
|
$guestsCheckbox.appendTo($tabPanel.children('.OxBar'));
|
|
|
|
|
|
|
|
$dialog.options({content: $tabPanel});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2012-10-09 08:26:04 +00:00
|
|
|
function getColor(color) {
|
|
|
|
var hsl = Ox.hsl(color);
|
2012-10-31 23:14:09 +00:00
|
|
|
hsl[2] = Math.max(hsl[2] - 0.1, 0);
|
2012-10-09 08:26:04 +00:00
|
|
|
return Ox.rgb(hsl);
|
|
|
|
}
|
|
|
|
|
2012-10-27 17:28:47 +00:00
|
|
|
function getName(key, version) {
|
2012-03-27 09:41:03 +00:00
|
|
|
var name = '';
|
2012-10-27 17:28:47 +00:00
|
|
|
Ox.forEach(Object.keys(colors[key]), function(v) {
|
2012-03-27 09:41:03 +00:00
|
|
|
if (new RegExp('^' + v).test(version)) {
|
|
|
|
name = v;
|
2012-07-04 11:40:37 +00:00
|
|
|
return false;
|
2012-03-27 09:41:03 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2012-03-22 20:08:51 +00:00
|
|
|
return $dialog;
|
|
|
|
|
2012-05-22 13:15:16 +00:00
|
|
|
};
|