').css(css).html(html.join('; ')).appendTo($text);
}
+ // Alternative Titles ------------------------------------------------------
+
data.alternativeTitles && $('
')
.css(css)
.html(
@@ -435,6 +457,30 @@ pandora.ui.infoView = function(data) {
return false;
}
+ function editMetadata(key, value) {
+ var edit = {id: data.id};
+ if (key == 'title') {
+ Ox.extend(edit, parseTitle(value));
+ } else if (key == 'director' || key == 'country') {
+ edit[key] = value.split(', ');
+ } else {
+ edit[key] = value;
+ }
+ pandora.api.edit(edit, function(result) {
+ if (result.data.id != data.id) {
+ Ox.Request.clearCache(); // fixme: too much
+ pandora.UI.set({item: result.data.id});
+ pandora.$ui.browser.value(data.id, 'id', result.data.id);
+ }
+ // FIXME: value function should accept {k: v, ...}
+ pandora.$ui.browser.value(result.data.id, 'title', result.data.title);
+ pandora.$ui.browser.value(result.data.id, 'director', result.data.director);
+ pandora.$ui.browser.value(result.data.id, 'country', result.data.country);
+ pandora.$ui.browser.value(result.data.id, 'year', result.data.year);
+ //pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser());
+ });
+ }
+
function formatKey(key, isStatistics) {
return isStatistics
? $('
').css({marginBottom: '2px', fontWeight: 'bold'}).html(Ox.toTitleCase(key))
@@ -445,6 +491,17 @@ pandora.ui.infoView = function(data) {
return '' + str + '';
}
+ function formatTitle(title) {
+ var match = /(\(S\d{2}E\d{2}\))/.exec(title);
+ if (match) {
+ title = title.replace(match[0], formatLight(match[0]));
+ }
+ return title + (
+ data.originalTitle && data.originalTitle != title
+ ? ' ' + formatLight('(' + data.originalTitle + ')') : ''
+ );
+ }
+
function formatValue(value, key) {
return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ?
@@ -496,6 +553,20 @@ pandora.ui.infoView = function(data) {
}
}
+ function parseTitle(title) {
+ var data = {title: title},
+ match = /(\(S(\d{2})E(\d{2})\))/.exec(title),
+ split;
+ if (match) {
+ data.season = parseInt(match[2], 10);
+ data.episode = parseInt(match[3], 10);
+ split = title.split(match[1]);
+ data.seriesTitle = split[0].trim();
+ data.episodeTitle = split[1].trim();
+ }
+ return data;
+ }
+
function renderCapabilities(rightsLevel) {
var capabilities = Ox.merge(
canEdit ? [{name: 'canSeeItem', symbol: 'Find'}] : [],