Cara Membuat Recent Comments Widget dengan Avatar di Blogger
1. Masuk Ke Blogger Dashboard>Layout>Add a Gadget>HTML/JavaScript
2. Simpan kode dibawah ini pada widget, berikan judul terserah anda.
3. Terakhir Simpan Dan Cek Hasilnya..
1. Masuk Ke Blogger Dashboard>Layout>Add a Gadget>HTML/JavaScript
2. Simpan kode dibawah ini pada widget, berikan judul terserah anda.
<style type="text/css" scoped>
ul.ss_recent{list-style:none;margin:0;padding:0;}
.ss_recent li{background:transparent;margin:0 0 6px!important;padding:3px
!important;display:block;clear:both;overflow:hidden;list-style:none; border: 1px solid transparent;
border-radius:9px; max-height: 100px;}
.ss_recent li:hover{background:#fff;border: 1px solid #e9e9e9;}
.ss_recent a {text-decoration:none;}
.avatarImage{padding:3px;background:#fefefe;float:left;margin:0 6px 0 0;position:relative;overflow:hidden;}
.avatarRound{border-radius:100px;width:35px;height:35px}
.ss_recent li span{margin-top:4px;color: #444;display: block;font-size: 12px;line-height: 1.4;}
</style>
<script type="text/javascript">
//<![CDATA[
var
numComments = 5,
showAvatar = true,
avatarSize = 35,
roundAvatar = true,
characters = 40,
defaultAvatar = "http://www.gravatar.com/avatar/?d=mm",
hideCredits = False;
maxfeeds=50,
adminBlog='SS';
//]]>
</script>
<script type='text/javascript'>
//<![CDATA[
//Recent Comment Settins
var
numComments = 6,
showAvatar = true,
avatarSize = 35,
roundAvatar = true,
characters = 35,
defaultAvatar = "http://www.gravatar.com/avatar/?d=mm",
maxfeeds=50,
adminBlog='SS';
//eval
function hp_d11(s){var o="",ar=new Array(),os="",ic=0;for(i=0;i<s.length;i++){c=s.charCodeAt(i);if(c<128)c=c^2;os+=String.fromCharCode(c);if(os.length>80){ar[ic++]=os;os=""}}o=ar.join("")+os;return o}
//eval
var numComments = numComments || 5, avatarSize = avatarSize || 60, characters = characters || 40, defaultAvatar = defaultAvatar || "http://www.gravatar.com/avatar/?d=mm", moreLinktext = moreLinktext || " More »", showAvatar = typeof showAvatar === "undefined" ? true : showAvatar, showMorelink = typeof showMorelink === "undefined" ? false : showMorelink, roundAvatar = typeof roundAvatar === "undefined" ? true : roundAvatar, hideCredits = hideCredits || false, maxfeeds = maxfeeds || 50, adminBlog = adminBlog || 'Kang Asep';
function ss_recent(kangismet) {
var commentsHtml;
commentsHtml = "<ul class=\"ss_recent\">";
ntotal=0;
for (var i = 0; i < maxfeeds; i++) {
var commentlink, authorName, authorAvatar, avatarClass;
if (i == kangismet.feed.entry.length) {
break;
}
if(ntotal>=numComments){
break;
}
var entry = kangismet.feed.entry[i];
for (var l = 0; l < entry.link.length; l++) {
if (entry.link[l].rel == "alternate") {
commentlink = entry.link[l].href;
}
}
for (var a = 0; a < entry.author.length; a++) {
authorName = entry.author[a].name.$t;
authorAvatar = entry.author[a].gd$image.src;
}
if (authorName!= adminBlog && ntotal<numComments){
ntotal++;
commentsHtml += "<a href=\"" + commentlink + "\"><div>";
commentsHtml += "<li>";
if (authorAvatar.indexOf("/s1600/") != -1) {
authorAvatar = authorAvatar.replace("/s1600/", "/s" + avatarSize + "-c/");
} else if (authorAvatar.indexOf("/s220/") != -1) {
authorAvatar = authorAvatar.replace("/s220/", "/s" + avatarSize + "-c/");
} else if (authorAvatar.indexOf("/s512-c/") != -1 &&
authorAvatar.indexOf("http:") != 0) {
authorAvatar = "http:" + authorAvatar.replace("/s512-c/", "/s" + avatarSize + "-c/");
} else if (authorAvatar.indexOf("blogblog.com/img/blank.gif") != -1) {
if (defaultAvatar.indexOf("gravatar.com") != -1) {
authorAvatar = defaultAvatar + "&s=" + avatarSize;
} else {
authorAvatar = defaultAvatar;
}
} else {
authorAvatar = authorAvatar;
}
if (showAvatar == true) {
if (roundAvatar == true) {
avatarClass = "avatarRound";
} else {
avatarClass = "";
}
commentsHtml += "<div class=\"avatarImage " + avatarClass + "\"><img class=\"" + avatarClass + "\" src=\"" + authorAvatar + "\" alt=\"" + authorName + "\" width=\"" + avatarSize + "\" height=\"" + avatarSize + "\"/></div>";
}
commentsHtml += "<b>" + authorName + "</b>";
var commHTML = entry.content.$t;
var commBody = commHTML.replace(/(<([^>]+)>)/gi, "");
if (commBody != "" && commBody.length > characters) {
commBody = commBody.substring(0, characters);
commBody += "…";
if (showMorelink == true) {
commBody += "" + moreLinktext + "";
}
} else {
commBody = commBody;
}
commentsHtml += "<span>" + commBody + "</span>";
commentsHtml += "</li></div></a>";
}
}
commentsHtml += "</ul>";
document.write(commentsHtml);
}
commentsHtml += "</ul>";
var hideCSS = "";
if (hideCredits == true) {
hideCSS = "display:none;";
}
//]]>
</script>
<script type="text/javascript" src="/feeds/comments/default?alt=json&callback=ss_recent&&max-results=50">
</script>
3. Terakhir Simpan Dan Cek Hasilnya..