117 lines
3.9 KiB
JavaScript
117 lines
3.9 KiB
JavaScript
|
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();
|
||
|
}
|
||
|
}
|