Pownce Viewer

From OpenSocial Directory

Jump to: navigation, search
Thumbnail
no_image_gadget_thm.png
Application Details
Description Simple gadget that access the Pownce API and display the messages for/from a given user.
Publisher colmeia.tv
Code http://hosting.gmodules.com/ig/gadgets/file/108599327442277231068/simple_pownce.xml
Genre Micro-Blogging

Image:Example.jpg==Reviews== Add a Review
Template:Pownce Viewer Reviews

[edit] Comments

Leave a comment

Your Name:
Heading:
Comment:


[edit] Code

View Code

  <?xml version="1.0" encoding="UTF-8" ?> 
  <Module>
  <ModulePrefs title="Pownce Notes" thumbnail="http://google.com/ig/images/no_image/no_image_gadget_thm.png" description="A simple social gadget for Pownce" height="300" /> 
  <UserPref name="username" display_name="Your Pownce login:" /> 
  <Content type="html">
  <![CDATA[ 
		
		<style>
		#main_container { 
		  width:100%; 
			background-color: #ffffff;
		}
		
    #content { 
      display : block;
		  float:left;
			font-size: 11px;
    }
				
		a { 
		  color : #000000; 
			font-size: 12px;
		}
		a:link { 
		  text-decoration:none;
		}
		a:hover { 
		  text-decoration:underline;
		}

    #linkbox { margin: 0 0 0 20px;}

    h3 {
      display : inline;
      float:left;
      font-size: 14px;			
    }

    p { font-size: 12px; }

    .alert { 
		  display: block;
		  margin : 200px 0 
		}
		
		#logo { 
		  display : inline;
			float:right;
			margin-right: 20px; 
		}
		
		#contents_table {
			border : 0;
			display : block;
			float:left;
			cellpadding: 5px;
		}

		</style>
		
		<div id="main_container">
		  <h3>Latest Pownce notes for/from you</h3>
		  <img id="logo" src="http://img410.imageshack.us/img410/9798/powncegh3.png" alt="Pownce" />
		  <div id="content"><p class="alert"><b>Please wait...</b></p></div>
		</div>
		
		<script type="text/javascript">
		
			// Get userprefs
			var prefs = new _IG_Prefs(__MODULE_ID__);
			var login = prefs.getString("username");
      
			if (login == null || login == '') {
				_gel("content").innerHTML = '<p class="alert"><b>Please go to "edit settings" and fill out your Pownce login.</b></p>';
		  } 
			else {

				var uri = 'http://api.pownce.com/1.0/public_note_lists/for/' + login + '.xml';
				
				_IG_FetchXmlContent(uri,
				function(response) {
					if (response == null || typeof(response) != "object" ||
					     response.firstChild == null) {
						_gel("content").innerHTML = "<i>Invalid data.</i>";
						return;
					}

		       var itemList = response.getElementsByTagName("note");
           var html = '<table id="contents_table">';		
		       for (var i = 0; i < itemList.length ; i++) { 
		         var nodeList = itemList.item(i).childNodes;
             var link = null; 
		         for (var j = 0; j < nodeList.length ; j++) {
		            var node = nodeList.item(j);								
		            if (node.nodeName == "body") {
		               var body = node.firstChild.nodeValue;
		            }
								
                if (node.nodeName == "link") {
                   link = node.childNodes.item(1).firstChild.nodeValue;
									 var short_link = link.replace('http://', '').substring(0, 34);
                }
												
                if (node.nodeName == "sender") {
                   var sender = node.childNodes;
									 for (var k = 0; k < sender.length ; k++) {
		                var info = sender.item(k);
		                if (info.nodeName == "username") {
										  var username = info.firstChild.nodeValue;
										}			
										if (info.nodeName == "permalink") {
                      var userurl = info.firstChild.nodeValue;
                    }
	                  if (info.nodeName == "profile_photo_urls") {
	                     var imgs = info.childNodes;
	                     for (var l = 0; l < imgs.length ; l++) {
	                      var photo = imgs.item(l);
	                      if (photo.nodeName == "medium_photo_url") {
	                        var avatar = photo.firstChild.nodeValue;
	                      }     
	                     }
	                  }
									}
                }															
		         } 
						 html += '<tr><td valign="top"><a href="' + userurl + '"><img border="0" src="' + avatar + '" alt="' + username + '" /></a><br /><br /></td>';
		         html += '<td valign="top"><p>' + body + '</p>';
						 if (link) html += '<a id="linkbox" href="' + link + '">' + short_link + '...</a>';
						 html += '<br /></td></tr>';

		     } 
         html += '</table>';
	      _gel("content").innerHTML = html;
				
				}, 10, false);
		}
		</script>
		

  ]]> 
  </Content>
  </Module>

Page Rating

Rating: 3.7/5 (3 votes cast)

Personal tools
communication