From 1ec946d118e387066338b4bf53ae9c46d00a4b88 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 14 Jul 2013 10:57:03 +0000 Subject: [PATCH] update video on sort and time code changes --- pandora/edit/views.py | 2 +- static/js/pandora/editPanel.js | 36 +++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/pandora/edit/views.py b/pandora/edit/views.py index 3dd3558c..d0d50667 100644 --- a/pandora/edit/views.py +++ b/pandora/edit/views.py @@ -96,7 +96,7 @@ def editClip(request): response = json_response() data = json.loads(request.POST['data']) clip = get_object_or_404_json(models.Clip, pk=ox.fromAZ(data['id'])) - valid = False + valid = True if clip.edit.editable(request.user): for key in ('in', 'out'): if key in data: diff --git a/static/js/pandora/editPanel.js b/static/js/pandora/editPanel.js index 38449244..1ef19d4c 100644 --- a/static/js/pandora/editPanel.js +++ b/static/js/pandora/editPanel.js @@ -116,8 +116,14 @@ pandora.ui.editPanel = function() { args['in'] = args.out; } pandora.api.editClip(args, function(result) { - edit.clips[index] = result.data; - that.updateClip(data.id, result.data); + if (result.status.code == 200) { + edit.clips[index] = result.data; + console.log(index, result.data); + that.updateClip(data.id, result.data); + updateVideos(); + } else { + Ox.print('failed to edit clip', result); + } }); }); }, @@ -127,6 +133,7 @@ pandora.ui.editPanel = function() { ids: data.ids }, function() { Ox.Request.clearCache('getEdit'); + sortClips(data.ids); }); }, muted: function(data) { @@ -138,6 +145,7 @@ pandora.ui.editPanel = function() { clips: Ox.Clipboard.paste(), edit: pandora.user.ui.edit }, function(result) { + Ox.Request.clearCache('getEdit'); updateClips(edit.clips.concat(result.data.clips)); }); } @@ -154,6 +162,7 @@ pandora.ui.editPanel = function() { ids: data.ids, edit: pandora.user.ui.edit }, function(result) { + Ox.Request.clearCache('getEdit'); updateClips(result.data.clips); }); } @@ -213,8 +222,15 @@ pandora.ui.editPanel = function() { }); } + function sortClips(ids) { + edit.clips.forEach(function(clip) { + clip.index = ids.indexOf(clip.id); + }); + edit.clips = Ox.sortBy(edit.clips, 'index'); + udpateVideos(); + } + function updateClips(clips) { - Ox.Request.clearCache(); // FIXME: too much edit.clips = clips; edit.duration = 0; edit.clips.forEach(function(clip) { @@ -230,6 +246,20 @@ pandora.ui.editPanel = function() { } + function updateVideos() { + edit.duration = 0; + edit.clips.forEach(function(clip) { + clip.position = edit.duration; + edit.duration += clip.duration; + }); + that.options({ + smallTimelineURL: getSmallTimelineURL(), + video: getVideos() + }); + updateSmallTimelineURL(); + } + + function updateSmallTimelineURL() { var fps = 25; Ox.serialForEach(edit.clips, function(clip) {