Widget Senarai Pemberi Komen Terbanyak ini adalah hasil ilham daripada Widget Komen Terkini Dengan Avatar Berpusing yang CK postkan sebelum ini. Ia kelihatan agak unik kerana mampu memusingkan avatar pemberi komen terbanyak apabila cursor mengenainya. Selain itu, widget ini memberitahu profil pemberi komen terbanyak dan bilangan komen yang diberi.
Jika mahukan widget ini, sila ikuti langkah-langkah di bawah:
2. Pilih "Layout"
3. Klik "Add a Gadget" pada sidebar
4. Scroll ke bawah sedikit dan klik "HTML/JavaScript"
5. "Copy" semua kod di bawah dan "paste" ke dalam kotak Content
<style type="text/css">
.top-commenter-line img {
border: 2px solid #ffffff;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
border-radius: 100px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
}
.top-commenter-line img:hover {-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
}
.top-commenter-line {margin: 3px 0;}
.top-commenter-line .profile-name-link {padding-left:0;}
.top-commenter-avatar {vertical-align:middle;
}
</style>
<script type="text/javascript">
var maxTopCommenters = 5;
var minComments = 1;
var numDays = 0;
var excludeMe = true;
var excludeUsers = ["Anonymous", "someotherusertoexclude"];
var maxUserNameLength = 42;
var txtTopLine = '<b>[#].</b> [image] [user] ([count])';
var txtNoTopCommenters = '';
var txtAnonymous = '';
var sizeAvatar = 50;
var cropAvatar = true;
var urlNoAvatar = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfTEYshFI2QQlOroDDzk30q3PF6I4fLA3iMd0in-XtDppm9RKYUaz9So82rp036tKvoIC3EbhE2yK6tVuzUNUXvwtenh3rbyXcjL4Z_4F0E28UtoQ8LYgK9tmSNTIgC95D1ePWPQGFFO36/s1600/ck-avatar.jpg";
var urlAnoAvatar = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfTEYshFI2QQlOroDDzk30q3PF6I4fLA3iMd0in-XtDppm9RKYUaz9So82rp036tKvoIC3EbhE2yK6tVuzUNUXvwtenh3rbyXcjL4Z_4F0E28UtoQ8LYgK9tmSNTIgC95D1ePWPQGFFO36/s1600/ck-avatar.jpg' + sizeAvatar;
var urlMyProfile = '';
var urlMyAvatar = '';
// for old IEs & IE modes:
if(!Array.indexOf) {
Array.prototype.indexOf=function(obj) {
for(var i=0;i<this.length;i++) if(this[i]==obj) return i;
return -1;
}}
function replaceTopCmtVars(text, item, position)
{
if(!item || !item.author) return text;
var author = item.author;
var authorUri = "";
if(author.uri && author.uri.$t != "")
authorUri = author.uri.$t;
var avaimg = urlAnoAvatar;
var bloggerprofile = "http://www.blogger.com/profile/";
if(author.gd$image && author.gd$image.src && authorUri.substr(0,bloggerprofile.length) == bloggerprofile)
avaimg = author.gd$image.src;
else {
var parseurl = document.createElement('a');
if(authorUri != "") {
parseurl.href = authorUri;
avaimg = 'http://www.google.com/s2/favicons?domain=' + parseurl.hostname;
}
}
if(urlMyProfile != "" && authorUri == urlMyProfile && urlMyAvatar != "")
avaimg = urlMyAvatar;
if(avaimg == "http://img2.blogblog.com/img/b16-rounded.gif" && urlNoAvatar != "")
avaimg = urlNoAvatar;
var newsize="s"+sizeAvatar;
avaimg = avaimg.replace(/\/s\d\d+-c\//, "/"+newsize+"-c/");
if(cropAvatar) newsize+="-c";
avaimg = avaimg.replace(/\/s\d\d+(-c){0,1}\//, "/"+newsize+"/");
var authorName = author.name.$t;
if(authorName == 'Anonymous' && txtAnonymous != '' && avaimg == urlAnoAvatar)
authorName = txtAnonymous;
var imgcode = '<img class="top-commenter-avatar" height="'+sizeAvatar+'" width="'+sizeAvatar+'"title="'+authorName+'" src="'+avaimg+'" />';
if(authorUri!="") imgcode = '<a href="'+authorUri+'">'+imgcode+'</a>';
if(maxUserNameLength > 3 && authorName.length > maxUserNameLength)
authorName = authorName.substr(0, maxUserNameLength-3) + "...";
var authorcode = authorName;
if(authorUri!="") authorcode = '<a class="profile-name-link" href="'+authorUri+'">'+authorcode+'</a>';
text = text.replace('[user]', authorcode);
text = text.replace('[image]', imgcode);
text = text.replace('[#]', position);
text = text.replace('[count]', item.count);
return text;
}
var topcommenters = {};
var ndxbase = 1;
function showTopCommenters(json) {
var one_day=1000*60*60*24;
var today = new Date();
if(urlMyProfile == "") {
var elements = document.getElementsByTagName("*");
var expr = /(^| )profile-link( |$)/;
for(var i=0 ; i<elements.length ; i++)
if(expr.test(elements[i].className)) {
urlMyProfile = elements[i].href;
break;
}
}
for(var i = 0 ; i < json.feed.entry.length ; i++ ) {
var entry = json.feed.entry[i];
if(numDays > 0) {
var datePart = entry.published.$t.match(/\d+/g); // assume ISO 8601
var cmtDate = new Date(datePart[0],datePart[1]-1,datePart[2],datePart[3],datePart[4],datePart[5]);
//Calculate difference btw the two dates, and convert to days
var days = Math.ceil((today.getTime()-cmtDate.getTime())/(one_day));
if(days > numDays) break;
}
var authorUri = "";
if(entry.author[0].uri && entry.author[0].uri.$t != "")
authorUri = entry.author[0].uri.$t;
if(excludeMe && authorUri != "" && authorUri == urlMyProfile)
continue;
var authorName = entry.author[0].name.$t;
if(excludeUsers.indexOf(authorName) != -1)
continue;
var hash=entry.author[0].name.$t + "-" + authorUri;
if(topcommenters[hash])
topcommenters[hash].count++;
else {
var commenter = new Object();
commenter.author = entry.author[0];
commenter.count = 1;
topcommenters[hash] = commenter;
}
}
if(json.feed.entry.length == 200) {
ndxbase += 200;
document.write('<script type="text/javascript" src="http://'+window.location.hostname+'/feeds/comments/default?redirect=false&max-results=200&start-index='+ndxbase+'&alt=json-in-script&callback=showTopCommenters"></'+'script>');
return;
}
// convert object to array of tuples
var tuplear = [];
for(var key in topcommenters) tuplear.push([key, topcommenters[key]]);
tuplear.sort(function(a, b) {
if(b[1].count-a[1].count)
return b[1].count-a[1].count;
return (a[1].author.name.$t.toLowerCase() < b[1].author.name.$t.toLowerCase()) ? -1 : 1;
});
// list top topcommenters:
var realcount = 0;
for(var i = 0; i < maxTopCommenters && i < tuplear.length ; i++) {
var item = tuplear[i][1];
if(item.count < minComments)
break;
document.write('<di'+'v class="top-commenter-line">');
document.write(replaceTopCmtVars(txtTopLine, item, realcount+1));
document.write('</d'+'iv>');
realcount++;
}
if(!realcount)
document.write(txtNoTopCommenters);
}
document.write('<script type="text/javascript" src="http://'+window.location.hostname+'/feeds/comments/default?redirect=false&max-results=200&alt=json-in-script&callback=showTopCommenters"></'+'script>');
</script>
<span id=ck-wkt><a href=http://cikgukacamata.blogspot.com/2013/06/widget-senarai-pemberi-komen-terbanyak.html target=_blank>Widget Senarai Pemberi Komen Terbanyak</a></span>
<style type=text/css>
#ck-wkt {font-family: Arial,Tahoma;font-size:9px;font-style:italic;padding-top:7px;display:block;text-align:right;}
</style>
.top-commenter-line img {
border: 2px solid #ffffff;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
border-radius: 100px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
}
.top-commenter-line img:hover {-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
}
.top-commenter-line {margin: 3px 0;}
.top-commenter-line .profile-name-link {padding-left:0;}
.top-commenter-avatar {vertical-align:middle;
}
</style>
<script type="text/javascript">
var maxTopCommenters = 5;
var minComments = 1;
var numDays = 0;
var excludeMe = true;
var excludeUsers = ["Anonymous", "someotherusertoexclude"];
var maxUserNameLength = 42;
var txtTopLine = '<b>[#].</b> [image] [user] ([count])';
var txtNoTopCommenters = '';
var txtAnonymous = '';
var sizeAvatar = 50;
var cropAvatar = true;
var urlNoAvatar = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfTEYshFI2QQlOroDDzk30q3PF6I4fLA3iMd0in-XtDppm9RKYUaz9So82rp036tKvoIC3EbhE2yK6tVuzUNUXvwtenh3rbyXcjL4Z_4F0E28UtoQ8LYgK9tmSNTIgC95D1ePWPQGFFO36/s1600/ck-avatar.jpg";
var urlAnoAvatar = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfTEYshFI2QQlOroDDzk30q3PF6I4fLA3iMd0in-XtDppm9RKYUaz9So82rp036tKvoIC3EbhE2yK6tVuzUNUXvwtenh3rbyXcjL4Z_4F0E28UtoQ8LYgK9tmSNTIgC95D1ePWPQGFFO36/s1600/ck-avatar.jpg' + sizeAvatar;
var urlMyProfile = '';
var urlMyAvatar = '';
// for old IEs & IE modes:
if(!Array.indexOf) {
Array.prototype.indexOf=function(obj) {
for(var i=0;i<this.length;i++) if(this[i]==obj) return i;
return -1;
}}
function replaceTopCmtVars(text, item, position)
{
if(!item || !item.author) return text;
var author = item.author;
var authorUri = "";
if(author.uri && author.uri.$t != "")
authorUri = author.uri.$t;
var avaimg = urlAnoAvatar;
var bloggerprofile = "http://www.blogger.com/profile/";
if(author.gd$image && author.gd$image.src && authorUri.substr(0,bloggerprofile.length) == bloggerprofile)
avaimg = author.gd$image.src;
else {
var parseurl = document.createElement('a');
if(authorUri != "") {
parseurl.href = authorUri;
avaimg = 'http://www.google.com/s2/favicons?domain=' + parseurl.hostname;
}
}
if(urlMyProfile != "" && authorUri == urlMyProfile && urlMyAvatar != "")
avaimg = urlMyAvatar;
if(avaimg == "http://img2.blogblog.com/img/b16-rounded.gif" && urlNoAvatar != "")
avaimg = urlNoAvatar;
var newsize="s"+sizeAvatar;
avaimg = avaimg.replace(/\/s\d\d+-c\//, "/"+newsize+"-c/");
if(cropAvatar) newsize+="-c";
avaimg = avaimg.replace(/\/s\d\d+(-c){0,1}\//, "/"+newsize+"/");
var authorName = author.name.$t;
if(authorName == 'Anonymous' && txtAnonymous != '' && avaimg == urlAnoAvatar)
authorName = txtAnonymous;
var imgcode = '<img class="top-commenter-avatar" height="'+sizeAvatar+'" width="'+sizeAvatar+'"title="'+authorName+'" src="'+avaimg+'" />';
if(authorUri!="") imgcode = '<a href="'+authorUri+'">'+imgcode+'</a>';
if(maxUserNameLength > 3 && authorName.length > maxUserNameLength)
authorName = authorName.substr(0, maxUserNameLength-3) + "...";
var authorcode = authorName;
if(authorUri!="") authorcode = '<a class="profile-name-link" href="'+authorUri+'">'+authorcode+'</a>';
text = text.replace('[user]', authorcode);
text = text.replace('[image]', imgcode);
text = text.replace('[#]', position);
text = text.replace('[count]', item.count);
return text;
}
var topcommenters = {};
var ndxbase = 1;
function showTopCommenters(json) {
var one_day=1000*60*60*24;
var today = new Date();
if(urlMyProfile == "") {
var elements = document.getElementsByTagName("*");
var expr = /(^| )profile-link( |$)/;
for(var i=0 ; i<elements.length ; i++)
if(expr.test(elements[i].className)) {
urlMyProfile = elements[i].href;
break;
}
}
for(var i = 0 ; i < json.feed.entry.length ; i++ ) {
var entry = json.feed.entry[i];
if(numDays > 0) {
var datePart = entry.published.$t.match(/\d+/g); // assume ISO 8601
var cmtDate = new Date(datePart[0],datePart[1]-1,datePart[2],datePart[3],datePart[4],datePart[5]);
//Calculate difference btw the two dates, and convert to days
var days = Math.ceil((today.getTime()-cmtDate.getTime())/(one_day));
if(days > numDays) break;
}
var authorUri = "";
if(entry.author[0].uri && entry.author[0].uri.$t != "")
authorUri = entry.author[0].uri.$t;
if(excludeMe && authorUri != "" && authorUri == urlMyProfile)
continue;
var authorName = entry.author[0].name.$t;
if(excludeUsers.indexOf(authorName) != -1)
continue;
var hash=entry.author[0].name.$t + "-" + authorUri;
if(topcommenters[hash])
topcommenters[hash].count++;
else {
var commenter = new Object();
commenter.author = entry.author[0];
commenter.count = 1;
topcommenters[hash] = commenter;
}
}
if(json.feed.entry.length == 200) {
ndxbase += 200;
document.write('<script type="text/javascript" src="http://'+window.location.hostname+'/feeds/comments/default?redirect=false&max-results=200&start-index='+ndxbase+'&alt=json-in-script&callback=showTopCommenters"></'+'script>');
return;
}
// convert object to array of tuples
var tuplear = [];
for(var key in topcommenters) tuplear.push([key, topcommenters[key]]);
tuplear.sort(function(a, b) {
if(b[1].count-a[1].count)
return b[1].count-a[1].count;
return (a[1].author.name.$t.toLowerCase() < b[1].author.name.$t.toLowerCase()) ? -1 : 1;
});
// list top topcommenters:
var realcount = 0;
for(var i = 0; i < maxTopCommenters && i < tuplear.length ; i++) {
var item = tuplear[i][1];
if(item.count < minComments)
break;
document.write('<di'+'v class="top-commenter-line">');
document.write(replaceTopCmtVars(txtTopLine, item, realcount+1));
document.write('</d'+'iv>');
realcount++;
}
if(!realcount)
document.write(txtNoTopCommenters);
}
document.write('<script type="text/javascript" src="http://'+window.location.hostname+'/feeds/comments/default?redirect=false&max-results=200&alt=json-in-script&callback=showTopCommenters"></'+'script>');
</script>
<span id=ck-wkt><a href=http://cikgukacamata.blogspot.com/2013/06/widget-senarai-pemberi-komen-terbanyak.html target=_blank>Widget Senarai Pemberi Komen Terbanyak</a></span>
<style type=text/css>
#ck-wkt {font-family: Arial,Tahoma;font-size:9px;font-style:italic;padding-top:7px;display:block;text-align:right;}
</style>
Nota:
-
Kod Warna Biru:
Untuk menukar warna border pada avatar -
Kod Warna Hijau:
Untuk memaparkan jumlah bilangan pemberi komen terbanyak -
Kod Warna Merah:
Untuk sembunyikan profil dan avatar anda daripada tersenarai dalam pemberi komen terbanyak, gantikan dengan nama profil anda sendiri. (Contoh: "someotherusertoexclude" diganti dengan "Cikgu Kacamata") -
Kod Warna Ungu:
Untuk menukar saiz avatar
Nice share! SW nak try letak juga lah kat blog. Thanks bro.
ReplyDeleteYa, silakan SW. Thanks anyway :)
Deletenice sharing..nama kita ada gak..hihi
ReplyDeleteThanks cik Normi. Setakat ni Normi di ranking ke-2 tu ;)
Deletenak nak nak...
ReplyDeleteBoleh...silakan ambil mama ;)
Deleteok nice! tgk pun skang ni dah banyak orang bubuh kat blog ek... sy nak buat gaklah nanti... tp yg menariknye kat mane pun ade widget ni, popular name is MissAiza.. tahniah...
ReplyDeleteBg CK widget ni mmg berguna dan menghargai sesiapa yang buat komen kat blog kita. Kepada Mizz Aiza CK ucapkan berbyk2 terima kasih kerana selalu mengunjung blog CK...blogger yg lain pun sama juga. Terima kasih tak terhingga CK ucapkan kerana sudi jengah di sini ;)
Deletesalam CK.owh nanti kalau saya nak tukar..bolehlah singgah follow tutor ni.dah bookmark page ni he3..
ReplyDeleteBoleh bangat aLeaSaRa. Boleh amik anytime. Thanks bookmarked post ni ;)
Deletemenarik widget ni CK.. yang aiza punya ada orang tolong buatkan.. tapi avatar dia takde la bergerak macam yang CK buat tu.. nice sharing.. :D
ReplyDeleteHehe, CK nak buat kelainan sikit. Terima kasih Aiza coz alwayz be my part in here ;)
Deleteyeayy, jadi.. tapi nama anna ada skali.. huhuhuu.. cmna ni?
ReplyDeleteAlhamdulillah...
DeleteOk, untuk sembunyikan komen kita sendiri, Anna perlu ubah ini:
-->>> Cari kod ni:
var excludeUsers = ["Anonymous", "someotherusertoexclude"];
-->>> Gantikan; someotherusertoexclude dengan ANNA MARIANA
*sebenarnya itu nama profil blog kita. Ikut saja nama profil kita; kalau huruf besar, gunakan huruf besar; kalau nama ada lebih satu perkataan yang berjarak, ikut saja jarak tu)
Harap ini dapat membantu Anna ;)
Jika ada pertanyaan, roger je CK anytime!
Boleh...amik je cik akak...:)
ReplyDeletesalam..
ReplyDeleteAlhamdulillah menjadi..
kalo kita nak bagi jadi 10 pengomen tegar cmna ye?
Alhamdulillah...
DeleteUntuk senaraikan 10 pengomen tegar, cari kod ini:
var maxTopCommenters = 5;
Gantikan 5 dengan 10
Itu saja ;)
salam..
ReplyDeletealhamdulillah..
berjaya..
thanks sudi sharing..
:)
Alhamdulillah...ya sama2 ;)
Deletewah langsung aku coba ya, terimaksih telah berbagi
ReplyDeleteYa...sama-sama. Terima kasih menggunakan widget ini :)
DeleteThnaks.... dah masukkan dalam blog.. hehehe
ReplyDeleteYr welcome my friend :D
Deletesalam cikgu..saya ada problem dengan widget jenis cloud.dah beberapa hari buat hal..menghilang he3..
ReplyDeletesaya dah pasang yang baru ikut tutor ni.tapi lupalah,macam mana ye nak setting komen mengikut bulan,sebab keluar pulak jumlah semua yg pernah mereka komen dari awal mereka singgah dulu2...terima kasih ye cikgu ^^
takpe cikgu saya dah edit sendiri tadi he3.selamat berpuasa ^^
ReplyDeleteYeke...ok, kalau lea ada ape2 nak tanya, roger je CK anytime ;)
Deletesalam cikgu,akak dah buat namun nama sendiri tetap muncul juga..nape ek?
ReplyDeleteSalam Aidilfitri kak tie. Utk disable komen akak sendiri, akak tgk komen Anna Mariana kat atas. Caranya sama je cuma akan perlu ubah perkataan tu dgn Kak Tie saja. Maaf CK tak dpt beri penerangan lengkap sbb guna hp...
ReplyDeleteThis comment has been removed by the author.
ReplyDeletewah bagus widgetnya nih
ReplyDeleteNak buat jugak la.
ReplyDeleteThank informasinya...
ReplyDeleteAssalam CK : baru try widget ini...terima kasih perkongsian, ana follow CK #404
ReplyDeleteNICE.... ciut miut.. :D Terima kasih bnyk ya
ReplyDeleteTerima Kasih,
ReplyDeleteSaya dah cuba banyak widget untuk top commenter..
finally, this one is the best.. :D
Salam CK,
ReplyDeletemacam mana nak jadikan widget ni monthly...
saya dah tukar varian numdays = 30..
tapi bila masuk bulan baru.. tak tertukar pun..
harap CK boleh bantu.. :)
salam ramadhan,
ReplyDeletemohon share widget top commentar ye..
salam hari raya..eda mahu share ini yer..best sangat..
ReplyDeletefollow sini jugak
ReplyDeletetQ cikgu...dah copy widget ni....hehehe
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteNice widget. Sy copy & letak di blog ye. TQ cikgu
ReplyDeletevery nice sharee. nanti nak cuba lah :)
ReplyDeletehihi.. sy copy ye.. comey... :)
ReplyDeletetumpang copy&paste di blog ye!!
ReplyDelete~wink~
Salam singgah petang cikgu...diana try kat blog diana....menjadi lah...tq cikgu....
ReplyDeleteKita guna ye ^_^ Dah lama cari tutorial commenters ni. Terima kasih.
ReplyDeleteKita share dekat blog. Mohon halalkan ye ^_^
ReplyDeletenice. nak try nanti
ReplyDeleteJOM KE BLOG UYUL >> Uyul Rosli | Blonolog Blogger Picisan
Thansk informasinya...
ReplyDeleteBlognya keren gan...
ReplyDeletesaya punya tak jadi. tak tahu sebab apa?
ReplyDeleteWidget nie tak keluar gambar plak hari nie ...
ReplyDeleteindirmen
ReplyDeletesalam kenal om, blog comment nyari backlink
ReplyDeleteJasa Pembuatan Website Murah di Bali
شراء اثاث مستعمل بالرياض NVrUdet1Ju
ReplyDelete