From 10c78fc8623d60cb0c508ed50763c9cd99b0c0c5 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 22 Jan 2025 17:42:44 +0530 Subject: [PATCH] allow selecting multiple annotations to get in/out range --- static/js/editor.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/static/js/editor.js b/static/js/editor.js index 90558d63..5d131c56 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -391,7 +391,21 @@ pandora.ui.editor = function(data) { pandora.UI.set({videoResolution: data.resolution}); }, select: function(data) { - pandora.UI.set('videoPoints.' + ui.item + '.annotation', data.id.split('/')[1] || ''); + if (Ox.isArray(data.id)) { + var range = data.id.map(id => { + return getAnnotationById(id) + }) + data['in'] = Ox.min(range.map(annotation => { return annotation["in"]; })) + data['out'] = Ox.max(range.map(annotation => { return annotation["out"]; })) + pandora.UI.set('videoPoints.' + ui.item, { + annotation: '', + 'in': data['in'], + out: data.out, + position: ui.videoPoints[ui.item].position + }) + } else { + pandora.UI.set('videoPoints.' + ui.item + '.annotation', data.id.split('/')[1] || ''); + } }, showentityinfo: function(data) { pandora.URL.push('/entities/' + data.id) @@ -428,6 +442,18 @@ pandora.ui.editor = function(data) { pandora._dontSelectResult = false; + function getAnnotationById(id) { + var annotation + data.annotations.forEach(layer => { + layer.items.forEach(a => { + if (a.id == id) { + annotation = a + } + }) + }) + return annotation; + } + function updateBrowser() { pandora.$ui.browser.find('img[src*="/' + ui.item + '/"]').each(function() { $(this).attr({