3.08.2009

Последние коментарии

Последние комментарии (гаджет) сделать очень просто. Для этого нужно:
Зайдите в настройки> Макет> Добавить гаджет> HTML/Javascript> создать. В поле ввода введите следующий код:


<script
type="text/javascript">
function
recentcommentDisplay(json) {
if
(recentcommentprocessed){return;}
recentcommentprocessed
= true;

for (var i = 0; i < numcomments; i++) {

var entry = json.feed.entry[i];

var alturl;
if (i == json.feed.entry.length) break;

for (var k = 0; k < entry.link.length; k++) {

if (entry.link[k].rel == 'alternate') {

alturl = entry.link[k].href;

break;

}

}

alturl = alturl.replace("#", "#comment-");

var postlink = alturl.split("#");

postlink = postlink[0];

var linktext = postlink.split("/");

linktext = linktext[5];

linktext = linktext.split(".html");

linktext = linktext[0];

var posttitle = linktext.replace(/-/g," ");

posttitle = posttitle.link(postlink);

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] = "Янв";

monthnames[2] = "Фев";

monthnames[3] = "Март";

monthnames[4] = "Апр";

monthnames[5] = "Май";

monthnames[6] = "Июнь";

monthnames[7] = "Июль";

monthnames[8] = "Авг";

monthnames[9] = "Сент";

monthnames[10] = "Окт";

monthnames[11] = "Нояб";

monthnames[12] = "Дек";

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, "");

if (!standardstyling) document.write('<'+'div
class="bbrecpost">');

if (standardstyling) document.write('<'+'br/>');

if (showcommentdate == true) document.write(cdday + ' ' +
monthnames[parseInt(cdmonth,10)] + ' ');

document.write('<'+'a href="' + alturl + '">' +
entry.author[0].name.$t + '</a> ');

if (showposttitle == true) document.write(': ' + posttitle);

if (!standardstyling) document.write('<'+'/div>'+'<'+'div
class="bbrecpostsum">');

if (standardstyling) document.write('<'+'br/>');

if (comment.length < numchars) {

if (standardstyling) document.write('<'+'i>');

document.write(comment);

if (standardstyling) document.write('<'+'/i>');}

else

{

if (standardstyling) document.write('<'+'i>');

comment = comment.substring(0, numchars);

var quoteEnd = comment.lastIndexOf(" ");

comment = comment.substring(0, quoteEnd);

document.write(comment + '...'+'<'+'a href="' +
alturl + '">(далее)'+'<'+'/a>');

if (standardstyling) document.write('<'+'/i>');}

if (!standardstyling) document.write('<'+'/div>');

if (standardstyling) document.write('<'+'br/>');

}} </script>

<script
src="http://ВашБлог.blogspot.com/feeds/comments/default?alt=json-in-script&callback=recentcommentDisplay"></script>

Не забудьте
вместо слов «Ваш блог» вставить первую
часть url-ла вашего блога.



Последние комментарии