Last.fm Recent Tracks

From OpenSocial Directory

Jump to: navigation, search
Thumbnail
lastfm.gif
Application Details
Description Last.fm Recent Tracks
Publisher Diogo Moura
Author Diogo Moura
Code http://www.diogomoura.com/orkut/last/lastfm.xml.cfm
Genre Music
Screenshot
lastfm280.gif

Image:Example.jpg==Reviews== Add a Review
Template:Last.fm Recent Tracks Reviews

[edit] Comments

Leave a comment

Your Name:
Heading:
Comment:


[edit] Code

View Code

  <?xml version="1.0" encoding="UTF-8" ?> 
  <Module>
  <ModulePrefs title="Recently Listened Tracks" description="Recently Listened Tracks" author="Diogo Moura" author_email="diogomoura@gmail.com" thumbnail="http://www.diogomoura.com/orkut/last/lastfm.gif" screenshot="http://www.diogomoura.com/orkut/last/lastfm280.gif">
  <Require feature="opensocial-0.5" /> 
  <Require feature="dynamic-height" /> 
  </ModulePrefs>
  <UserPref name="lastusername" display_name="Your user in Last.fm" default_value="diogomoura" datatype="string" /> 
  <Content type="html">
  <![CDATA[ 
	<link rel="stylesheet" type="text/css" media="all" href="http://cdn.last.fm/styles/branches/release-20070823/51862/main.css" charset="utf-8" />
	<!--[if IE 6]>
	<link rel="stylesheet" type="text/css" media="screen" href="http://cdn.last.fm/styles/branches/release-20070823/51862/ie/ie6.css" charset="utf-8" />
	<![endif]-->
    <script type="text/javascript">
		_IG_RegisterOnloadHandler(request);
		
		function request() {
			var prefs = new _IG_Prefs();
			var cacheBug = new Date().getTime();
			var service = 'http://ws.audioscrobbler.com/1.0/user/' + prefs.getString("lastusername") + '/recenttracks.xml';
			var serviceProfile = 'http://ws.audioscrobbler.com/1.0/user/' + prefs.getString("lastusername") + '/profile.xml';
			
			/*_IG_FetchXmlContent(serviceProfile + '?cacheBug=' + cacheBug, function (response) {
				if (response == null || typeof(response) != "object" || 
					  response.firstChild == null) {
				  _gel("content_div").innerHTML = "<i>Invalid Data.</i>";
				  return;
				}
				
				var html = '';
				var profileData = response.getElementsByTagName("profile");
				
				for (var i = 0; i < profileData.length ; i++) { 
					var nodeList = profileData.item(i).childNodes;

					for (var j = 0; j < nodeList.length ; j++) {
						var node = nodeList.item(j);
						
						if (node.nodeName == "playcount") {
		                   var playcount = node.firstChild.nodeValue;
		                }
		                if (node.nodeName == "avatar") {
		                   var avatar = node.firstChild.nodeValue; 
						   avatar = avatar.replace('/160/','/50/');
		                }
						if (node.nodeName == "url") {
		                   var url = node.firstChild.nodeValue; 
		                }
					}
					
					html += '<h3 style="text-align:left;"><a href="' + url + '" target="_blank">Recently Listened Tracks</a></h3>';
				}

				_gel('header_div').innerHTML = html;
				_IG_AdjustIFrameHeight();
			});*/
			
			_IG_FetchXmlContent(service + '?cacheBug=' + cacheBug, function (response) {
				if (response == null || typeof(response) != "object" || 
					  response.firstChild == null) {
				  _gel("content_div").innerHTML = "<i>Invalid Data.</i>";
				  return;
				}
				
				var user = response.getElementsByTagName("recenttracks").item(0).getAttribute("user");
				var trackList = response.getElementsByTagName("track");
				
				var html = '<table id="recentLast" class="recentList" width="100%" cellspacing="0" cellpadding="0" border="0"><tbody>';
				
				for (var i = 0; i < trackList.length ; i++) { 
					var nodeList = trackList.item(i).childNodes;

					for (var j = 0; j < nodeList.length ; j++) {
						var node = nodeList.item(j);
						
						if (node.nodeName == "name") {
		                   var name = node.firstChild.nodeValue;
		                }
		                if (node.nodeName == "artist") {
		                   var artist = node.firstChild.nodeValue; 
		                }
						if (node.nodeName == "url") {
		                   var url = node.firstChild.nodeValue; 
		                }
						if (node.nodeName == "date") {
		                   var date = node.firstChild.nodeValue; 
		                }
					}
					
					html += '<tr class=""><td class="subject"><a href="' + url + '" target="_blank">' + artist + ' - ' + name + '</a></td><td class="date">	' + date + '</td></tr>';
				}
				
				html += '</tbody></table>';
				html += '<div style="text-align:right;width:100%;"><a title="Last.fm Homepage" href="http://last.fm/" target="_blank"><img alt="Last.fm" src="http://cdn.last.fm/depth/advertising/lastfm/mini_red.gif" id="LogoImg"/></a></div>';
				
				
				_gel('content_div').innerHTML = html;
				_IG_AdjustIFrameHeight();
			});
		}
	</script>
	<div id='content_div' style="text-align:left;">Loading...</div>
  

  ]]> 
  </Content>
  </Module>

Page Rating

Rating: 3.9/5 (7 votes cast)

Personal tools
communication