This commit is contained in:
rolux 2012-06-10 20:31:02 +02:00
parent 41cd72d37e
commit 453f83e067
15 changed files with 108 additions and 93 deletions

View file

@ -26,9 +26,10 @@ var app = new Ox.App({
app.api.api({docs: true, code: true}, function(results) { app.api.api({docs: true, code: true}, function(results) {
app.actions = results.data.actions; app.actions = results.data.actions;
if (document.location.hash) {
if(document.location.hash) { app.$ui.actionList.triggerEvent('select', {
app.$ui.actionList.triggerEvent('select', {ids: document.location.hash.substring(1).split(',')}); ids: document.location.hash.substring(1).split(',')
});
} }
}); });
@ -84,11 +85,7 @@ function constructList() {
id: 'actionList', id: 'actionList',
items: function(data, callback) { items: function(data, callback) {
function _sort(a, b) { function _sort(a, b) {
if(a.name > b.name) return a.name > b.name ? 1 : a.name == b.name ? 0 : -1;
return 1;
else if(a.name == b.name)
return 0;
return -1;
} }
if (!data.keys) { if (!data.keys) {
app.api.api(function(results) { app.api.api(function(results) {
@ -123,10 +120,10 @@ function constructList() {
select: function(data) { select: function(data) {
var info = $('<div>').addClass('OxSelectable'), var info = $('<div>').addClass('OxSelectable'),
hash = '#'; hash = '#';
if(data.ids.length) if (data.ids.length)
data.ids.forEach(function(id) { data.ids.forEach(function(id) {
info.append( info.append(
$("<h2>") $('<h2>')
.html(id) .html(id)
.css({ .css({
marginBottom: '8px' marginBottom: '8px'

View file

@ -57,9 +57,11 @@ Ox.load('UI', {
Ox.UI.hideLoadingScreen(); Ox.UI.hideLoadingScreen();
function checkRange(data) { function checkRange(data) {
if(data.position < options['in'] - 0.04 if (
|| data.position > options.out) { data.position < options['in'] - 0.04
if(!pandora.player.options('paused')) { || data.position > options.out
) {
if (!pandora.player.options('paused')) {
pandora.player.togglePaused(); pandora.player.togglePaused();
} }
pandora.player.options({ pandora.player.options({

View file

@ -320,12 +320,12 @@ appPanel
}); });
pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8; pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8;
if(localStorage && localStorage['pandora.onload']) { if (localStorage && localStorage['pandora.onload']) {
try { try {
eval(localStorage['pandora.onload']) eval(localStorage['pandora.onload'])
} catch(e) { } catch(e) {}
}
} }
}); });
} }

View file

@ -2,6 +2,7 @@
'use strict'; 'use strict';
pandora.ui.embedDialog = function(data) { pandora.ui.embedDialog = function(data) {
var content = Ox.Element().css({margin: '16px'}), var content = Ox.Element().css({margin: '16px'}),
height = 360, height = 360,
width = 640, width = 640,
@ -33,36 +34,41 @@ pandora.ui.embedDialog = function(data) {
data.view = 'video'; data.view = 'video';
function constructUrl(data) { content.html('To embed this video use this code on your page:<br>');
content.append(
$('<textarea>')
.css({
width: '520px',
margin: '16px',
height: '100%'
}).val(
'<iframe width="' + width
+ '" height="' + height
+ '" src="' + constructURL(data)
+ '" frameborder="0" allowfullscreen></iframe>'
).on({
click: function() {
this.focus();
this.select();
}
})
);
function constructURL(data) {
var url = document.location.protocol var url = document.location.protocol
+ '//' + document.location.host + '//' + document.location.host
+ '/' + pandora.user.ui.item + '/embed?', + '/' + pandora.user.ui.item + '/embed?',
query = []; query = [];
Ox.forEach(data, function(value, key) { Ox.forEach(data, function(value, key) {
if(key[0] != '_') { if (key[0] != '_') {
query.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); query.push(
encodeURIComponent(key) + '=' + encodeURIComponent(value)
);
} }
}); });
return url + query.join('&'); return url + query.join('&');
} }
content.html('To embed this video use this code on your page:<br>');
content.append(
$('<textarea>')
.css({
width: '520px',
margin: '16px',
height: '100%'
}).val(
'<iframe width="' + width
+ '" height="' + height
+ '" src="' + constructUrl(data)
+ '" frameborder="0" allowfullscreen></iframe>'
).on({
click: function() {
this.focus();
this.select();
}
})
);
return that; return that;
}; };

View file

@ -219,8 +219,7 @@ pandora.ui.filesView = function(options, self) {
var ids = data.ids.filter(function(id) { var ids = data.ids.filter(function(id) {
return self.$filesList.value(id, 'instances').length == 0; return self.$filesList.value(id, 'instances').length == 0;
}); });
if(ids.length>0 && pandora.user.level == 'admin') { if (ids.length > 0 && pandora.user.level == 'admin') {
Ox.print('delete', ids);
pandora.api.removeFiles({ pandora.api.removeFiles({
ids: ids ids: ids
}, function(result) { }, function(result) {
@ -439,7 +438,10 @@ pandora.ui.filesView = function(options, self) {
data[key] = self['$' + key + 'Input'].value(); data[key] = self['$' + key + 'Input'].value();
}); });
pandora.api.moveFiles(data, function(result) { pandora.api.moveFiles(data, function(result) {
if(pandora.user.ui.item == self.options.id && pandora.user.ui.itemView == 'files') { if (
pandora.user.ui.item == self.options.id
&& pandora.user.ui.itemView == 'files'
) {
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
if (self.$checkbox.value()) { if (self.$checkbox.value()) {
pandora.UI.set({item: result.data.itemId}); pandora.UI.set({item: result.data.itemId});

View file

@ -58,15 +58,16 @@ pandora.ui.importAnnotations = function(data) {
}); });
function addAnnotation() { function addAnnotation() {
if(srt.length>0) { if (srt.length > 0) {
var data = srt.shift(); var data = srt.shift();
data.text = Ox.sanitizeHTML(data.text) data.text = Ox.sanitizeHTML(data.text)
.replace(/<br[ /]*?>\n/g, '\n') .replace(/<br[ /]*?>\n/g, '\n')
.replace(/\n\n/g, '<br>\n') .replace(/\n\n/g, '<br>\n')
.replace(/\n/g, '<br>\n'); .replace(/\n/g, '<br>\n');
$status.html(Ox.formatDuration(data['in']) $status.html(
+ ' to ' + Ox.formatDuration(data.out) + '<br>\n' Ox.formatDuration(data['in']) + ' to '
+ data.text); + Ox.formatDuration(data.out) + '<br>\n' + data.text
);
pandora.api.addAnnotation({ pandora.api.addAnnotation({
'in': data['in'], 'in': data['in'],
out: data.out, out: data.out,
@ -113,18 +114,17 @@ pandora.ui.importAnnotations = function(data) {
}) })
.on({ .on({
change: function(event) { change: function(event) {
if(this.files.length) { if (this.files.length) {
file = this.files[0]; file = this.files[0];
var reader = new FileReader(); var reader = new FileReader();
reader.onloadend = function(event) { reader.onloadend = function(event) {
srt = Ox.parseSRT(this.result); srt = Ox.parseSRT(this.result);
total = srt.length; total = srt.length;
if(total) { total && importButton.options({disabled: false});
importButton.options({ $status.html(
disabled: false 'File contains ' + total + ' annotation'
}); + (total == 1 ? '' : 's') + '.'
} );
$status.html('File contains '+ total + ' annotations.');
}; };
reader.readAsText(file); reader.readAsText(file);
} else { } else {

View file

@ -508,7 +508,7 @@ pandora.ui.infoView = function(data) {
var edit = {id: data.id}; var edit = {id: data.id};
if (key == 'title') { if (key == 'title') {
Ox.extend(edit, parseTitle(value)); Ox.extend(edit, parseTitle(value));
} else if(['director', 'country'].indexOf(key) > -1) { } else if (['director', 'country'].indexOf(key) > -1) {
edit[key] = value ? value.split(', ') : []; edit[key] = value ? value.split(', ') : [];
} else { } else {
edit[key] = value; edit[key] = value;

View file

@ -375,7 +375,7 @@ pandora.ui.infoView = function(data) {
.css(css) .css(css)
) )
.appendTo($center); .appendTo($center);
} else if(data.summary) { } else if (data.summary) {
$('<div>').css(css).html(data.summary).appendTo($center); $('<div>').css(css).html(data.summary).appendTo($center);
} }
@ -398,7 +398,7 @@ pandora.ui.infoView = function(data) {
} }
}) })
.appendTo($div); .appendTo($div);
} else if(data.license) { } else if (data.license) {
$div.html( $div.html(
formatKey('License') formatKey('License')
+ (data.license || []).join(', ') + (data.license || []).join(', ')
@ -547,12 +547,13 @@ pandora.ui.infoView = function(data) {
} }
function formatValue(value, key) { function formatValue(value, key) {
if(key == 'date') { if (key == 'date') {
return value ? Ox.formatDate(value, return value ? Ox.formatDate(value,
['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length] ['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length]
) : ''; ) : '';
} else if(key == 'duration') { } else if (key == 'duration') {
return value < 60 ? Math.round(value) + ' sec' : Math.round(value / 60) + ' min'; return value < 60 ? Math.round(value) + ' sec'
: Math.round(value / 60) + ' min';
} }
return (Ox.isArray(value) ? value : [value]).map(function(value) { return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ? return key ?

View file

@ -426,7 +426,7 @@ pandora.ui.infoView = function(data) {
.css(css) .css(css)
) )
.appendTo($center); .appendTo($center);
} else if(data.summary) { } else if (data.summary) {
$('<div>').css(css).html(data.summary).appendTo($center); $('<div>').css(css).html(data.summary).appendTo($center);
} }
@ -449,7 +449,7 @@ pandora.ui.infoView = function(data) {
} }
}) })
.appendTo($div); .appendTo($div);
} else if(data.license) { } else if (data.license) {
$div.html( $div.html(
formatKey('License') formatKey('License')
+ (data.license || []).join(', ') + (data.license || []).join(', ')
@ -598,11 +598,11 @@ pandora.ui.infoView = function(data) {
} }
function formatValue(value, key) { function formatValue(value, key) {
if(key == 'date') { if (key == 'date') {
return value ? Ox.formatDate(value, return value ? Ox.formatDate(value,
['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length] ['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length]
) : ''; ) : '';
} else if(key == 'duration') { } else if (key == 'duration') {
return value < 60 ? Math.round(value) + ' sec' : Math.round(value / 60) + ' min'; return value < 60 ? Math.round(value) + ' sec' : Math.round(value / 60) + ' min';
} }
return (Ox.isArray(value) ? value : [value]).map(function(value) { return (Ox.isArray(value) ? value : [value]).map(function(value) {

View file

@ -332,7 +332,7 @@ pandora.ui.mainMenu = function() {
pandora.$ui.appPanel.reload(); pandora.$ui.appPanel.reload();
}); });
} else if (data.id == 'debug') { } else if (data.id == 'debug') {
if(pandora.localStorage('debug')) { if (pandora.localStorage('debug')) {
pandora.localStorage['delete']('debug'); pandora.localStorage['delete']('debug');
} else { } else {
pandora.localStorage('debug', true); pandora.localStorage('debug', true);

View file

@ -18,7 +18,7 @@ pandora.ui.news = function(width, height) {
pandora.api.getNews({}, function(result) { pandora.api.getNews({}, function(result) {
items = result.data.items; items = result.data.items;
if(items.length) { if (items.length) {
selected = items[0].id; selected = items[0].id;
renderItem(); renderItem();
renderList(); renderList();

View file

@ -71,7 +71,7 @@ pandora.ui.onloadDialog = function() {
that.superClose = that.close; that.superClose = that.close;
that.close = function() { that.close = function() {
var value = $text.value(); var value = $text.value();
if(value) { if (value) {
localStorage['pandora.onload'] = value; localStorage['pandora.onload'] = value;
} else { } else {
delete localStorage['pandora.onload']; delete localStorage['pandora.onload'];

View file

@ -21,7 +21,7 @@ pandora.tests = function() {
test('set item', pandora.user.ui.item, item.id); test('set item', pandora.user.ui.item, item.id);
startPlayback(); startPlayback();
function startPlayback() { function startPlayback() {
if(pandora.$ui.player) { if (pandora.$ui.player) {
pandora.$ui.player.options({paused: false}); pandora.$ui.player.options({paused: false});
setTimeout(function() { setTimeout(function() {
pandora.$ui.player.options({paused: true}); pandora.$ui.player.options({paused: true});

View file

@ -88,9 +88,9 @@ pandora.ui.upload = function(oshash, file) {
chunk, chunk,
chunkOffset = chunkId * chunkSize; chunkOffset = chunkId * chunkSize;
if(file.mozSlice) { if (file.mozSlice) {
chunk = file.mozSlice(chunkOffset, chunkOffset+chunkSize, file.type); chunk = file.mozSlice(chunkOffset, chunkOffset+chunkSize, file.type);
} else if(file.webkitSlice) { } else if (file.webkitSlice) {
chunk = file.webkitSlice(chunkOffset, chunkOffset+chunkSize, file.type); chunk = file.webkitSlice(chunkOffset, chunkOffset+chunkSize, file.type);
} }

View file

@ -3,7 +3,7 @@
pandora.ui.uploadDialog = function(data) { pandora.ui.uploadDialog = function(data) {
var content = Ox.Element().css({margin: '16px'}), var content = Ox.Element().css({margin: '16px'}),
canceled = false, cancelled = false,
file, file,
closeButton, closeButton,
actionButton, actionButton,
@ -23,14 +23,14 @@ pandora.ui.uploadDialog = function(data) {
title: 'Select Video' title: 'Select Video'
}).bindEvent({ }).bindEvent({
click: function() { click: function() {
if(actionButton.options('title') == 'Select Video') { if (actionButton.options('title') == 'Select Video') {
if(selectVideo()) { if (selectVideo()) {
actionButton.options('title', 'Upload'); actionButton.options('title', 'Upload');
} }
} else if(actionButton.options('title') == 'Close') { } else if (actionButton.options('title') == 'Close') {
that.close(); that.close();
} else if(actionButton.options('title') == 'Cancel') { } else if (actionButton.options('title') == 'Cancel') {
canceled = true; cancelled = true;
pandora.firefogg && pandora.firefogg.cancel(); pandora.firefogg && pandora.firefogg.cancel();
pandora.$ui.upload && pandora.$ui.upload.abort(); pandora.$ui.upload && pandora.$ui.upload.abort();
actionButton.options('title', 'Select Video'); actionButton.options('title', 'Select Video');
@ -70,7 +70,7 @@ pandora.ui.uploadDialog = function(data) {
pandora._status = $status; pandora._status = $status;
pandora._info = $info; pandora._info = $info;
if(typeof(Firefogg) == 'undefined') { if (typeof(Firefogg) == 'undefined') {
/* /*
selectFile = $('<input>') selectFile = $('<input>')
.attr({ .attr({
@ -81,9 +81,9 @@ pandora.ui.uploadDialog = function(data) {
}) })
.on({ .on({
change: function(event) { change: function(event) {
if(this.files.length) { if (this.files.length) {
file = this.files[0]; file = this.files[0];
if(file.type == 'video/webm') { if (file.type == 'video/webm') {
$status.html(''); $status.html('');
uploadButton.options({ uploadButton.options({
disabled: false disabled: false
@ -122,7 +122,7 @@ pandora.ui.uploadDialog = function(data) {
denominator; denominator;
ratio = ratio.split(':'); ratio = ratio.split(':');
numerator = ratio[0]; numerator = ratio[0];
if(ratio.length == 2) { if (ratio.length == 2) {
denominator = ratio[1]; denominator = ratio[1];
} }
if (Math.abs(numerator/denominator - 4/3) < 0.03) { if (Math.abs(numerator/denominator - 4/3) < 0.03) {
@ -166,8 +166,8 @@ pandora.ui.uploadDialog = function(data) {
function(result, file) { function(result, file) {
result = JSON.parse(result); result = JSON.parse(result);
if (result.progress != 1) { if (result.progress != 1) {
if(canceled) { if (cancelled) {
$status.html('Encoding canceled.'); $status.html('Encoding cancelled.');
} else { } else {
$status.html('Encoding failed.'); $status.html('Encoding failed.');
} }
@ -209,7 +209,7 @@ pandora.ui.uploadDialog = function(data) {
dar, dar,
options = {}; options = {};
if(format == 'webm') { if (format == 'webm') {
options.videoCodec = 'vp8'; options.videoCodec = 'vp8';
options.audioCodec = 'vorbis'; options.audioCodec = 'vorbis';
} else if (format == 'ogv') { } else if (format == 'ogv') {
@ -296,12 +296,14 @@ pandora.ui.uploadDialog = function(data) {
options.noUpscaling = true; options.noUpscaling = true;
if((!info.video.length || (info.video[0].codec == options.videoCodec if (
&& info.video[0].height <= options.height)) (!info.video.length || (
&& (!info.audio.length || info.audio[0].codec == options.audioCodec)) { info.video[0].codec == options.videoCodec
options = { && info.video[0].height <= options.height
passthrough: true ))
}; && (!info.audio.length || info.audio[0].codec == options.audioCodec)
) {
options = {passthrough: true};
} }
return JSON.stringify(options); return JSON.stringify(options);
} }
@ -310,14 +312,17 @@ pandora.ui.uploadDialog = function(data) {
var html = ''; var html = '';
html += '<b>' + info.path + '</b>'; html += '<b>' + info.path + '</b>';
html += '<br />'; html += '<br />';
if(info.video && info.video.length>0) { if (info.video && info.video.length > 0) {
var video = info.video[0]; var video = info.video[0];
html += video.width + 'x' + video.height + ' (' + video.codec + ')'; html += video.width + 'x' + video.height + ' (' + video.codec + ')';
} }
if(info.video && info.video.length>0 && info.audio && info.audio.length>0) { if (
info.video && info.video.length > 0
&& info.audio && info.audio.length > 0
) {
html += ' / '; html += ' / ';
} }
if(info.audio && info.audio.length>0) { if (info.audio && info.audio.length > 0) {
var audio= info.audio[0]; var audio= info.audio[0];
html += '' + { html += '' + {
1: 'mono', 1: 'mono',
@ -335,10 +340,10 @@ pandora.ui.uploadDialog = function(data) {
} }
function selectVideo() { function selectVideo() {
canceled = false; cancelled = false;
pandora.firefogg = new Firefogg(); pandora.firefogg = new Firefogg();
pandora.firefogg.setFormat(pandora.site.video.formats[0]); pandora.firefogg.setFormat(pandora.site.video.formats[0]);
if(pandora.firefogg.selectVideo()) { if (pandora.firefogg.selectVideo()) {
var info = JSON.parse(pandora.firefogg.sourceInfo), var info = JSON.parse(pandora.firefogg.sourceInfo),
options = JSON.parse(getEncodingOptions(info)), options = JSON.parse(getEncodingOptions(info)),
oshash = info.oshash, oshash = info.oshash,
@ -350,7 +355,9 @@ pandora.ui.uploadDialog = function(data) {
}, },
keys: ['id', 'available'] keys: ['id', 'available']
}, function(result) { }, function(result) {
if(result.data.items.length === 0 || !result.data.items[0].available) { if (
result.data.items.length === 0 || !result.data.items[0].available
) {
$info.html(formatInfo(info)); $info.html(formatInfo(info));
$status.html( $status.html(
options.passthrough options.passthrough