среда, 1 сентября 2010 г.

Recent Comments Gadgets for Blogger

<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs
title="Recent Comments"
author="Blogger Buster"
description="Show your most recent comments, with optional summaries"
author_email="amanda@bloggerbuster.com"
thumbnail="http://lh5.ggpht.com/_xn2gmPb9TfM/Skx7Clau9xI/AAAAAAAAEZo/R-lxwscDVYw/s800/blogger-recent-comments-thumb.png">
<Require feature="opensocial-0.7"/>
<Require feature="google.blog"/>
<Require feature="skins"/>
<Require feature="views"/>
<Require feature="dynamic-height"/>
</ModulePrefs>

<UserPref
name="numberOfPosts"
display_name="Number of Comments to Display"
required="true"
default_value="10" />

<UserPref
name="summaryLength"
display_name="Summary Length"
required="true"
default_value="200" />


<Content type="html">
<![CDATA[
<script type="text/javascript">

/**
* This method is called after your friend data is loaded. It parses the friend data and
* saves the profile ids of your friends, then fetches the blog data.
*/
function onLoadFriends(data) {

// Get the feed data
blog = new google.Blog(function() {

window.setTimeout(function() {
blog.getCommentsJson(onLoadFeed);
}, 100);
}, window.name);
}

/**
* This method parses the feed data that was returned by the call to fetch the blog data.
*/
function onLoadFeed(data) {
var list = document.getElementById("output");

if (!data.data) {
list.innerHTML = "An error occured fetching the feed data";
}

data = data.data;

if (!data.feed.entry || data.feed.entry.length == 0) {
list.innerHTML = "No posts on this blog!";
}
var viewParams = gadgets.views.getParams();
var numberOfPosts = viewParams["numberOfPosts"];

for (var i = 0; i < numberOfPosts; i++) {
var entry = data.feed.entry[i];
var dt = document.createElement("DT");
dt.style.paddingTop = "10px";
var dd = document.createElement("div");
dd.style.fontSize = "0.8em";
var de = document.createElement("div");
de.style.fontSize = "0.8em";
var df = document.createElement("div");
df.style.fontSize = "0.8em";
var href;
for (var j = 0; j < entry.link.length; ++j) {
if (entry.link[j].rel == "alternate") {
href = entry.link[j].href.replace(/#/, "#comment-");
}
}

var postdate = entry.published.$t;
var cdyear = postdate.substring(0,4);
var cdmonth = postdate.substring(5,7);
var cdday = postdate.substring(8,10);
var monthnames = new Array();
monthnames[1] = "Jan";
monthnames[2] = "Feb";
monthnames[3] = "Mar";
monthnames[4] = "Apr";
monthnames[5] = "May";
monthnames[6] = "Jun";
monthnames[7] = "Jul";
monthnames[8] = "Aug";
monthnames[9] = "Sep";
monthnames[10] = "Oct";
monthnames[11] = "Nov";
monthnames[12] = "Dec";
if ("content" in entry) {
var postcontent = entry.content.$t;}
else
if ("summary" in entry) {
var postcontent = entry.summary.$t;}
else var postcontent = "";
var re = /<\S[^>]*>/g;
postcontent = postcontent.replace(re, "");

var viewParams = gadgets.views.getParams();
var numchars = viewParams["summaryLength"];

var a = document.createElement("A");
a.style.color = linkColor;
a.setAttribute("href", href);
a.target ='_top';
a.appendChild(document.createTextNode(entry.author[0].name.$t + " wrote..."));
dt.appendChild(a);
if (postcontent.length < numchars) {
de.appendChild(document.createTextNode(postcontent));}
else {
postcontent = postcontent.substring(0, numchars);
var quoteEnd = postcontent.lastIndexOf(" ");
postcontent = postcontent.substring(0,quoteEnd);
de.appendChild(document.createTextNode(postcontent + '...'));
var more = document.createElement("A");
more.style.color = linkColor;
more.setAttribute("href", href);
more.target ='_top';
more.appendChild(document.createTextNode("Continue >>"));
df.appendChild(more);
}

list.appendChild(dt);
list.appendChild(de);
list.appendChild(df);
gadgets.window.adjustHeight();
}
}


var linkColor;
var textColor;
var backgroundColor;
function initData() {
textColor = gadgets.skins.getProperty('CONTENT_TEXT_COLOR');
document.getElementById("output").style.color = textColor;

linkColor = gadgets.skins.getProperty('CONTENT_LINK_COLOR');
document.getElementById("canvas-link").style.color = linkColor;

backgroundColor = gadgets.skins.getProperty('CONTENT_BG_COLOR');
document.body.style.backgroundColor = backgroundColor;


var req = opensocial.newDataRequest();
req.send(onLoadFriends);
}
gadgets.util.registerOnLoadHandler(initData);
</script>

<div style="display:none;float:right;font-size:80%" id="canvas-link-container">
<a id="canvas-link" href="javascript:void(0);" onclick="goToCanvas();">Canvas mode</a>
</div>
<div style="clear:both"></div>
<div>
<div id="output" style="font-size:90%"></div>
</div>
]]>

</Content>
</Module>

0 коммент.:

Отправить комментарий