update filmographies

This commit is contained in:
rolux 2013-03-14 07:19:04 +00:00
parent ec30110ac9
commit 4ea2328fe5

View file

@ -578,7 +578,7 @@ pandora.ui.infoView = function(data) {
return ret; return ret;
} }
function getFilmography(key, value, callback) { function getFilmography(key, value, roles, callback) {
var keys = ['id', 'title', 'year'].concat( var keys = ['id', 'title', 'year'].concat(
key == 'name' ? nameKeys : [] key == 'name' ? nameKeys : []
); );
@ -601,12 +601,17 @@ pandora.ui.infoView = function(data) {
result.data.items.forEach(function(item) { result.data.items.forEach(function(item) {
var year = item.year || 'Unknown Year'; var year = item.year || 'Unknown Year';
if (key == 'name') { if (key == 'name') {
item.role = nameKeys.filter(function(nameKey) { item.roles = nameKeys.filter(function(nameKey) {
return Ox.contains(item[nameKey], value); return Ox.contains(item[nameKey], value);
}).map(function(nameKey) { });
if (roles.length == 1 && Ox.isEqual(item.roles, roles)) {
delete item.roles;
} else {
item.roles = item.roles.map(function(nameKey) {
return Ox.getObjectById(pandora.site.itemKeys, nameKey).title; return Ox.getObjectById(pandora.site.itemKeys, nameKey).title;
}); });
} }
}
if (!items[year]) { if (!items[year]) {
items[year] = []; items[year] = [];
} }
@ -617,7 +622,7 @@ pandora.ui.infoView = function(data) {
Object.keys(items).sort().map(function(year) { Object.keys(items).sort().map(function(year) {
return '<b>' + year + ':</b> ' + items[year].map(function(item) { return '<b>' + year + ':</b> ' + items[year].map(function(item) {
return '<a href="/' + item.id + '">' + item.title + '</a>' return '<a href="/' + item.id + '">' + item.title + '</a>'
+ (item.role ? ' (' + item.role.join(', ') + ')' : ''); + (item.roles ? ' (' + item.roles.join(', ') + ')' : '');
}).join(', '); }).join(', ');
}).join(', ') }).join(', ')
); );
@ -792,6 +797,7 @@ pandora.ui.infoView = function(data) {
getFilmography( getFilmography(
key == 'studios' ? 'productionCompany' : 'name', key == 'studios' ? 'productionCompany' : 'name',
value.name, value.name,
value.keys,
function($element) { function($element) {
$link.addClass('OxLink') $link.addClass('OxLink')
.html('Hide ' + filmography) .html('Hide ' + filmography)