108 lines
3.4 KiB
JavaScript
108 lines
3.4 KiB
JavaScript
//open User->Preferences->Advanced->Run Script on Load and paste this script
|
|
|
|
(function() {
|
|
playlist([
|
|
[function() { info('A'); }, 30.000],
|
|
[function() { play('B', 3); }, 10],
|
|
]);
|
|
|
|
//helper functions
|
|
function playlist(playlist) {
|
|
var current = 0;
|
|
pandora.$ui.home && pandora.$ui.home.fadeOutScreen();
|
|
clearTimeout(pandora.playlist);
|
|
next();
|
|
function next() {
|
|
if(current >= playlist.length) {
|
|
window.location.reload();
|
|
current = 0;
|
|
} else {
|
|
playlist[current][0]();
|
|
clearTimeout(pandora.playlist);
|
|
|
|
var duration = playlist[current][1];
|
|
if(Ox.isString(duration)) {
|
|
duration = Ox.parseDuration(duration);
|
|
}
|
|
pandora.playlist = setTimeout(next, Math.round(duration * 1000));
|
|
current += 1;
|
|
}
|
|
}
|
|
}
|
|
function sitePage(page) {
|
|
//if there is a player, pause it
|
|
pandora.$ui.player && pandora.$ui.player.options('paused', true);
|
|
//back to results view
|
|
pandora.UI.set({item: ''});
|
|
//open about page
|
|
pandora.UI.set({page: page});
|
|
}
|
|
function editor(item, start) {
|
|
playItem(item, 'editor', start);
|
|
}
|
|
function info(item) {
|
|
pandora.UI.set({page: ''});
|
|
pandora.UI.set({itemView: 'info'});
|
|
pandora.UI.set({item: item});
|
|
}
|
|
function play(item, position, layers) {
|
|
playItem(item, 'player', position, layers);
|
|
}
|
|
|
|
function timeline(item, position, layers) {
|
|
playItem(item, 'player', position, layers);
|
|
}
|
|
|
|
function playItem(item, view, position, layers) {
|
|
showLayers(layers);
|
|
position = position || 0;
|
|
if(Ox.isString(position)) {
|
|
position = Ox.parseDuration(position);
|
|
}
|
|
pandora.UI.set({page: ''});
|
|
pandora.UI.set('videoPoints.' + item, {
|
|
'annotation': '',
|
|
'in': position,
|
|
out: position,
|
|
position: position
|
|
});
|
|
if(item != pandora.user.ui.item || pandora.user.ui.itemView != view) {
|
|
delete pandora.$ui[view];
|
|
pandora.UI.set({itemView: view});
|
|
pandora.UI.set({item: item});
|
|
}
|
|
startPlayback();
|
|
function startPlayback() {
|
|
if(pandora.$ui[view]) {
|
|
pandora.$ui[view].options({paused: false});
|
|
} else {
|
|
setTimeout(startPlayback, 500);
|
|
}
|
|
}
|
|
}
|
|
function find(query, view) {
|
|
view = view || 'grid';
|
|
pandora.UI.set({item: '', page: '', listView: view});
|
|
pandora.$ui.findInput.value(query);
|
|
pandora.UI.set({find: {conditions: [{key: '*', value: query, operator: '='}], operator: '&'}});
|
|
}
|
|
|
|
function showLayers(layers) {
|
|
layers = layers || Object.keys(pandora.site.user.ui.showLayers).filter(function(layer) {
|
|
return pandora.site.user.ui.showLayers[layer];
|
|
});
|
|
pandora.UI.set('showLayers', Ox.map(pandora.site.user.ui.showLayers, function(value, layer) {
|
|
return layers.indexOf(layer) > -1;
|
|
}));
|
|
}
|
|
|
|
function openDocument(id) {
|
|
//if there is a player, pause it
|
|
pandora.$ui.player && pandora.$ui.player.options('paused', true);
|
|
pandora.URL.push('/documents/' + id);
|
|
}
|
|
|
|
function closeDocument() {
|
|
pandora.$ui.documentDialog.close();
|
|
}
|
|
})();
|