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

View file

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

View file

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

View file

@ -2,6 +2,7 @@
'use strict';
pandora.ui.embedDialog = function(data) {
var content = Ox.Element().css({margin: '16px'}),
height = 360,
width = 640,
@ -33,36 +34,41 @@ pandora.ui.embedDialog = function(data) {
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
+ '//' + document.location.host
+ '/' + pandora.user.ui.item + '/embed?',
query = [];
Ox.forEach(data, function(value, key) {
if(key[0] != '_') {
query.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
if (key[0] != '_') {
query.push(
encodeURIComponent(key) + '=' + encodeURIComponent(value)
);
}
});
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;
};

View file

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

View file

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

View file

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

View file

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

View file

@ -426,7 +426,7 @@ pandora.ui.infoView = function(data) {
.css(css)
)
.appendTo($center);
} else if(data.summary) {
} else if (data.summary) {
$('<div>').css(css).html(data.summary).appendTo($center);
}
@ -449,7 +449,7 @@ pandora.ui.infoView = function(data) {
}
})
.appendTo($div);
} else if(data.license) {
} else if (data.license) {
$div.html(
formatKey('License')
+ (data.license || []).join(', ')
@ -598,11 +598,11 @@ pandora.ui.infoView = function(data) {
}
function formatValue(value, key) {
if(key == 'date') {
if (key == 'date') {
return value ? Ox.formatDate(value,
['', '%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 (Ox.isArray(value) ? value : [value]).map(function(value) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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