2013-03-05 11:50:51 +00:00
|
|
|
pandora.ui.openSRTDialog = function() {
|
2014-01-22 13:56:04 +00:00
|
|
|
var $layerName = Ox.Input({
|
|
|
|
'label': 'Layer name'
|
|
|
|
});
|
|
|
|
var $fileInput = Ox.FileInput({
|
|
|
|
maxFiles: 1,
|
|
|
|
label: 'Select SRT File'
|
|
|
|
}).bindEvent("change", function() {
|
|
|
|
var fil = this.value()[0];
|
|
|
|
//console.log(fil);
|
|
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function() {
|
|
|
|
var txt = reader.result;
|
|
|
|
pandora.$ui.textArea.speedtrans.fromSrt(txt);
|
|
|
|
var title = pandora.utils.getUntitledName(fil.name);
|
|
|
|
var storage = pandora.storage(pandora.$ui.textArea.storage);
|
|
|
|
storage[title] = txt;
|
|
|
|
pandora.$ui.textArea.currentTrack = title;
|
|
|
|
pandora.$ui.selectAnnotationType.value(title);
|
|
|
|
//var layers = pandora.$ui.textArea.speedtrans.getLayers();
|
|
|
|
pandora.$ui.annotationsPanel.addLayer({
|
|
|
|
'id': title,
|
|
|
|
'title': title,
|
|
|
|
'items': pandora.$ui.textArea.speedtrans.toSrt('layers', txt)
|
|
|
|
});
|
|
|
|
pandora.utils.updateFolderMenus();
|
|
|
|
//console.log(reader.result);
|
|
|
|
};
|
|
|
|
reader.readAsText(fil);
|
|
|
|
});
|
2013-03-05 11:50:51 +00:00
|
|
|
var $textInput = Ox.Input({
|
|
|
|
'type': 'textarea',
|
|
|
|
'label': 'Paste SRT',
|
|
|
|
'id': 'srtText',
|
|
|
|
'labelWidth': 150,
|
|
|
|
'width': 500,
|
2014-01-22 13:56:04 +00:00
|
|
|
'height': 400
|
2013-03-05 11:50:51 +00:00
|
|
|
});
|
2014-01-22 13:56:04 +00:00
|
|
|
var $content = Ox.Element().append($layerName).append($fileInput).append($textInput);
|
2013-03-05 11:50:51 +00:00
|
|
|
var that = Ox.Dialog({
|
|
|
|
'content': $content,
|
|
|
|
'closeButton': true,
|
2014-01-22 13:56:04 +00:00
|
|
|
'width': 600,
|
|
|
|
'height': 450,
|
2013-03-05 11:50:51 +00:00
|
|
|
'buttons': [
|
|
|
|
Ox.Button({
|
|
|
|
'group': true,
|
|
|
|
'id': 'loadSRTButton',
|
|
|
|
'title': 'Load SRT'
|
|
|
|
}).bindEvent("click", function() {
|
|
|
|
var txt = $textInput.value();
|
|
|
|
pandora.$ui.textArea.speedtrans.fromSrt(txt);
|
|
|
|
that.close();
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
return that;
|
|
|
|
};
|