forked from 0x2620/pandora
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() {
|
change: function() {
|
||||||
updateStatus();
|
updateStatus();
|
||||||
that.enableButton('export');
|
that.enableButton('export');
|
||||||
|
!$link && addLink();
|
||||||
|
updateLink();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.appendTo($content),
|
.appendTo($content),
|
||||||
|
@ -44,6 +46,8 @@ pandora.ui.exportAnnotationsDialog = function(options) {
|
||||||
})
|
})
|
||||||
.appendTo($content),
|
.appendTo($content),
|
||||||
|
|
||||||
|
$link,
|
||||||
|
|
||||||
that = Ox.Dialog({
|
that = Ox.Dialog({
|
||||||
buttons: [
|
buttons: [
|
||||||
Ox.Button({
|
Ox.Button({
|
||||||
|
@ -60,9 +64,6 @@ pandora.ui.exportAnnotationsDialog = function(options) {
|
||||||
id: 'export',
|
id: 'export',
|
||||||
title: Ox._('Export')
|
title: Ox._('Export')
|
||||||
})
|
})
|
||||||
.bindEvent({
|
|
||||||
click: exportAnnotations
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
closeButton: true,
|
closeButton: true,
|
||||||
content: $content,
|
content: $content,
|
||||||
|
@ -75,19 +76,38 @@ pandora.ui.exportAnnotationsDialog = function(options) {
|
||||||
|
|
||||||
updateStatus();
|
updateStatus();
|
||||||
|
|
||||||
function exportAnnotations() {
|
if (enabledLayers.length) {
|
||||||
Ox.print(
|
addLink();
|
||||||
Ox.formatSRT(annotations[$layerSelect.value()].map(function(annotation) {
|
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 {
|
return {
|
||||||
'in': annotation['in'],
|
'in': annotation['in'],
|
||||||
out: annotation.out,
|
out: annotation.out,
|
||||||
text: annotation.value
|
text: annotation.value
|
||||||
.replace(/\n/g, ' ')
|
.replace(/\n/g, ' ')
|
||||||
.replace(/\s+/g, ' ')
|
.replace(/\s+/g, ' ')
|
||||||
.replace(/<br>/g, '\n')
|
.replace(/<br>\s+?/g, '\n')
|
||||||
};
|
};
|
||||||
}))
|
}))
|
||||||
);
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStatus() {
|
function updateStatus() {
|
||||||
|
|
Loading…
Reference in a new issue