update annotations export dialog
This commit is contained in:
parent
32733bdefa
commit
dd6ee74b71
1 changed files with 48 additions and 28 deletions
|
@ -34,6 +34,8 @@ pandora.ui.exportAnnotationsDialog = function(options) {
|
|||
change: function() {
|
||||
updateStatus();
|
||||
that.enableButton('export');
|
||||
!$link && addLink();
|
||||
updateLink();
|
||||
}
|
||||
})
|
||||
.appendTo($content),
|
||||
|
@ -44,6 +46,8 @@ pandora.ui.exportAnnotationsDialog = function(options) {
|
|||
})
|
||||
.appendTo($content),
|
||||
|
||||
$link,
|
||||
|
||||
that = Ox.Dialog({
|
||||
buttons: [
|
||||
Ox.Button({
|
||||
|
@ -60,9 +64,6 @@ pandora.ui.exportAnnotationsDialog = function(options) {
|
|||
id: 'export',
|
||||
title: Ox._('Export')
|
||||
})
|
||||
.bindEvent({
|
||||
click: exportAnnotations
|
||||
})
|
||||
],
|
||||
closeButton: true,
|
||||
content: $content,
|
||||
|
@ -75,19 +76,38 @@ pandora.ui.exportAnnotationsDialog = function(options) {
|
|||
|
||||
updateStatus();
|
||||
|
||||
function exportAnnotations() {
|
||||
Ox.print(
|
||||
Ox.formatSRT(annotations[$layerSelect.value()].map(function(annotation) {
|
||||
if (enabledLayers.length) {
|
||||
addLink();
|
||||
updateLink();
|
||||
}
|
||||
|
||||
function addLink() {
|
||||
var layer = $layerSelect.value();
|
||||
$link = $('<a>').attr({
|
||||
target: '_blank'
|
||||
});
|
||||
updateLink();
|
||||
$(that.find('.OxButton')[3]).wrap($link);
|
||||
}
|
||||
|
||||
function updateLink() {
|
||||
var layer = $layerSelect.value();
|
||||
$link.attr({
|
||||
download: options.title + ' - '
|
||||
+ Ox.getObjectById(layers, layer).title + '.srt',
|
||||
href: 'data:text/plain;base64,' + btoa(
|
||||
Ox.formatSRT(annotations[layer].map(function(annotation) {
|
||||
return {
|
||||
'in': annotation['in'],
|
||||
out: annotation.out,
|
||||
text: annotation.value
|
||||
.replace(/\n/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.replace(/<br>/g, '\n')
|
||||
.replace(/<br>\s+?/g, '\n')
|
||||
};
|
||||
}))
|
||||
);
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function updateStatus() {
|
||||
|
|
Loading…
Reference in a new issue