Skip to content

Instantly share code, notes, and snippets.

@lazypower
Created April 8, 2011 02:40
Show Gist options
  • Save lazypower/909182 to your computer and use it in GitHub Desktop.
Save lazypower/909182 to your computer and use it in GitHub Desktop.
$(document).ready(function()
{
$("ul.lfm-thumb li").hover(function() {
if ($(this).hasClass("lfm-lefborder")) {
marTop = '110px';
marLeft = '110px';
} else {
marTop = '-110px'; /* The next 4 lines will vertically align this image */
marLeft = '-110px';
}
$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/
$(this).find('img').not('#tooltip img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
.animate({
marginTop: marTop,
marginLeft: marLeft,
top: '50%',
left: '50%',
width: '174px', /* Set new width */
height: '174px',
padding: '20px'
}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
} , function() {
$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
$(this).find('img').not('#tooltip img').removeClass("hover").stop() /* Remove the "hover" class , then stop animation queue buildup*/
.animate({
marginTop: '0', /* Set alignment back to default */
marginLeft: '0',
top: '0px',
left: '0px',
width: '100px', /* Set width back to default */
height: '100px', /* Set height back to default */
padding: '1px'
}, 400);
}); // end of animation
// TOOLTIP!!
// grab all the tooltip's
$('a[rel=tooltip]').mouseover(function(e) {
//Grab the title attribute's value and assign it to a variable
var tip = $(this).attr('title');
//Remove the title attribute's to avoid the native tooltip from the browser
$(this).attr('title','');
//Append the tooltip template and its value
$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');
//Show the tooltip with faceIn effect
$('#tooltip').fadeIn('500');
$('#tooltip').fadeTo('10',0.9);
}).mousemove(function(e) {
//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
//$('#tooltip').css('top', e.pageY + 10 ); not workiing, it shot it to the bottom of the browser
//$('#tooltip').css('left', e.pageX + 20 );
}).mouseout(function() {
//Put back the title attribute's value
$(this).attr('title',$('.tipBody').html());
//Remove the appended tooltip template
$(this).children('div#tooltip').remove();
});
});
<?PHP
$lastfm = new LastFm();
$lastfm->key = "APIKEY";
$albums = $lastfm->user_getRecentTracks("user=lazypower");
//$shouts = $lastfm->user_getShouts("user=lazypower");
$info = $lastfm->user_getInfo("user=lazypower");
?>
// display user info
<?php foreach ($info as $w) : ?>
<!-- <div class="contentContainer">
<p /> <h1> <a href=" <?PHP echo $w[user][url][value]; ?>"> <?PHP echo $w[user][name][value]; ?>
<img src=" <?PHP echo $w[user][image][1][value]; ?> /></a>
*/ -->
<span class="lfm-heading">Total Songs Scrobbled: <?PHP echo $w[user][playcount][value]; ?></span><p />
<!-- </div> -->
<?PHP endforeach; ?>
<span class="lfm-heading">Recently Played</span>
<?PHP //if ($albums[1][recenttracks][track][1][attr][nowplaying] == true) { do stuff } ?>
<div class="LFMContainer">
<?PHP
forEach ($albums as $v) :
for ($i = 0; $i <= 8; $i++) :
if ($i == 0 | $i == 3 | $i == 6 ) {
echo("<ul class=\"lfm-thumb\">");
echo("<li class=\"lfm-leftborder\">");
} else {
echo("<li>");
}
?>
<a rel="tooltip" title="
<br />Title: <?php echo $v[recenttracks][track][$i][name][value]; ?>
<br />Artist: <?php echo $v[recenttracks][track][$i][artist][value]; ?>
<br />Album: <?php echo $v[recenttracks][track][$i][album][value]; ?> "/>
<img src="
<?php if ($v[recenttracks][track][$i][image][3][value] != null){
echo $v[recenttracks][track][$i][image][3][value] . "\"/>";
} else {
echo("include/noimage.jpg \"/>");
} ?> </a></li>
<?php if ($i == 2| $i == 5 | $i == 8 ) : ?>
</ul>
<?PHP endif; ?>
<?php endfor; ?>
<?php endforeach; ?>
</div>
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment