Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src='http://code.jquery.com/jquery-latest.js' type='text/javascript'></script>
- <b:if cond='data:blog.pageType == "item"'>
- <style type="text/css">
- .oldernewerpost {
- cursor: pointer;
- padding-top: 5px;
- text-align: center;
- width: 160px;
- overflow: hidden;
- }
- .oldernewerleft { float: left; }
- .oldernewerright { float: right; }
- .home-link {
- margin-top: 5px;
- }
- .oldernewerpost:hover {
- background-color: #EEEEEE;
- }
- .oldernewerpost a:hover {
- text-decoration: none;
- }
- .oldernewerpost img {
- /* thumbnail properties */
- margin-top: 2px;
- padding: 2px;
- width: 72px;
- }
- .oldernewerpost .title {
- line-height: 1.1;
- font-size: 11px;
- font-weight: bold;
- padding: 0 5px 5px;
- }
- .oldernewerpost .summary {
- border-top: 1px dashed #777777;
- border-bottom: 1px dashed #777777;
- color: #404040;
- font-size: 10px;
- line-height: 1;
- padding: 5px;
- text-align: left;
- }
- </style>
- <script type='text/javascript'>
- // Post titles, thumbnails and summaries to Older Post and Newer Post links (without stats skew)
- // by MS-potilas 2013. See http://yabtb.blogspot.com/2013/11/add-post-titles-thumbnails-and.html
- //<![CDATA[
- //
- // Configuration:
- var maxSummaryLength = 160;
- // In these you can use [title], [date], [datetime], [title], [img], [thumburl], [summary]:
- var olderLink = '<div class="oldernewerpost oldernewerright" title="Older Post - [title] - posted on [date]" onclick="location.href=\'[url]\';"><a href="[url]" title="Older Post - [title] - posted on [date]">Older Post >><br/>[img]<div class="title">[title]</div></a><div class="summary">[summary]</div></div>';
- var newerLink = '<div class="oldernewerpost oldernewerleft" title="Newer Post - [title] - posted on [date]" onclick="location.href=\'[url]\';"><a href="[url]" title="Newer Post - [title] - posted on [date]"><< Newer Post<br/>[img]<div class="title">[title]</div></a><div class="summary">[summary]</div></div>';
- // you can use same image or different here:
- var defaultOlderImage = "https://lh5.googleusercontent.com/-rK3a8daWjFs/UpWXOb4up-I/AAAAAAAABo4/2RfPPCI-VPg/s72/older.png";
- var defaultNewerImage = "https://lh4.googleusercontent.com/-etSvFmkqF5M/UpWXOXHdEVI/AAAAAAAABo8/wMBH4bQGug4/s72/newer.png";
- // configuration ends
- //
- function getThumb(entry, def) {
- var thumburl = def;
- try { thumburl = entry.media$thumbnail.url; }
- catch(error) {
- d = $("<p>"+entry.content.$t+"</p>").find("img").attr("src");
- if(d)
- thumburl = d;
- else
- thumburl = def;
- }
- return thumburl;
- }
- function setLink(selector, template, defthumb, entry) {
- 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
- var thumburl = getThumb(entry, defthumb);
- var url = $(selector).attr("href");
- var summary = $("<p>"+entry.content.$t+"</p>").text();
- if(summary.length > maxSummaryLength) {
- summary = summary.substring(0, maxSummaryLength);
- var indexBreak = summary.lastIndexOf(" ");
- summary = summary.substring(0, indexBreak)+"...";
- }
- var htm = template.replace(/\[title\]/g, entry.title.$t);
- htm = htm.replace(/\[date\]/g, date.toLocaleDateString());
- htm = htm.replace(/\[datetime\]/g, date.toLocaleString());
- htm = htm.replace(/\[summary\]/g, summary);
- htm = htm.replace(/\[thumburl\]/g, thumburl);
- htm = htm.replace(/\[url\]/g, url);
- var imghtm = "";
- if(thumburl != "")
- imghtm = '<img src="'+thumburl+'">';
- htm = htm.replace(/\[img\]/g, imghtm);
- $(selector).replaceWith(htm);
- }
- function setOlderLink(entry) { setLink("a.blog-pager-older-link", olderLink, defaultOlderImage, entry); }
- function setNewerLink(entry) { setLink("a.blog-pager-newer-link", newerLink, defaultNewerImage, 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/default?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/default?alt=json-in-script&start-index=2&max-results=1&callback=?", function(resp) { setOlderLink(resp.feed.entry[0]); });
- });
- }, 250);
- });
- //]]>
- </script>
- </b:if>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement