Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- place this code on a page in your blog -->
- <script type="text/javascript" src="https://www.google.com/jsapi"></script>
- <script type="text/javascript">
- // Posts in chronological order from feed / MS-potilas 2011 yabtb.blogspot.com
- // Configuration:
- var maxResults = 500; // 1-500 (500 is max possible)
- var numPerPage = 7; // post per page, number or "all"
- var feedURI = "/feeds/posts/default";
- // full url could be used, too (read from another blog):
- // var feedURI = "http://yabtb.blogspot.com/feeds/posts/default";
- google.load("feeds", "1");
- var theResult = null;
- feedURI = feedURI + "?max-results="+maxResults+"&redirect=false";
- var goodGoogle = google;
- function doThings()
- {
- google = goodGoogle;
- var result = theResult;
- if (!result.error) {
- var container = document.getElementById("feedDiv");
- container.innerHTML = "";
- var strBuffer= "";
- var j = 0;
- var base = parseInt(window.location.hash.replace("#", ""));
- if(isNaN(base) || !base) base = 0;
- if(window.location.hash == "#all" || window.location.hash == "all" || numPerPage == "all")
- numPerPage = result.feed.entries.length;
- for (var i = result.feed.entries.length-1-base; j < numPerPage && i >= 0; i--) {
- var entry = result.feed.entries[i];
- postDate = new Date(entry.publishedDate);
- strBuffer = strBuffer + "<h2 class=\"date-header\">" + postDate.toDateString() + "</h2>";
- strBuffer = strBuffer + "<h3 class=\"post-title entry-title\"><a href=\"" + entry.link + "\">"+ entry.title + "</a></h3><br />";
- strBuffer = strBuffer + entry.content + "<div class=\"post-footer-line post-footer-line-1\"><div class=\"post-footer\">";
- strBuffer = strBuffer + "Posted by " + entry.author + " at " + postDate.getHours() + ":" + (postDate.getMinutes() < 10 ? "0":"") + postDate.getMinutes();
- strBuffer = strBuffer + " <a href=\"" + entry.link + "#comments\">Comments</a>";
- if(entry.categories.length) {
- strBuffer = strBuffer + "<br />Labels: ";
- for(var z = 0 ; z < entry.categories.length ; z++) {
- if(z) strBuffer = strBuffer + ", ";
- strBuffer = strBuffer + "<a href=\"/search/label/" + encodeURIComponent(entry.categories[z]) + "\">" + entry.categories[z] + "</a>";
- }
- }
- strBuffer = strBuffer + "</div></div><br /><br />";
- j++;
- }
- strBuffer = strBuffer + "<div style=\"margin-bottom: -1.5em; text-align: center\"><a onclick=\"setTimeout(doThings,500)\" href=\"#0\">First Post</a></div>";
- strBuffer = strBuffer + "<div>";
- if(i>0) strBuffer = strBuffer + "<a onclick=\"setTimeout(doThings,500)\" href=\"#" + (base + numPerPage) + "\">Newer Posts</a>";
- if(base >= numPerPage) strBuffer = strBuffer + "<a style=\"float:right\" onclick=\"setTimeout(doThings,500)\" href=\"#" + (base-numPerPage) + "\">Older Posts</a> ";
- strBuffer = strBuffer + "</div><br />";
- strBuffer = strBuffer.replace(/<img width=.1. height=.1. [^>]+>/g, "");
- container.innerHTML = strBuffer;
- }
- window.scroll(0,0);
- }
- function feedRead(result)
- {
- theResult = result;
- doThings();
- }
- function loadFeed() {
- google = goodGoogle;
- if(feedURI.substr(0,1) == "/")
- feedURI = window.location.protocol + "//" + window.location.host + feedURI;
- var feed = new google.feeds.Feed(feedURI);
- feed.includeHistoricalEntries();
- feed.setNumEntries(maxResults);
- feed.load(feedRead);
- // clear page title field:
- var elements = document.getElementsByTagName("*");
- for(var i=0 ; i<elements.length ; i++)
- if(/(^| )post-title( |$)/.test(elements[i].className))
- elements[i].parentNode.removeChild(elements[i]);
- }
- google.setOnLoadCallback(loadFeed);
- </script>
- <div id="feedDiv"><i>Loading, please wait...</i></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement