document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <style type="text/css">
  2. .recent-comment        { margin-bottom:10px; padding-left: 24px; }
  3. .recent-comment-admin  { background-color: #F4F4F4; }
  4. .recent-comment-ico    { margin-left:-20px;margin-top:4px;float:left;}
  5. .recent-comment-header {}
  6. .recent-comment-body   { padding-right: 4px; font-size: 95%;}
  7. .recent-comment-footer { font-size: 85%; }
  8. </style>
  9. <script type="text/javascript">
  10. //
  11. // Recent Comments blogger gadget by MS-potilas 2011
  12. // see http://yabtb.blogspot.com/2011/11/return-of-better-recent-comments-gadget.html
  13. //
  14. // CONFIG:
  15. var numRecentComments = 5;
  16. var numPerPost = 2; // max comments per post (to try) or 0
  17. var maxCommentChars = 90;
  18. var maxPostTitleChars = 0; // if 0, use full post title
  19.  
  20. var txtWrote = \'wrote:\';
  21. var txtMore = \'Continue >>\';
  22. var txtTooltip = \'[user] on &quot;[title]&quot; - [date MM/dd/yy hh:mm]\';
  23. var txtAnonymous = \'\'; // empty, or Anonymous user name localized
  24. // Variables [xxx] in texts:
  25. // supports [title], [user], [date], [time], [datetime], [date format]
  26. // format supports: yyyy=long year, yy=short year, MM=month(01-12), dd=monthday, hh=hour, mm=min, ss=sec
  27.  
  28. var getTitles = true;   // false faster
  29. var trueAvatars = true; // false faster
  30. var urlMyAvatar = \'\';   // can be empty (then it is fetched) or url to image
  31. var urlMyProfile = \'\';  // set if you have no profile gadget on page
  32. //
  33. var urlAnoAvatar = \'http://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&s=16\';
  34. var maxResultsPosts = "";       // or for example "&max-results=100"
  35. var maxResultsComments = "";    // or for example "&max-results=300"
  36. // CONFIG END
  37. var urlToTitle = {};
  38. function replaceVars(text, user, title, date) {
  39.   text = text.replace(\'[user]\', user);
  40.   text = text.replace(\'[date]\', date.toLocaleDateString());
  41.   text = text.replace(\'[datetime]\', date.toLocaleString());
  42.   text = text.replace(\'[time]\', date.toLocaleTimeString());
  43.   text = text.replace(\'[title]\', title.replace(/\\"/g,\'&quot;\'));
  44.   var i = text.indexOf("[date ");
  45.   if(i > -1) {
  46.     var format = /\\[date\\s+(.+?)\\]/.exec(text)[1];
  47.     if(format != \'\') {
  48.       var txtDate = format.replace(/yyyy/i, date.getFullYear());
  49.       txtDate = txtDate.replace(/yy/i, date.getFullYear().toString().slice(-2));
  50.       txtDate = txtDate.replace("MM", String("0"+(date.getMonth()+1)).slice(-2));
  51.       txtDate = txtDate.replace("mm", String("0"+date.getMinutes()).slice(-2));
  52.       txtDate = txtDate.replace("ss", String("0"+date.getSeconds()).slice(-2));
  53.       txtDate = txtDate.replace("dd", String("0"+date.getDate()).slice(-2));
  54. //or: txtDate = txtDate.replace("dd", date.getDate());
  55.       txtDate = txtDate.replace("hh", String("0"+date.getHours()).slice(-2));
  56. //or: txtDate = txtDate.replace("hh", date.getHours());
  57.       text = text.replace(/\\[date\\s+(.+?)\\]/, txtDate)
  58.     }
  59.   }
  60.   return text;
  61. }
  62. if(urlMyProfile == "") {
  63.   var elements = document.getElementsByTagName("*");
  64.   var expr = /(^| )profile-link( |$)/;
  65.   for(var i=0 ; i<elements.length ; i++)
  66.     if(expr.test(elements[i].className)) {
  67.       urlMyProfile = elements[i].href;
  68.       break;
  69.     }
  70. }
  71. function getPostUrlsForComments(json) {
  72.   for(var i = 0 ; i < json.feed.entry.length ; i++ ) {
  73.     var entry = json.feed.entry[i];
  74.     var href;
  75.     for (var k = 0; k < entry.link.length; k++ ) {
  76.       if (entry.link[k].rel == \'alternate\') {
  77.         href = entry.link[k].href;
  78.         break;
  79.       }
  80.     }
  81.     urlToTitle[href] = entry.title.$t;
  82.   }
  83. }
  84. function showRecentComments(json) {
  85.   var postHandled = {};
  86.   var j = 0;
  87.   if(numPerPost) {
  88.     while(numPerPost < numRecentComments) {
  89.       for(var i = 0 ; i < json.feed.entry.length ; i++ ) {
  90.         var entry = json.feed.entry[i];
  91.         if(entry["thr$in-reply-to"]) {
  92.           if(!postHandled[entry["thr$in-reply-to"].href])
  93.               postHandled[entry["thr$in-reply-to"].href] = 1;
  94.           else
  95.               postHandled[entry["thr$in-reply-to"].href]++;
  96.           if(postHandled[entry["thr$in-reply-to"].href] <= numPerPost)
  97.             j++;
  98.         }
  99.       }
  100.       if(j >= numRecentComments)
  101.         break;
  102.       numPerPost++;
  103.       j = 0;
  104.       postHandled = {};
  105.     }
  106.     if(numRecentComments == numPerPost)
  107.        numPerPost = 0;
  108.   }
  109.   postHandled = {};
  110.   j = 0;
  111.   for(var i = 0 ; j < numRecentComments && i < json.feed.entry.length ; i++ ) {
  112.     var entry = json.feed.entry[i];
  113.     if(numPerPost && postHandled[entry["thr$in-reply-to"].href] && postHandled[entry["thr$in-reply-to"].href] >= numPerPost)
  114.       continue;
  115.     if(entry["thr$in-reply-to"]) {
  116.       if(!postHandled[entry["thr$in-reply-to"].href])
  117.           postHandled[entry["thr$in-reply-to"].href] = 1;
  118.       else
  119.           postHandled[entry["thr$in-reply-to"].href]++;
  120.       j++;
  121.       var href=\'\';
  122.       for (var k = 0; k < entry.link.length; k++ ) {
  123.         if (entry.link[k].rel == \'alternate\') {
  124.           href = entry.link[k].href;
  125.           break;
  126.         }
  127.       }
  128.       if(href==\'\') {j--; continue; }
  129.       var hrefPost = href.split("?")[0];
  130.       var comment = "";
  131.       if("content" in entry) comment = entry.content.$t;
  132.       else                   comment = entry.summary.$t;
  133.       comment = comment.replace(/<br[^>]*>/ig, " ");
  134.       comment = comment.replace(/<\\S[^>]*>/g, "");
  135.       var postTitle="-";
  136.       if(urlToTitle[hrefPost]) postTitle=urlToTitle[hrefPost];
  137.       else {
  138.         if(hrefPost.match(/\\/([^/]*)\\.html/)) postTitle = hrefPost.match(/\\/([^/]*)\\.html/)[1].replace(/_\\d{2}$/, "");
  139.         postTitle = postTitle.replace(/-/g," ");
  140.         postTitle = postTitle[0].toUpperCase() + postTitle.slice(1);
  141.       }
  142.       if(maxPostTitleChars && postTitle.length > maxPostTitleChars) {
  143.         postTitle = postTitle.substring(0, maxPostTitleChars);
  144.         var indexBreak = postTitle.lastIndexOf(" ");
  145.         postTitle = postTitle.substring(0, indexBreak) + "...";
  146.       }
  147.  
  148.       var authorName = entry.author[0].name.$t
  149.       var authorUri = ""
  150.       if(entry.author[0].uri && entry.author[0].uri.$t != "")
  151.         authorUri = entry.author[0].uri.$t;
  152.    
  153.       var avaimg = urlAnoAvatar;
  154.       var bloggerprofile = "http://www.blogger.com/profile/";
  155.       if(trueAvatars && authorUri.substr(0,bloggerprofile.length) == bloggerprofile)
  156.           avaimg = "http://avafavico.appspot.com/?userid=" + authorUri.substr(bloggerprofile.length);
  157.       else {
  158.         var parseurl = document.createElement(\'a\');
  159.         if(authorUri != "") {
  160.           parseurl.href = authorUri;
  161.           avaimg = \'http://www.google.com/s2/favicons?domain=\' + parseurl.hostname;
  162.         }
  163.       }
  164.       if(authorUri == urlMyProfile && urlMyAvatar != "")
  165.         avaimg = urlMyAvatar;
  166.       if(authorName == \'Anonymous\' && txtAnonymous != \'\' && avaimg == urlAnoAvatar)
  167.         authorName = txtAnonymous;
  168.       var imgcode = \'<img height="16" width="16" title="\'+authorName+\'" src="\'+avaimg+\'" />\';
  169.       if (authorUri!="") imgcode = \'<a href="\'+authorUri+\'">\'+imgcode+\'</a>\';
  170.  
  171.       var clsAdmin = "";
  172.       if(authorUri == urlMyProfile)
  173.           clsAdmin = " recent-comment-admin";
  174.  
  175.       var datePart = entry.published.$t.match(/\\d+/g); // assume ISO 8601
  176.       var cmtDate = new Date(datePart[0],datePart[1]-1,datePart[2],datePart[3],datePart[4],datePart[5]);
  177.  
  178.       var txtHeader = txtWrote;
  179.       if(txtWrote.indexOf(\'[\')==-1)
  180.         txtHeader = authorName + \' \' + txtWrote;
  181.       else
  182.         txtHeader = replaceVars(txtHeader, authorName, postTitle, cmtDate);
  183.  
  184.       var tooltip = replaceVars(txtTooltip, authorName, postTitle, cmtDate);
  185.       if(!/#/.test(href)) href += "#comments";
  186.       document.write(\'<div title="\'+tooltip+\'" class="recent-comment\'+clsAdmin+\'">\');
  187.       document.write(\'<div title="\'+tooltip+\'" class="recent-comment-header\'+clsAdmin+\'"><div title="\'+tooltip+\'" class="recent-comment-ico\'+clsAdmin+\'">\'+imgcode+\'</div><a title="\'+tooltip+\'" href="\' + href + \'">\' + txtHeader + \' </a></div>\');
  188.       if(comment.length < maxCommentChars)
  189.         document.write(\'<div title="\'+tooltip+\'" class="recent-comment-body\'+clsAdmin+\'">\' + comment + \'</div>\');
  190.       else {
  191.         comment = comment.substring(0, maxCommentChars);
  192.         var indexBreak = comment.lastIndexOf(" ");
  193.         comment = comment.substring(0, indexBreak);
  194.         document.write(\'<div title="\'+tooltip+\'" class="recent-comment-body\'+clsAdmin+\'">\' + comment + \'...</div>\');
  195.         if(txtMore != "") {
  196.           var moretext = replaceVars(txtMore, authorName, postTitle, cmtDate);
  197.           document.write(\'<div title="\'+tooltip+\'" class="recent-comment-footer\'+clsAdmin+\'"><a title="\'+tooltip+\'" href="\' + href + \'">\' + moretext + \'</a></div>\');
  198.         }
  199.       }
  200.       document.write(\'</div>\');
  201.     }
  202.   }
  203. }
  204. if(getTitles)
  205.   document.write(\'<script type="text/javascript" src="http://\'+window.location.hostname+\'/feeds/posts/summary?redirect=false\'+maxResultsPosts+\'&alt=json-in-script&callback=getPostUrlsForComments"></\'+\'script>\');
  206. document.write(\'<script type="text/javascript" src="http://\'+window.location.hostname+\'/feeds/comments/default?redirect=false\'+maxResultsComments+\'&alt=json-in-script&callback=showRecentComments"></\'+\'script>\');
  207. </script>
');