mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-15 16:19:28 +01:00
Initial changes to the default template to use the cache
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
<%def name="body()">
|
||||
<div id="artistheader" class="clearfix">
|
||||
<div id="artistImg">
|
||||
<img class="albumArt" src="http://ec1.images-amazon.com/images/P/None.01.MZZZZZZZ.jpg" width="200" height="200" alt="${artist['ArtistName']}"/>
|
||||
<img id="artistImg" class="albumArt" alt="${artist['ArtistName']}"/>
|
||||
</div>
|
||||
<h1>
|
||||
%if artist['Status'] == 'Loading':
|
||||
@@ -109,7 +109,7 @@
|
||||
%>
|
||||
<tr class="grade${grade}">
|
||||
<td id="select"><input type="checkbox" name="${album['AlbumID']}" class="checkbox" /></td>
|
||||
<td id="albumart"><img src="http://ec1.images-amazon.com/images/P/${album['AlbumASIN']}.01.MZZZZZZZ.jpg" height="50" width="50"></td>
|
||||
<td id="albumart"><img title="${album['AlbumID']}" height="64" width="64"></td>
|
||||
<td id="albumname"><a href="albumPage?AlbumID=${album['AlbumID']}">${album['AlbumTitle']}</a></td>
|
||||
<td id="reldate">${album['ReleaseDate']}</td>
|
||||
<td id="type">${album['Type']}</td>
|
||||
@@ -148,11 +148,41 @@
|
||||
<script src="js/libs/jquery.dataTables.min.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
function getArtistArt() {
|
||||
var id = "${artist['ArtistID']}";
|
||||
var image = $("div#artistImg img#artistImg");
|
||||
if ( !image.hasClass('done') ) {
|
||||
image.addClass('done');
|
||||
getArtwork(image,id,'artist');
|
||||
}
|
||||
}
|
||||
|
||||
function getAlbumArt() {
|
||||
$("table#album_table tr td#albumart").each(function(){
|
||||
var id = $(this).children('img').attr('title');
|
||||
var image = $(this).children('img');
|
||||
if ( !image.hasClass('done') ) {
|
||||
image.addClass('done');
|
||||
getThumb(image,id,'album');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getArtistBio() {
|
||||
var id = "${artist['ArtistID']}";
|
||||
var elem = $("div#artistBio")
|
||||
getInfo(elem,id,'artist');
|
||||
}
|
||||
|
||||
|
||||
function initThisPage() {
|
||||
%if artist['Status'] == 'Loading':
|
||||
showMsg("Getting artist information",true);
|
||||
%endif
|
||||
|
||||
getArtistArt();
|
||||
getArtistBio();
|
||||
getAlbumArt();
|
||||
$('#album_table').dataTable({
|
||||
"bDestroy": true,
|
||||
"aoColumns": [
|
||||
@@ -181,19 +211,16 @@
|
||||
|
||||
});
|
||||
resetFilters("albums");
|
||||
replaceEmptyAlbum("table#album_table td#albumart img","${artist['ArtistName']}");
|
||||
setTimeout(function(){
|
||||
initFancybox();
|
||||
},1000);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
getArtistInfo("${artist['ArtistName']}","#artistImg img",3,"${artist['ArtistID']}");
|
||||
initActions();
|
||||
initThisPage();
|
||||
});
|
||||
$(window).load(function(){
|
||||
replaceEmptyAlbum("table#album_table td#albumart img","${artist['ArtistName']}");
|
||||
setTimeout(function(){
|
||||
initFancybox();
|
||||
},1000)
|
||||
|
||||
@@ -96,10 +96,9 @@
|
||||
<a href="#main" id="toTop"><span>Back to top</span></a>
|
||||
</div>
|
||||
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
|
||||
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.7.2.min.js"%3E%3C/script%3E'))</script>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.19/jquery-ui.min.js"></script>
|
||||
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-ui.min.js"%3E%3C/script%3E'))</script>
|
||||
<script src="js/libs/jquery-1.7.2.min.js"></script>
|
||||
<script src="js/libs/jquery-ui.min.js"></script>
|
||||
|
||||
${next.javascriptIncludes()}
|
||||
|
||||
<script src="js/plugins.js"></script>
|
||||
|
||||
@@ -74,11 +74,10 @@
|
||||
function getArtistArt() {
|
||||
$("table#artist_table tr td#name").each(function(){
|
||||
var id = $(this).children('a').attr('title');
|
||||
var artist = $(this).children('a').text();
|
||||
var image = $(this).parent().find("td#albumart img");
|
||||
if ( !image.hasClass('done') ) {
|
||||
image.addClass('done');
|
||||
getArtistInfo(artist,image,1,id);
|
||||
getThumb(image,id,'artist');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -114,4 +113,4 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
</%def>
|
||||
</%def>
|
||||
|
||||
@@ -1,110 +1,65 @@
|
||||
function getArtistInfo(name,imgElem,size,artistID) {
|
||||
var apikey = "690e1ed3bc00bc91804cd8f7fe5ed6d4";
|
||||
function getThumb(imgElem,id,type) {
|
||||
|
||||
// Get Data by Artist ID
|
||||
$.ajax({
|
||||
url: "http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&mbid="+ artistID +"&api_key="+ apikey+"&format=json",
|
||||
dataType: "jsonp",
|
||||
cache: true,
|
||||
success: function(data){
|
||||
if ( data.artist !== undefined ) {
|
||||
var imageUrl = data.artist.image[size]['#text'];
|
||||
}
|
||||
if (data.error) {
|
||||
getArtistName();
|
||||
} else {
|
||||
if ( data.artist === undefined || imageUrl == "" || imageUrl == undefined ) {
|
||||
var imageLarge = "#";
|
||||
var imageUrl = "interfaces/default/images/no-cover-artist.png";
|
||||
} else {
|
||||
var artist = data.artist.mbid;
|
||||
var artistBio = data.artist.bio.summary;
|
||||
var imageLarge = data.artist.image[4]['#text'];
|
||||
var imageUrl = data.artist.image[size]['#text'];
|
||||
}
|
||||
var artistBio = artistBio;
|
||||
var image = imgElem;
|
||||
var bio = $('#artistBio');
|
||||
$(image).attr("src",imageUrl).removeAttr("width").removeAttr("height").hide().fadeIn();
|
||||
if ( bio.length > 0 ) $(bio).append(artistBio);
|
||||
$(image).wrap('<a href="'+ imageLarge +'" rel="dialog" title="' + name + '"></a>');
|
||||
}
|
||||
}
|
||||
});
|
||||
// If not found get by Name
|
||||
function getArtistName() {
|
||||
$.ajax({
|
||||
url: "http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&artist="+ name +"&api_key="+ apikey+"&format=json",
|
||||
dataType: "jsonp",
|
||||
success: function(data){
|
||||
if ( data.artist !== undefined ) {
|
||||
var imageUrl = data.artist.image[size]['#text'];
|
||||
}
|
||||
if ( data.artist === undefined || imageUrl == "" ) {
|
||||
var imageLarge = "#";
|
||||
var imageUrl = "interfaces/default/images/no-cover-artist.png";
|
||||
} else {
|
||||
var artist = data.artist.name;
|
||||
var artistBio = data.artist.bio.summary;
|
||||
var imageLarge = data.artist.image[4]['#text'];
|
||||
var imageUrl = data.artist.image[size]['#text'];
|
||||
}
|
||||
var artistBio = artistBio;
|
||||
var image = imgElem;
|
||||
var bio = $('#artistBio');
|
||||
$(image).attr("src",imageUrl).removeAttr("width").removeAttr("height").hide().fadeIn();
|
||||
if ( bio.length > 0 ) $(bio).append(artistBio);
|
||||
$(image).wrap('<a href="'+ imageLarge +'" rel="dialog" title="' + artist + '"></a>');
|
||||
}
|
||||
});
|
||||
if ( type == 'artist' ) {
|
||||
var thumbURL = "getThumb?ArtistID=" + id;
|
||||
} else {
|
||||
var thumbURL = "getThumb?AlbumID=" + id;
|
||||
}
|
||||
// Get Data from the cache by Artist ID
|
||||
$.ajax({
|
||||
url: thumbURL,
|
||||
success: function(data){
|
||||
if ( data == "" ) {
|
||||
var imageUrl = "interfaces/default/images/no-cover-artist.png";
|
||||
}
|
||||
else {
|
||||
var imageUrl = data;
|
||||
}
|
||||
$(imgElem).attr("src",imageUrl).removeAttr("width").removeAttr("height").hide().fadeIn();
|
||||
$(imgElem).wrap('<a href="'+ imageLarge +'" rel="dialog" title="' + name + '"></a>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getAlbumInfo(name, album, elem,size) {
|
||||
var apikey = "690e1ed3bc00bc91804cd8f7fe5ed6d4";
|
||||
var dimensions = getOriginalWidthOfImg(this);
|
||||
var cover = $(elem);
|
||||
function getArtwork(imgElem,id,type) {
|
||||
|
||||
if ( dimensions <= 1) {
|
||||
// Get Data
|
||||
$.ajax({
|
||||
url: "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=" + apikey + "&artist="+ name +"&album="+ album +"&format=json&callback=?",
|
||||
dataType: "jsonp",
|
||||
success: function(data){
|
||||
if ( data.artist !== undefined ) {
|
||||
var imageUrl = data.artist.image[size]['#text'];
|
||||
}
|
||||
if (data.album === undefined || imageUrl == "") {
|
||||
if ( elem.width() == 50 ) {
|
||||
var imageUrl = "interfaces/default/images/no-cover-artist.png";
|
||||
} else {
|
||||
var imageUrl = "interfaces/default/images/no-cover-art.png";
|
||||
}
|
||||
} else {
|
||||
var imageUrl = data.album.image[size]['#text'];
|
||||
var imageLarge = data.album.image[3]['#text'];
|
||||
}
|
||||
$(cover).error(function(){
|
||||
if ( elem.width() == 50 ) {
|
||||
var imageUrl = "interfaces/default/images/no-cover-artist.png";
|
||||
} else {
|
||||
var imageUrl = "interfaces/default/images/no-cover-art.png";
|
||||
}
|
||||
$(elem).css("background", "url("+ imageUrl+") center top no-repeat");
|
||||
});
|
||||
if ( imageUrl == "") {
|
||||
if ( elem.width() == 50 ) {
|
||||
var imageUrl = "interfaces/default/images/no-cover-artist.png";
|
||||
} else {
|
||||
var imageUrl = "interfaces/default/images/no-cover-art.png";
|
||||
}
|
||||
$(elem).css("background", "url("+ imageUrl+") center top no-repeat");
|
||||
}
|
||||
$(elem).css("background", "url("+ imageUrl+") center top no-repeat");
|
||||
$(elem).wrap('<a href="'+ imageLarge +'" rel="dialog" title="' + name + '"></a>');
|
||||
}
|
||||
});
|
||||
if ( type == 'artist' ) {
|
||||
var artworkURL = "getArtwork?ArtistID=" + id;
|
||||
} else {
|
||||
var artworkURL = "getArtwork?AlbumID=" + id;
|
||||
}
|
||||
// Get Data from the cache by Artist ID
|
||||
$.ajax({
|
||||
url: artworkURL,
|
||||
success: function(data){
|
||||
if ( data == "" ) {
|
||||
var imageUrl = "interfaces/default/images/no-cover-artist.png";
|
||||
}
|
||||
else {
|
||||
var imageUrl = data;
|
||||
}
|
||||
$(imgElem).attr("src",imageUrl).removeAttr("width").removeAttr("height").hide().fadeIn();
|
||||
$(imgElem).wrap('<a href="'+ imageLarge +'" rel="dialog" title="' + name + '"></a>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getInfo(elem,id,type) {
|
||||
|
||||
if ( type == 'artist' ) {
|
||||
var infoURL = "getInfo?ArtistID=" + id;
|
||||
} else {
|
||||
var infoURL = "getInfo?AlbumID=" + id;
|
||||
}
|
||||
// Get Data from the cache by Artist ID
|
||||
$.ajax({
|
||||
url: infoURL,
|
||||
data_type: "jsonp",
|
||||
success: function(data){
|
||||
var summary = data['Summary'];
|
||||
$(elem).append(summary);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getOriginalWidthOfImg(img_element) {
|
||||
|
||||
Reference in New Issue
Block a user