2011-07-26 18:04:57 +04:00
|
|
|
$(document).ready(function(){
|
2011-07-31 02:50:04 +04:00
|
|
|
OC.search.customResults.Music=function(row,item){
|
|
|
|
var parts=item.link.substr(item.link.indexOf('#')+1).split('&');
|
|
|
|
var data={};
|
|
|
|
for(var i=0;i<parts.length;i++){
|
|
|
|
var itemParts=parts[i].split('=');
|
2011-08-01 02:25:53 +04:00
|
|
|
data[itemParts[0]]=itemParts[1].replace(/\+/g,' ');
|
2011-07-31 02:50:04 +04:00
|
|
|
}
|
|
|
|
var media=Collection.find(data.artist,data.album,data.song);
|
2011-07-31 03:39:25 +04:00
|
|
|
var a=row.find('a');
|
|
|
|
a.attr('href','#');
|
|
|
|
a.click(function(){
|
|
|
|
var oldSize=PlayList.items.length;
|
|
|
|
PlayList.add(media);
|
|
|
|
PlayList.play(oldSize);
|
|
|
|
PlayList.render();
|
|
|
|
});
|
2011-09-28 13:45:22 +04:00
|
|
|
var button=$('<input type="button" title="'+t('media','Add album to playlist')+'" class="add"></input>');
|
2012-02-22 01:31:35 +04:00
|
|
|
button.css('background-image','url('+OC.imagePath('core','actions/play-add')+')');
|
2011-07-31 03:39:25 +04:00
|
|
|
button.click(function(event){
|
|
|
|
event.stopPropagation();
|
|
|
|
PlayList.add(media);
|
|
|
|
PlayList.render();
|
|
|
|
});
|
|
|
|
row.find('div.name').append(button);
|
2011-09-30 01:54:33 +04:00
|
|
|
button.tipsy({gravity:'n', fade:true, delayIn: 400, live:true});
|
2012-02-22 01:31:35 +04:00
|
|
|
};
|
2011-08-08 19:53:03 +04:00
|
|
|
Collection.display();
|
2012-01-12 05:02:45 +04:00
|
|
|
|
|
|
|
Collection.load(function(){
|
|
|
|
var urlVars=getUrlVars();
|
|
|
|
if(urlVars.artist){
|
|
|
|
var song=Collection.find(urlVars.artist,urlVars.album,urlVars.song);
|
|
|
|
PlayList.add(song);
|
|
|
|
PlayList.play(0);
|
|
|
|
}
|
2012-02-22 01:31:35 +04:00
|
|
|
});
|
2011-07-26 18:04:57 +04:00
|
|
|
});
|
2011-07-22 08:30:52 +04:00
|
|
|
|
|
|
|
function getUrlVars(){
|
2012-01-12 05:02:45 +04:00
|
|
|
var vars = {}, hash;
|
|
|
|
var hashes = window.location.hash.substr(1).split('&');
|
|
|
|
for(var i = 0; i < hashes.length; i++){
|
2011-07-22 08:30:52 +04:00
|
|
|
hash = hashes[i].split('=');
|
2012-01-12 05:02:45 +04:00
|
|
|
vars[hash[0]] = decodeURIComponent(hash[1]).replace(/\+/g,' ');
|
2011-07-22 08:30:52 +04:00
|
|
|
}
|
|
|
|
return vars;
|
2011-07-26 18:04:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function musicTypeFromFile(file){
|
2012-03-23 18:11:03 +04:00
|
|
|
var extention=file.split('.').pop().toLowerCase();
|
2011-07-26 18:04:57 +04:00
|
|
|
if(extention=='ogg'){
|
2012-02-22 01:31:35 +04:00
|
|
|
return 'oga';
|
2011-07-26 18:04:57 +04:00
|
|
|
}
|
|
|
|
//TODO check for more specific cases
|
|
|
|
return extention;
|
2012-02-22 01:31:35 +04:00
|
|
|
}
|