Advertisement
Guest User

Script Recent Post

a guest
Mar 28th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.91 KB | None | 0 0
  1. // ----------------------------------------
  2. // SHOW RECENT POST
  3. // ----------------------------------------
  4. // This functions takes a blogger-feed in JSON
  5. // format and displays it.
  6. //
  7. // Version: 2.1
  8. // Date:    2007-02-02
  9. // Author:  Hans Oosting
  10. // URL:     beautifulbeta.blogspot.com
  11. // ----------------------------------------
  12.  
  13. function showrecentposts(json) {
  14.  
  15.   for (var i = 0; i < numposts; i++) {
  16.     var entry = json.feed.entry[i];
  17.     var posttitle = entry.title.$t;
  18.     var posturl;
  19.     if (i == json.feed.entry.length) break;
  20.     for (var k = 0; k < entry.link.length; k++) {
  21.       if (entry.link[k].rel == 'alternate') {
  22.         posturl = entry.link[k].href;
  23.         break;
  24.       }
  25.     }
  26.     posttitle = posttitle.link(posturl);
  27.     var readmorelink = "(Baca)";
  28.     readmorelink = readmorelink.link(posturl);
  29.     var postdate = entry.published.$t;
  30.     var cdyear = postdate.substring(0,4);
  31.     var cdmonth = postdate.substring(5,7);
  32.     var cdday = postdate.substring(8,10);
  33.     var monthnames = new Array();
  34.     monthnames[1] = "Jan";
  35.     monthnames[2] = "Feb";
  36.     monthnames[3] = "Mar";
  37.     monthnames[4] = "Apr";
  38.     monthnames[5] = "May";
  39.     monthnames[6] = "Jun";
  40.     monthnames[7] = "Jul";
  41.     monthnames[8] = "Aug";
  42.     monthnames[9] = "Sep";
  43.     monthnames[10] = "Oct";
  44.     monthnames[11] = "Nov";
  45.     monthnames[12] = "Dec";
  46.     if ("content" in entry) {
  47.       var postcontent = entry.content.$t;}
  48.     else
  49.     if ("summary" in entry) {
  50.       var postcontent = entry.summary.$t;}
  51.     else var postcontent = "";
  52.     var re = /<\S[^>]*>/g;
  53.     postcontent = postcontent.replace(re, "");
  54.     if (!standardstyling) document.write('<div class="bbrecpost">');
  55.     if (standardstyling) document.write('<br/>');
  56.     document.write(posttitle);
  57.     if (showpostdate == true) document.write(' - ' + monthnames[parseInt(cdmonth,10)] + ' ' + cdday);
  58.     if (!standardstyling) document.write('</div><div class="bbrecpostsum"">');
  59.     if (showpostsummary == true) {
  60.       if (standardstyling) document.write('<br/>');
  61.       if (postcontent.length < numchars) {
  62.          if (standardstyling) document.write('<i>');
  63.          document.write(postcontent);
  64.          if (standardstyling) document.write('</i>');}
  65.       else {
  66.          if (standardstyling) document.write('<i>');
  67.          postcontent = postcontent.substring(0, numchars);
  68.          var quoteEnd = postcontent.lastIndexOf(" ");
  69.          postcontent = postcontent.substring(0,quoteEnd);
  70.          document.write(postcontent + '...' + readmorelink);
  71.          if (standardstyling) document.write('</i>');}
  72. }
  73.     if (!standardstyling) document.write('</div>');
  74.     if (standardstyling) document.write('<br/>');
  75. }
  76. if (!standardstyling) document.write('<div class="bbwidgetfooter">');
  77. if (standardstyling) document.write('<br/>');
  78. document.write('<span style="font-size:80%;"></span>');
  79. if (!standardstyling) document.write('</div>');
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement