Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <b:if cond='data:blog.pageType == "item"'>
- <script type='text/javascript'>
- // Post titles to Older Post and Newer Post links (without stats skew) - reloaded!
- // by MS-potilas 2012. See http://yabtb.blogspot.com/2012/06/titles-to-older-newer-links-reloaded.html
- //<![CDATA[
- //
- // Configuration:
- // In these you can use [title]:
- var olderLink = 'Older Post >><div class="blog-pager-older-link-title">[title]</div>';
- var newerLink = '<< Newer Post<div class="blog-pager-newer-link-title">[title]</div>';
- // In these you can use [date], [datetime], [title]:
- var olderTitle = 'Older Post - posted on [date]';
- var newerTitle = 'Newer Post - posted on [date]';
- // configuration ends
- //
- function setLink(selector, link, title, entry) {
- var htm = link.replace("[title]", entry.title.$t);
- $(selector).html(htm);
- var date = entry.published.$t.match(/\d+/g);
- date = new Date(date[0],date[1]-1,date[2],date[3],date[4],date[5]); // convert iso
- title = title.replace('[date]', date.toLocaleDateString());
- title = title.replace('[datetime]', date.toLocaleString());
- title = title.replace("[title]", entry.title.$t);
- $(selector).attr("title", title);
- }
- function setOlderLink(entry) { setLink("a.blog-pager-older-link", olderLink, olderTitle, entry); }
- function setNewerLink(entry) { setLink("a.blog-pager-newer-link", newerLink, newerTitle, entry); }
- $(window).load(function() {
- window.setTimeout(function() {
- var timestamp = $(".published").attr("title");
- if(timestamp && timestamp != "")
- $.getJSON("/feeds/posts/default?alt=json-in-script&published-min="+encodeURIComponent(timestamp)+"&max-results=0&callback=?", function(resp) {
- var postindex = parseInt(resp.feed.openSearch$totalResults.$t);
- if(postindex > 1)
- $.getJSON("/feeds/posts/summary?alt=json-in-script&start-index="+(postindex-1)+"&max-results=3&callback=?", function(resp) {
- setNewerLink(resp.feed.entry[0]);
- var postcount = parseInt(resp.feed.openSearch$totalResults.$t);
- var startindex = parseInt(resp.feed.openSearch$startIndex.$t);
- if(postcount - startindex > 1) setOlderLink(resp.feed.entry[2]);
- });
- else
- $.getJSON("/feeds/posts/summary?alt=json-in-script&start-index=2&max-results=1&callback=?", function(resp) { setOlderLink(resp.feed.entry[0]); });
- });
- }, 500);
- });
- //]]>
- </script>
- </b:if>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement