| 5 comments ]

Quick Post: Buat para blogger yang blom punya Recent Comment Widget di blog kamu seperti Andie & Ivan #ahaha... beberapa teman saya. Kali ini saya akan memberikan Script tersebut yang sedikit beda. Yang pasti dengan tampilan yang lebih menarik dan mudah untuk memasangnya. Jadi bagi Andie & Ivan sobat blogger yang tidak begitu mengerti tentang Java script-pun bisa menggunakanya.



  • Login Blogger>Layout>Add a Gadget (pilih: HTML/Javascript>
  • Copy>Paste script dibawah ini.



<ul><script style="text/javascript">
function showrecentcomments(json) {
for (var i = 0; i < 5; i++) {
var entry = json.feed.entry[i];
var ctlink;
var commentdate = entry.published.$t;
var cdyear = commentdate.substring(0,4);
var cdmonth = commentdate.substring(5,7);
var cdday = commentdate.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 (i == json.feed.entry.length) break;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
ctlink = entry.link[k].href;
break;
}
}
ctlink = ctlink.replace("#", "#comment-");
var ptlink = ctlink.split("#");
ptlink = ptlink[0];
var txtlink = ptlink.split("/");
txtlink = txtlink[5];
txtlink = txtlink.split(".html");
txtlink = txtlink[0];
var pttitle = txtlink.replace(/-/g," ");
pttitle = pttitle.link(ptlink);
if ("content" in entry) {
var comment = entry.content.$t;}
else
if ("summary" in entry) {
var comment = entry.summary.$t;}
else var comment = "";
var re = /<s[^>]*>/g;
comment = comment.replace(re, "");

document.write('<li>');
if (comment.length < 50) {
document.write('<div style="font-size:90%;background-color: #E8EEFA;border: #C3D9FF 1px dashed;margin-right:5px">' + monthnames[parseInt(cdmonth,10)] + ' ' + cdday);
document.write(' - ' + entry.author[0].name.$t + ' commented on');
document.write(' ' + pttitle + ':</div>');
document.write(comment);
}
else
{
comment = comment.substring(0, 50);
var quoteEnd = comment.lastIndexOf(" ");
comment = comment.substring(0, quoteEnd);
document.write('<div style="font-size:90%;background-color: #E8EEFA;border: #C3D9FF 1px dashed;margin-right:5px">' + monthnames[parseInt(cdmonth,10)] + ' ' + cdday);
document.write(' - ' + entry.author[0].name.$t + ' commented on');
document.write(' ' + pttitle + ':</div>');
document.write(comment + '...<a href="' + ctlink + '">(more)</a>');
}
}
document.write('</li>');
}
</script>
<script src="http://tipspack.blogspot.com/feeds/comments/default?alt=json-in-script&callback=showrecentcomments">
</script></ul>
<noscript>You need to enable JavaScript to read this.</noscript>

Note:
  • (var i = 0; i < 5; i++) angka 5 adalah jumlah banyaknya comment yang ditampilkan
  • Ganti http://tipspack.blogspot.com dengan alamat blog kamu.
Selamat mencoba....

5 comments

Andie Gokil said... @ October 16, 2009 at 4:30 PM

pertamax!! woi. ak punya recent comment dudul. si ivan yg ga punya. hahahaha. #bakar #sunat

Tipspack said... @ October 16, 2009 at 4:36 PM

Ahaha... Sori gan... Tapi kayanya punyamu masi yg lama. punyaku lebih keren #sombong

Ivan@mobii said... @ October 16, 2009 at 5:15 PM

Hahaha, ntr d coba.

Bayu The Maniac said... @ October 16, 2009 at 10:19 PM

udah lama nih nggak koment ke sini ...
hehehe ...

Bayu The Maniac said... @ October 16, 2009 at 10:20 PM

kelimaks ...
langsung minggat ...

Post a Comment