some fixes for persistent playlists

This commit is contained in:
Robin Appelman 2011-08-01 01:56:45 +02:00
parent 9b764cb7f4
commit ef22498c6f
5 changed files with 16 additions and 13 deletions

View File

@ -51,7 +51,7 @@ $(document).ready(function() {
}
if(typeof PlayList==='undefined'){
if(typeof localStorage !== 'undefined'){
if(localStorage.hasOwnProperty('oc_playlist_items')){
if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items')){
loadPlayer();
}
}

View File

@ -13,9 +13,11 @@ $(document).ready(function(){
Collection.hide();
});
var tab=window.location.href.slice(window.location.href.indexOf('#') + 1);
if(tab=='collection'){
$('#plugins a[href="#collection"]').trigger('click');
}
PlayList.init('mp3',function(){
if(tab=='collection'){
$('#plugins a[href="#collection"]').trigger('click');
}
});
OC.search.customResults.Music=function(row,item){
var parts=item.link.substr(item.link.indexOf('#')+1).split('&');
var data={};
@ -41,7 +43,6 @@ $(document).ready(function(){
});
row.find('div.name').append(button);
}
PlayList.init();
});

View File

@ -33,9 +33,9 @@ var PlayList={
PlayList.player.jPlayer("setMedia", PlayList.items[PlayList.current]);
PlayList.items[index].playcount++;
PlayList.player.jPlayer("play");
localStorage.setItem('oc_playlist_current',index);
localStorage.setItem('oc_playlist_playing','true');
if(index>=0){
localStorage.setItem(oc_current_user+'oc_playlist_current',index);
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
if(index>0){
var previous=index-1;
}else{
var previous=PlayList.items.length-1;
@ -135,15 +135,15 @@ var PlayList={
},
save:function(){
if(typeof localStorage !== 'undefined'){
localStorage.setItem('oc_playlist_items',JSON.stringify(PlayList.items));
localStorage.setItem(oc_current_user+'oc_playlist_items',JSON.stringify(PlayList.items));
}
},
load:function(){
if(typeof localStorage !== 'undefined'){
if(localStorage.hasOwnProperty('oc_playlist_items')){
PlayList.items=JSON.parse(localStorage.getItem('oc_playlist_items'));
PlayList.current=parseInt((localStorage.getItem('oc_playlist_current')));
if(JSON.parse(localStorage.getItem('oc_playlist_playing'))){
if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items')){
PlayList.items=JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_items'));
PlayList.current=parseInt((localStorage.getItem(oc_current_user+'oc_playlist_current')));
if(JSON.parse(localStorage.getItem(oc_current_user+'oc_playlist_playing'))){
PlayList.play();
}
PlayList.render();

View File

@ -9,6 +9,7 @@
<?php endforeach; ?>
<script type="text/javascript">
var oc_webroot = '<?php global $WEBROOT; echo $WEBROOT; ?>';
var oc_current_user = '<?php echo OC_User::getUser() ?>';
// </script>
<?php foreach($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>

View File

@ -9,6 +9,7 @@
<?php endforeach; ?>
<script type="text/javascript">
var oc_webroot = '<?php global $WEBROOT; echo $WEBROOT; ?>';
var oc_current_user = '<?php echo OC_User::getUser() ?>';
// </script>
<?php foreach($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>