Sanjay B
10 years ago
15 changed files with 483 additions and 58 deletions
@ -0,0 +1,100 @@ |
|||
pandora.ui.annotationsPanel = function(layers) { |
|||
console.log('annotationsPanel init') |
|||
var layers = layers || []; |
|||
//Ox.print("layers", layers);
|
|||
var showLayers = {}; |
|||
layers.forEach(function(v,i) { |
|||
showLayers[v.id] = true; |
|||
}); |
|||
|
|||
Ox.print("annotation layers", layers); |
|||
var that = Ox.AnnotationPanel({ |
|||
'layers': Ox.clone(layers, true), |
|||
'width': 256, |
|||
'range': 'position', |
|||
'showLayers': showLayers |
|||
}); |
|||
|
|||
that.interval = setInterval(function() { |
|||
//console.log("interval");
|
|||
var changed = pandora.$ui.textArea.changed; |
|||
if (changed) { |
|||
//console.log("interval changed");
|
|||
pandora.$ui.textArea.changed = false; |
|||
var currentTrack = pandora.$ui.textArea.currentTrack; |
|||
//Ox.print("current layers", pandora.$ui.textArea.speedtrans.toSrt("layers"));
|
|||
//Ox.print("layer", currentTrack);
|
|||
|
|||
//var currentLayers = that.options('layers');
|
|||
//console.log("current layers", layers);
|
|||
//console.log("current track", currentTrack);
|
|||
var layerIndex = Ox.getIndexById(layers, currentTrack); |
|||
layers[layerIndex].items = pandora.$ui.textArea.speedtrans.toSrt("layers"); |
|||
Ox.print("setting these layers", layers); |
|||
that.options('layers', Ox.clone(layers, true)); |
|||
//that.updateLayer(currentTrack, pandora.$ui.textArea.speedtrans.toSrt("layers"));
|
|||
} |
|||
}, 1500); |
|||
|
|||
|
|||
var $panelMenuButton = Ox.MenuButton({ |
|||
'title': 'edit', |
|||
'type': 'image', |
|||
'style': 'symbol', |
|||
'tooltip': 'Add Layer', |
|||
'items': [ |
|||
{ |
|||
'id': 'newSRT', |
|||
'title': 'New Layer' |
|||
}, |
|||
{ |
|||
'id': 'openSRT', |
|||
'title': 'Import SRT ...' |
|||
} |
|||
] |
|||
|
|||
}).css({'float': 'right'}).bindEvent("click", function(data) { |
|||
if (data.id == 'openSRT') { |
|||
pandora.$ui.openSRTDialog.open(); |
|||
} else if (data.id == 'newSRT') { |
|||
var title = pandora.utils.getUntitledName(); |
|||
pandora.storage(pandora.$ui.textArea.storage)[title] = ''; |
|||
pandora.$ui.textArea.currentTrack = title; |
|||
pandora.$ui.annotationsPanel.addLayer({ |
|||
'id': title, |
|||
'title': title, |
|||
'items': [] |
|||
}); |
|||
pandora.$ui.selectAnnotationType.value(title); |
|||
pandora.utils.updateFolderMenus(); |
|||
} |
|||
}); |
|||
|
|||
// var $addButton = Ox.Button({
|
|||
// 'title': 'add',
|
|||
// 'type': 'image',
|
|||
// 'style': 'symbol',
|
|||
// 'tooltip': 'New annotation layer'
|
|||
// }).css({'float': 'right'}).bindEvent("click", function() {
|
|||
// pandora.$ui.newSRTDialog.open();
|
|||
// });
|
|||
|
|||
// var $loadSRTButton = Ox.Button({
|
|||
// 'title': 'upload',
|
|||
// 'type': 'image',
|
|||
// 'style': 'symbol',
|
|||
// 'tooltip': 'Import SRT'
|
|||
// }).css({'float': 'right'}).bindEvent("click", function() {
|
|||
// pandora.$ui.openSRTDialog.open();
|
|||
// });
|
|||
|
|||
Ox.print("panel menu button", $panelMenuButton); |
|||
$(that.find('.OxBar')[0]).append($panelMenuButton); |
|||
|
|||
// that.updateLayers = function() {
|
|||
// var layers = that.getLayers();
|
|||
// that.options("layers", layers);
|
|||
// };
|
|||
|
|||
return that; |
|||
}; |
@ -0,0 +1,8 @@ |
|||
pandora.ui.newSRTDialog = function() { |
|||
|
|||
var that = Ox.Dialog({ |
|||
|
|||
}); |
|||
|
|||
return that; |
|||
}; |
@ -0,0 +1,64 @@ |
|||
pandora.ui.selectAnnotationType = function() { |
|||
// var annot_types = [
|
|||
// {
|
|||
// 'id': 'transcript',
|
|||
// 'title': 'Transcript'
|
|||
// },
|
|||
// {
|
|||
// 'id': 'description',
|
|||
// 'title': 'Description'
|
|||
// },
|
|||
// {
|
|||
// 'id': 'other',
|
|||
// 'title': 'Other...'
|
|||
// }
|
|||
// ];
|
|||
|
|||
var that = Ox.Input({ |
|||
//'items': annot_types,
|
|||
'label': 'Type', |
|||
'placeholder': 'type annotation type', |
|||
labelWidth: 256, |
|||
width: 512, |
|||
//'max': 1,
|
|||
//'min': 1,
|
|||
'value': 'untitled', |
|||
}).bindEvent("blur", function(e) { |
|||
//alert("changed annot type");
|
|||
//console.log(e);
|
|||
var videoKey = pandora.$ui.textArea.storage; |
|||
var storageData = pandora.storage(videoKey); |
|||
var currentName = pandora.$ui.textArea.currentTrack; |
|||
console.log(currentName); |
|||
//console.log(storage);
|
|||
var newName = this.value(); |
|||
console.log(newName); |
|||
if (currentName == newName) return; |
|||
storageData[newName] = pandora.$ui.textArea.value(); |
|||
delete(storageData[currentName]); |
|||
pandora.storage(videoKey, storageData); |
|||
pandora.$ui.textArea.currentTrack = newName; |
|||
//delete(storage[currentName]);
|
|||
pandora.$ui.annotationsPanel.removeLayer(currentName); |
|||
pandora.$ui.annotationsPanel.addLayer({ |
|||
'id': newName, |
|||
'title': newName, |
|||
'items': pandora.$ui.textArea.speedtrans.toSrt("layers", storageData[newName]) |
|||
}); |
|||
//var storage = pandora.storage
|
|||
// var typ = this.value();
|
|||
// var textArea = pandora.$ui.textArea;
|
|||
// var val = pandora.storage(textArea.storage);
|
|||
// if (val[typ]) {
|
|||
// var txt = val[typ];
|
|||
// } else {
|
|||
// var txt = val[typ] = '';
|
|||
// pandora.storage(textArea.storage, val);
|
|||
// }
|
|||
// textArea.value(txt);
|
|||
}); |
|||
|
|||
|
|||
|
|||
return that; |
|||
}; |
@ -0,0 +1,116 @@ |
|||
pandora.utils = {}; |
|||
|
|||
pandora.utils.updateFolderMenus = function() { |
|||
//Ox.print("updateFolderMenus called");
|
|||
$(".OxAnnotationFolder").each(function() { |
|||
//Ox.print("each");
|
|||
var $this = $(this); |
|||
var $bar = $this.children().eq(0); |
|||
var title = $bar.find(".OxTitle").text(); |
|||
var $extras = $bar.find(".OxExtras"); |
|||
$extras.empty(); |
|||
//Ox.print($extras);
|
|||
var disabled = title == pandora.$ui.selectAnnotationType.value(); |
|||
var $folderMenuButton = Ox.MenuButton({ |
|||
'title': 'edit', |
|||
'type': 'image', |
|||
'style': 'symbol', |
|||
'tooltip': 'Add Layer', |
|||
'items': [ |
|||
{ |
|||
'id': 'editSRT', |
|||
'title': 'Edit this layer', |
|||
'disabled': disabled |
|||
}, |
|||
{ |
|||
'id': 'exportSRT', |
|||
'title': 'Export SRT for this layer' |
|||
|
|||
}, |
|||
{}, |
|||
{ |
|||
'id': 'removeSRT', |
|||
'title': 'Remove this layer' |
|||
} |
|||
] |
|||
}).appendTo($extras).bindEvent("click", function(data) { |
|||
Ox.print(data.id); |
|||
if (data.id == 'editSRT') { |
|||
pandora.$ui.selectAnnotationType.value(title); |
|||
var storage = pandora.$ui.textArea.storage; |
|||
var txt = pandora.storage(storage)[title]; |
|||
pandora.$ui.textArea.value(txt); |
|||
pandora.utils.updateFolderMenus(); |
|||
} else if (data.id == 'exportSRT') { |
|||
|
|||
} else if (data.id == 'removeSRT') { |
|||
var storageData = pandora.storage(pandora.$ui.textArea.storage); |
|||
if (Object.keys(storageData).length == 1) { |
|||
alert("Cannot remove the only annotation layer"); |
|||
return; |
|||
} |
|||
if (confirm("Are you sure you wish to permanently delete this annotation track?")) { |
|||
pandora.$ui.annotationsPanel.removeLayer(title); |
|||
delete(storageData[title]); |
|||
pandora.storage(pandora.$ui.textArea.storage, currStorage); |
|||
var newTitle = Object.keys(storageData)[0]; |
|||
var txt = storageData[newTitle]; |
|||
pandora.$ui.selectAnnotationType.value(newTitle); |
|||
pandora.$ui.textArea.value(txt); |
|||
} |
|||
|
|||
} |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
pandora.utils.getUntitledName = function(name) { |
|||
var currStorage = pandora.storage(pandora.$ui.textArea.storage); |
|||
// var keys = Object.keys(currStorage);
|
|||
// console.log(keys);
|
|||
var title = name || "untitled"; |
|||
var i = 1; |
|||
while (currStorage.hasOwnProperty(title)) { |
|||
title = title + "-" + i; |
|||
i++; |
|||
}; |
|||
return title; |
|||
}; |
|||
|
|||
pandora.utils.loadLocalFile = function(file) { |
|||
Ox.oshash(file, function(oshash) { |
|||
//console.log(oshash);
|
|||
var url = window.URL.createObjectURL(file); |
|||
var options = { |
|||
'type': 'local', |
|||
'url': url, |
|||
'name': oshash, |
|||
'title': file.name |
|||
} |
|||
pandora.$ui.textArea.speedtrans.load(options); |
|||
}); |
|||
}; |
|||
|
|||
pandora.utils.commonKeyboardEvents = { |
|||
key_control_up: function() { |
|||
Ox.print("ctrl left"); |
|||
pandora.$ui.videoPlayer.seek(-1); |
|||
}, |
|||
key_control_down: function() { |
|||
Ox.print("ctrl right"); |
|||
pandora.$ui.videoPlayer.seek(1); |
|||
}, |
|||
key_control_shift_up: function() { |
|||
pandora.$ui.videoPlayer.seek(-0.040); |
|||
}, |
|||
key_control_shift_down: function() { |
|||
pandora.$ui.videoPlayer.seek(0.040); |
|||
}, |
|||
key_control_space: function() { |
|||
pandora.$ui.videoPlayer.options("paused", !pandora.$ui.videoPlayer.options("paused")); |
|||
pandora.$ui.textArea.find("textarea").focus(); //FIXME
|
|||
}, |
|||
key_control_shift_s: function() { |
|||
pandora.$ui.textArea.speedtrans.save(); |
|||
} |
|||
} |
Loading…
Reference in new issue