PlayList.render=function(){ $('#playlist').show(); PlayList.parent.empty(); for(var i=0;i'); button.attr('src',OC.imagePath('core','actions/delete')); $(this).children().last().append(button); button.click(function(event){ event.stopPropagation(); event.preventDefault(); var index=$(this).parent().parent().data('index'); PlayList.remove(index); }); },function(){ $(this).children().last().children('img.remove').remove(); }); tr.children('td.name').children('input').click(function(event){ event.stopPropagation(); if($(this).attr('checked')){ $(this).parent().parent().addClass('selected'); if($('tbody td.name input:checkbox').length==$('tbody td.name input:checkbox:checked').length){ $('#selectAll').attr('checked',true); } }else{ $(this).parent().parent().removeClass('selected'); $('#selectAll').attr('checked',false); } procesSelection(); }); PlayList.parent.append(tr); } } PlayList.getSelected=function(){ return $('tbody td.name input:checkbox:checked').parent().parent(); } PlayList.hide=function(){ $('#playlist').hide(); } $(document).ready(function(){ PlayList.parent=$('#playlist tbody'); PlayList.template=$('#playlist tr.template'); $('#selectAll').click(function(){ if($(this).attr('checked')){ // Check all $('tbody td.name input:checkbox').attr('checked', true); $('tbody td.name input:checkbox').parent().parent().addClass('selected'); }else{ // Uncheck all $('tbody td.name input:checkbox').attr('checked', false); $('tbody td.name input:checkbox').parent().parent().removeClass('selected'); } procesSelection(); }); }); function procesSelection(){ var selected=PlayList.getSelected(); if(selected.length==0){ $('th.name span').text('Name'); $('th.artist').text('Artist'); $('th.album').text('Album'); $('th.time').text('Time'); $('th.plays').empty(); $('th.plays').text('Plays'); }else{ var name=selected.length+' selected'; var artist=$(selected[0]).data('artist'); var album=$(selected[0]).data('album'); var time=$(selected[0]).data('time'); var plays=$(selected[0]).data('plays'); for(var i=1;i'); button.attr('src',OC.imagePath('core','actions/delete')); $('th.plays').append(button); button.click(function(event){ event.stopPropagation(); event.preventDefault(); PlayList.getSelected().each(function(index,element){ var index=$(element).data('index'); PlayList.items[index]=null; }); PlayList.items=PlayList.items.filter(function(item){return item!==null}); PlayList.render(); procesSelection(); }); } }