From afae94a1befb2e720633f3d15559099b2525368b Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 24 Jul 2014 19:21:57 +0200 Subject: [PATCH] pass audioTrack, expand languages before passing --- static/js/editor.js | 4 +++- static/js/player.js | 7 ++++--- static/js/utils.js | 20 +++++++------------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/static/js/editor.js b/static/js/editor.js index c3c65a1c..871d3582 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -14,6 +14,7 @@ pandora.ui.editor = function(data) { annotationsSort: ui.annotationsSort, annotationsTooltip: Ox._('annotations') + ' ' + Ox.SYMBOLS.SHIFT + 'A', + audioTrack: data.audioTrack, censored: data.censored, censoredIcon: pandora.site.cantPlay.icon, censoredTooltip: Ox._(pandora.site.cantPlay.text), @@ -60,8 +61,9 @@ pandora.ui.editor = function(data) { showLayers: Ox.clone(ui.showLayers), showUsers: pandora.site.annotations.showUsers, subtitles: data.subtitles, - subtitlesDefaultTrack: pandora.site.language, + subtitlesDefaultTrack: Ox.getLanguageNameByCode(pandora.site.language), subtitlesLayer: data.subtitlesLayer, + subtitlesTrack: Ox.getLanguageNameByCode(pandora.site.language), timeline: ui.videoTimeline, timelines: pandora.site.timelines, video: data.video, diff --git a/static/js/player.js b/static/js/player.js index 3e71f905..1f802d1e 100644 --- a/static/js/player.js +++ b/static/js/player.js @@ -14,7 +14,7 @@ pandora.ui.player = function(data) { annotationsSort: ui.annotationsSort, annotationsTooltip: Ox._('annotations') + ' ' + Ox.SYMBOLS.SHIFT + 'A', - audioTrack: data.audioTracks ? data.audioTracks[0] : void 0, + audioTrack: data.audioTrack, censored: data.censored, censoredIcon: pandora.site.cantPlay.icon, censoredTooltip: Ox._(pandora.site.cantPlay.text), @@ -49,8 +49,9 @@ pandora.ui.player = function(data) { showUsers: pandora.site.annotations.showUsers, showTimeline: ui.showTimeline, smallTimelineURL: pandora.getMediaURL('/' + ui.item + '/timeline16p.jpg'), - subtitles: data.subtitles, - subtitlesDefaultTrack: pandora.site.language, + subtitlesDefaultTrack: Ox.getLanguageNameByCode(pandora.site.language), + subtitlesLayer: data.subtitlesLayer, + subtitlesTrack: Ox.getLanguageNameByCode(pandora.site.language), timeline: ui.videoTimeline, timelineTooltip: Ox._('timeline') + ' ' + Ox.SYMBOLS.SHIFT + 'T', video: data.video, diff --git a/static/js/utils.js b/static/js/utils.js index 45b18632..d25c729a 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1758,18 +1758,6 @@ pandora.getVideoOptions = function(data) { }).map(function(layer) { return layer.id; })[0]; - options.subtitles = options.subtitlesLayer - ? data.layers[options.subtitlesLayer].map(function(subtitle) { - return Ox.extend({ - id: subtitle.id, - 'in': subtitle['in'], - out: subtitle.out, - text: subtitle.value.replace(/\n/g, ' ').replace(//g, '\n') - }, subtitle.languages ? { - tracks: subtitle.languages - } : {}); - }) - : []; options.censored = canPlayVideo ? [] : canPlayClips ? ( options.subtitles.length @@ -1800,7 +1788,7 @@ pandora.getVideoOptions = function(data) { options.video.push({ duration: data.durations[i], index: i, - track: track, + track: Ox.getLanguageNameByCode(track), resolution: resolution, src: pandora.getVideoURL(data.item || pandora.user.ui.item, resolution, i + 1, track) }); @@ -1817,6 +1805,7 @@ pandora.getVideoOptions = function(data) { }); } }); + options.audioTrack = data.audioTracks ? Ox.getLanguageNameByCode(data.audioTracks[0]) : void 0; options.annotations = []; pandora.site.layers.forEach(function(layer, i) { options.annotations[i] = Ox.extend({}, layer, { @@ -1827,6 +1816,11 @@ pandora.getVideoOptions = function(data) { annotation.editable = annotation.editable || annotation.user == pandora.user.username || pandora.site.capabilities['canEditAnnotations'][pandora.user.level]; + annotation.languages = ( + annotation.languages || [pandora.site.language] + ).map(function(language) { + return Ox.getLanguageNameByCode(language); + }); return annotation; }) });