pandora.ui.openSRTDialog = function() { 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); }); var $textInput = Ox.Input({ 'type': 'textarea', 'label': 'Paste SRT', 'id': 'srtText', 'labelWidth': 150, 'width': 500, 'height': 400 }); var $content = Ox.Element().append($layerName).append($fileInput).append($textInput); var that = Ox.Dialog({ 'content': $content, 'closeButton': true, 'width': 600, 'height': 450, '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; };