(function() { var username; // How many entries to show per category before expanding var initialCount = 3; var tasteometer = ""; var lastPlayedTrack = ""; var sharedArtists = ""; var topArtists = ""; var topAlbums = ""; var topTracks = ""; var expanded = false; // Failed request flag. var flag = 0; $(document).ready(function () { // Avoid conflicting with other jQuery instances (userscripts et al). // $.noConflict(); // Why is this needed? // Fetch the username (appended from php) to base all get requests on. username = $('#lastfm_username').text(); var div = $('#lastfm_stats'); // Fetch the required data. // If data isn't cached, delays are issued in the class to avoid too many parallel requests to Last.fm getTasteometer(div); getLastPlayedTrack(div); getTopArtists(div); getTopAlbums(div); getTopTracks(div); // Allow expanding the show information to more than three entries. // Attach to document as lastfm_expand links are added dynamically when fetching the data. $(document).on('click', "#lastfm_expand", function () { // Make hidden entries visible and remove the expand button. if ( $(this).attr("href") == "#sharedartists" ) { sharedArtists = sharedArtists.replace(/\ class="hidden"/g,""); sharedArtists = sharedArtists.replace(/