<?xml version="1.0" encoding="UTF-8" ?> <Module> <ModulePrefs title="Top 10 Members" scrolling="true" description="Lists top 10 members of your site, accoring to the number of times a member visits your site" author="Karthik" author_email="manikarthik84@gmail.com" directory_title="Top 10 Members" thumbnail="http://xmlgadgets.com/ig/img/top10.png" screenshot="http://xmlgadgets.com/ig/img/top10_.png" > <Require feature="opensocial-0.8" /> <Require feature="views" /> <Require feature="dynamic-height" /> <Require feature="friendconnect" /> <Require feature="minimessage" /> <Optional feature="skins" /> </ModulePrefs> <UserPref name="imagewidth" display_name="Thumbnail Size" default_value="25" datatype="enum" > <EnumValue value="20" display_value="20 Smallest" /> <EnumValue value="25" display_value="25 Smaller" /> <EnumValue value="30" display_value="30 Small" /> <EnumValue value="35" display_value="35 Small Medium" /> <EnumValue value="40" display_value="40 Medium" /> </UserPref> <Content type="html" view="default"> <![CDATA[ <style> ul { list-style:none; margin:0px; padding:0px; } li { background-color: #EFF7FF; margin:3px 0px; padding:0px; width:200px; height:56px; float:left; } img { border: 0px; } li img { margin:0px auto; padding:2px; border:solid 1px #aaaaaa; width: 50px; height: 50px; } li span.note { font-size:0.8em; } li p { margin:0; } textarea { display:inline; width:136px; height:35px; margin:0; float:left; } input { display:block; clear:left; } </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script type="text/javascript"> var fp = { viewer:null, myVisits:[], config:{ maxDisplay: 10, messageDisappear: 3 }, init:function() { var viewParams = gadgets.views.getParams(); if (viewParams.maxDisplay != undefined) { var max = parseInt(viewParams.maxDisplay); if (max >= 3 && max <= 20) { fp.config.maxDisplay = max; } } $('body').css('background-color', gadgets.skins.getProperty('CONTENT_BG_COLOR')); $('body').css('color', gadgets.skins.getProperty('CONTENT_TEXT_COLOR')); $('body').css('font-face', gadgets.skins.getProperty('FONT_FAMILY')); $('#header').css('color', gadgets.skins.getProperty('CONTENT_HEADLINE_COLOR')); $('#header').css('background-color', gadgets.skins.getProperty('ENDCAP_BG_COLOR')); $('#footer').css('background-color', gadgets.skins.getProperty('ENDCAP_BG_COLOR')); $('#footer').css('color', gadgets.skins.getProperty('ENDCAP_TEXT_COLOR')); var req = opensocial.newDataRequest(); var params = {}; params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [opensocial.Person.Field.PROFILE_URL]; req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER, params), 'viewer'); var idspec = opensocial.newIdSpec({'userId':opensocial.IdSpec.PersonId.OWNER, 'groupId':opensocial.IdSpec.GroupId.FRIENDS}); req.add(req.newFetchPersonAppDataRequest(idspec, 'myVisit'), 'myVisit'); req.send(function(response) { if (!response.get('viewer').hadError()) { fp.viewer = response.get('viewer').getData(); } if (response.get('myVisit').hadError()) { fp.myVisits = []; } else { var myVisits = response.get('myVisit').getData(); var exist = false; $.each(myVisits, function(myVisit) { var json = gadgets.util.unescapeString(this.myVisit); var foot = gadgets.json.parse(json); fp.myVisits.unshift(foot); }); fp.myVisits.sort(function(a, b) { return b.myVisit1 - a.myVisit1; }); fp.showmyVisits(); } }); }, showmyVisits:function() { $('#myVisits').empty(); var html = ''; var vhtml = ''; var noOfMembs = 10; var linkColor = gadgets.skins.getProperty('CONTENT_LINK_COLOR'); var textColor = gadgets.skins.getProperty('CONTENT_TEXT_COLOR'); var fontFamily = gadgets.skins.getProperty('FONT_FAMILY'); var prefs = new _IG_Prefs(); var imgw = prefs.getInt("imagewidth"); var memName; fontFamily = 'Tahoma'; for (var i in fp.myVisits) { // if (i == fp.config.maxDisplay) break; var foot = fp.myVisits[i]; if (fp.viewer == null) {} else { if (fp.viewer.getField(opensocial.Person.Field.PROFILE_URL) == foot.profile) { putViewerlink(foot.myVisit1); } } if (i < noOfMembs) { //if (foot.name.length < 16) // memName = foot.name; //else // memName = foot.name.substr(0,15) + '<br>' + foot.name.substr(15,foot.name.length - 15); memName = foot.name; html += '<tr><td valign=top><img src = "' + foot.thumbnail + '" width=' + imgw + ' height=' + imgw + '></td>'; html += '<td valign=top><a href="' + foot.profile + '" target="_top" >'; html += '<span style="font-size:13px;color:' + linkColor +';font-family:' + fontFamily +';"><b>' + memName + '</b></a></span></td><td valign=top><span style="font-size:12px;font-family:' + fontFamily +';">'+ foot.myVisit1 +' visits</span>'; html += '</td></tr>'; } //html += '<img src="' + foot.thumbnail + '" width=36 height=36>'; //html += '<a href="' + foot.profile + '">' + foot.name + '</a><br>'; //html += '<a href="' + foot.myVisit1 + '">Link</a>'; }; if (fp.viewer == null) { // var mmsg = new gadgets.MiniMessage(); // mmsg.createDismissibleMessage('Please Sign in for your visit to be counted'); vhtml = '<span style="font-size:11px;color:' + textColor +';font-family:' + fontFamily +';">Please Sign in for your visit to be counted</span>'; $('#viewerDiv').html(vhtml); } else { var visits = document.getElementById('hiddenlink').value; var v1 = parseInt(visits); //v1 = v1 + 1; //vhtml = '<span style="font-size:12px;">Welcome ' + fp.viewer.getDisplayName() + '</span><br>'; vhtml = '<a href="'+fp.viewer.getField(opensocial.Person.Field.PROFILE_URL); vhtml += '" target="_top"><span style="font-size:13px;color:' + linkColor +';font-family:' + fontFamily +';"><b>You</b></span></a> <span style="font-size:13px;color:' + textColor +';font-family:' + fontFamily +';">(' + v1 + '&nbsp;Visits before)</span><hr>' ; $('#viewerDiv').html(vhtml); saveLink(); } html = '<table>' + html + '</table>'; html += '<br>'; $('#myVisits').html(html); $('#myVisits li').css('background-color', gadgets.skins.getProperty('ALTERNATE_BG_COLOR')); gadgets.window.adjustHeight(); } }; function putViewerlink(link1) { document.getElementById('hiddenlink').value = link1; } function saveLink() { var visits = document.getElementById('hiddenlink').value; var v1 = parseInt(visits); v1 = v1 + 1; var foot = { 'id': fp.viewer.getId(), 'name': fp.viewer.getDisplayName(), 'thumbnail': fp.viewer.getField(opensocial.Person.Field.THUMBNAIL_URL), 'profile': fp.viewer.getField(opensocial.Person.Field.PROFILE_URL), 'myVisit1': v1 }; var myVisit1 = gadgets.json.stringify(foot); var req = opensocial.newDataRequest(); req.add(req.newUpdatePersonAppDataRequest(opensocial.IdSpec.PersonId.VIEWER, 'myVisit', myVisit1)); req.send(); } </script> <script type="text/javascript"> gadgets.util.registerOnLoadHandler(fp.init); </script> <div id="header" class="header"><span style="font-size:13px;"><b>Top 10 Members</b></span></div> <div id="viewerDiv"></div> <div id="myVisits"></div> <div id="footer"> <a href="http://blog.xmlgadgets.com/google-friend-connect/top-10-members-google-friend-connect-gadget/?utm_source=top10&utm_medium=GFC&utm_campaign=Gadget" target="_blank"><span style="font-size:11px;">Get This!</span></a> </div> <input type=hidden id=hiddenlink value="0"> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-4747275-3"); pageTracker._trackPageview(); pageTracker._trackEvent('Top10', 'Viewed'); } catch(err) {}</script> ]]> </Content> </Module>