diff --git a/static/js/uploadVideoDialog.js b/static/js/uploadVideoDialog.js deleted file mode 100644 index cb455a67..00000000 --- a/static/js/uploadVideoDialog.js +++ /dev/null @@ -1,599 +0,0 @@ -'use strict'; - -pandora.ui.uploadVideoDialog = function(data) { - - var cancelled = false, - file, - hasFirefogg = !(Ox.isUndefined(window.Firefogg)) && ( - $.browser.version < '35' || Firefogg().version >= 334 - ), - infoContent = Ox._('Please select the video file that you want to upload.'), - itemView = pandora.hasCapability('canSeeExtraItemViews') ? 'media' : 'info', - selectFile, - $actionButton, - $closeButton, - $content = Ox.Element().css({margin: '16px'}), - $info = $('
') - .css({padding: '4px'}) - .html(infoContent), - $progress, - $status = $('
').css({padding: '4px', paddingTop: '8px'}), - that = Ox.Dialog({ - buttons: [ - $closeButton = Ox.Button({ - id: 'close', - title: Ox._('Close') - }).css({ - float: 'left' - }).bindEvent({ - click: function() { - if ($closeButton.options('title') == Ox._('Cancel')) { - cancelled = true; - $info.html(infoContent); - $status.html(''); - pandora.firefogg && pandora.firefogg.cancel(); - pandora.$ui.upload && pandora.$ui.upload.abort(); - $closeButton.options('title', Ox._('Close')); - if ($actionButton.options('title') == Ox._('Upload')) { - $closeButton.options('title', Ox._('Close')); - $actionButton.replaceWith($actionButton = hasFirefogg - ? getFirefoggButton() - : getSelectVideoButton() - ); - } - $actionButton.show(); - } else { - that.triggerEvent('close'); - } - } - }), - $actionButton = hasFirefogg ? getFirefoggButton() : getSelectVideoButton() - ], - content: $content, - height: 128, - removeOnClose: true, - width: 368, - title: Ox._('Upload Video'), - }) - .bindEvent({ - close: function(data) { - if (pandora.firefogg) { - pandora.firefogg.cancel(); - delete pandora.firefogg; - } - that.close(); - } - }); - - if (!pandora.site.itemRequiresVideo && !pandora.user.ui.item) { - $info.html(Ox._( - 'You can only upload a video to an existing {0}.' - + ' Please check if an entry for the {0}' - + ' you want to upload exists, and create one otherwise.', - [pandora.site.itemName.singular.toLowerCase()] - )); - $actionButton.hide(); - } - $content.append($info); - $content.append($status); - - function aspectratio(ratio) { - var denominator, numerator; - ratio = ratio.split(':'); - numerator = ratio[0]; - if (ratio.length == 2) { - denominator = ratio[1]; - } - if (Math.abs(numerator / denominator - 4/3) < 0.03) { - numerator = 4; - denominator = 3; - } else if (Math.abs(numerator / denominator - 16/9) < 0.02) { - numerator = 16; - denominator = 9; - } - return { - denominator: denominator, - 'float': numerator / denominator, - numerator: numerator, - ratio: numerator + ':' + denominator - }; - } - - function resetProgress(status) { - $progress = Ox.Progressbar({ - progress: 0, - showPercent: true, - showTime: true, - width: 304 - }); - $status.html(status || '').append($progress); - } - - function directUpload(file, info) { - resetProgress(); - pandora.api.addMedia({ - filename: info.name, - id: info.oshash, - item: pandora.site.itemRequiresVideo - ? undefined - : pandora.user.ui.item - }, function(result) { - uploadStream(result.data.item, info, file); - }); - } - - function encode() { - var filename = pandora.firefogg.sourceFilename, - info = JSON.parse(pandora.firefogg.sourceInfo), - item, - oshash = info.oshash; - $info.html('' + filename + '
' + Ox._('encoding...')); - resetProgress(); - pandora.api.addMedia({ - filename: filename, - id: oshash, - info: info, - item: pandora.site.itemRequiresVideo - ? undefined - : pandora.user.ui.item - }, function(result) { - item = result.data.item; - pandora.firefogg.encode( - getEncodingOptions(info), - function(result, file) { - result = JSON.parse(result); - if (result.progress != 1) { - $status.html( - cancelled - ? Ox._('Encoding cancelled.') - : Ox._('Encoding failed.') - ); - delete pandora.firefogg; - return; - } - setTimeout(function() { - $info.html( - '' + filename + '
' - + Ox._('uploading...') - ); - uploadStream(item, info, file); - }); - }, - Ox.throttle(function(progress) { - progress = JSON.parse(progress).progress || 0; - $progress.options({progress: progress}); - }, 1000) - ); - }); - } - - function getInfo(file, callback) { - Ox.oshash(file, function(oshash) { - var $video = $('