document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <style type="text/css">
  2. .recent-comment { padding-bottom:10px; }
  3. .recent-comment-header {}
  4. .recent-comment-body {}
  5. .recent-comment-footer { font-size: 80%; }
  6. </style>
  7. <script type="text/javascript">
  8.  
  9. // Recent Comments blogger gadget by MS-potilas 2011
  10. // see http://yabtb.blogspot.com
  11.  
  12. var numRecentComments = 5;
  13. var numCommentChars = 80;
  14. var numPerPost = 2; // max comments per post (to try) or 0
  15. var txtWrote = \'wrote:\';
  16. var txtMore = \'Continue >>\';
  17. var getTitles = true;
  18.  
  19. var maxResultsPosts = "";    // or for example "&max-results=200"
  20. var maxResultsComments = ""; // or for example "&max-results=400"
  21. var urlToTitle = {};
  22. function getPostUrlsForComments(json) {
  23.   for(var i = 0 ; i < json.feed.entry.length ; i++ ) {
  24.     var entry = json.feed.entry[i];
  25.     var href;
  26.     for (var k = 0; k < entry.link.length; k++ ) {
  27.       if (entry.link[k].rel == \'alternate\') {
  28.         href = entry.link[k].href;
  29.         break;
  30.       }
  31.     }
  32.     urlToTitle[href] = entry.title.$t;
  33.   }
  34. }
  35. function showRecentComments(json) {
  36.   var postHandled = {};
  37.   var j = 0;
  38.   if(numPerPost) {
  39.     while(numPerPost < numRecentComments) {
  40.       for(var i = 0 ; i < json.feed.entry.length ; i++ ) {
  41.         var entry = json.feed.entry[i];
  42.         if(!postHandled[entry["thr$in-reply-to"].href])
  43.             postHandled[entry["thr$in-reply-to"].href] = 1;
  44.         else
  45.             postHandled[entry["thr$in-reply-to"].href]++;
  46.         if(postHandled[entry["thr$in-reply-to"].href] <= numPerPost)
  47.           j++;
  48.       }
  49.       if(j >= numRecentComments)
  50.         break;
  51.       numPerPost++;
  52.       j = 0;
  53.       postHandled = {};
  54.     }
  55.     if(numRecentComments == numPerPost)
  56.        numPerPost = 0;
  57.   }
  58.   postHandled = {};
  59.   j = 0;
  60.   for(var i = 0 ; j < numRecentComments && i < json.feed.entry.length ; i++ ) {
  61.     var entry = json.feed.entry[i];
  62.     if(numPerPost && postHandled[entry["thr$in-reply-to"].href] && postHandled[entry["thr$in-reply-to"].href] >= numPerPost)
  63.       continue;
  64.     if(!postHandled[entry["thr$in-reply-to"].href])
  65.         postHandled[entry["thr$in-reply-to"].href] = 1;
  66.     else
  67.         postHandled[entry["thr$in-reply-to"].href]++;
  68.     j++;
  69.     var href=\'\';
  70.     for (var k = 0; k < entry.link.length; k++ ) {
  71.       if (entry.link[k].rel == \'alternate\') {
  72.         href = entry.link[k].href;
  73.         break;
  74.       }
  75.     }
  76.     if(href==\'\') {j--; continue; }
  77.     var hrefPost = href.split("?")[0];
  78.     var comment = "";
  79.     if("content" in entry)
  80.       comment = entry.content.$t;
  81.     else
  82.       comment = entry.summary.$t;
  83.     comment = comment.replace(/<br[^>]*>/ig, " ");
  84.     comment = comment.replace(/<\\S[^>]*>/g, "");
  85.     var postTitle="-";
  86.     if(urlToTitle[hrefPost]) postTitle=urlToTitle[hrefPost];
  87.     else {
  88.       if(hrefPost.match(/\\/([^/]*)\\.html/)) postTitle = hrefPost.match(/\\/([^/]*)\\.html/)[1].replace(/_\\d{2}$/, "");
  89.       postTitle = postTitle.replace(/-/g," ");
  90.       postTitle = postTitle[0].toUpperCase() + postTitle.slice(1);
  91.     }
  92.     document.write(\'<div class="recent-comment"><div class="recent-comment-header"><a title="\'+postTitle+\'" href="\' + href + \'">\' + entry.author[0].name.$t + \' \' + txtWrote + \' </a></div>\');
  93.     if(comment.length < numCommentChars)
  94.       document.write(\'<div class="recent-comment-body">\' + comment + \'</div>\');
  95.     else {
  96.       comment = comment.substring(0, numCommentChars);
  97.       var indexBreak = comment.lastIndexOf(" ");
  98.       comment = comment.substring(0, indexBreak);
  99.       document.write(\'<div class="recent-comment-body">\' + comment + \'...</div><div class="recent-comment-footer"><a title="\'+postTitle+\'" href="\' + href + \'">\' + txtMore + \'</a></div>\');
  100.     }
  101.     document.write(\'</div>\');
  102.   }
  103. }
  104. if(getTitles)
  105.   document.write(\'<script type="text/javascript" src="http://\'+window.location.hostname+\'/feeds/posts/summary?redirect=false\'+maxResultsPosts+\'&alt=json-in-script&callback=getPostUrlsForComments"></\'+\'script>\');
  106. document.write(\'<script type="text/javascript" src="http://\'+window.location.hostname+\'/feeds/comments/default?redirect=false\'+maxResultsComments+\'&alt=json-in-script&callback=showRecentComments"></\'+\'script>\');
  107. </script>
');