Bagaimana, tertarik memiliki komentar dan postingan terbaru yg dapat dilihat semua dengan tombol next and previous :-/ Memberi kemudahan kita dalam cek dan riceknya toh ;) Caranya juga cukup mudah kita tinggal masukin saja script dan kode kedalam Add a Gadget ► HTML/Javascript :p
Recent Post
<div id="newposts">
<noscript>failed!<br/>javascript not supported here!</noscript>
</div>
<script>
var npoststartindex = 1;
var npostshow = 6;
function showrecentposts(nindex) {
if (!nindex)
nindex = npoststartindex;
var sfeedurl = '/feeds/posts/summary?orderby=published&start-index='+nindex+'&max-results='+(npostshow+1)+'&alt=json-in-script&callback=generateposts';
var script = document.createelement('script');
document.getelementbyid('newposts').innerhtml = 'loading <blink>...</blink>';
script.setattribute('src', sfeedurl);
script.setattribute('type', 'text/javascript');
document.documentelement.firstchild.appendchild(script);
}
function generateposts(json) {
function compareentry(a,b) {
order= date.parse(a.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})t([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 gmt')) - date.parse(b.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})t([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 gmt'));
return 0-order;
}
var shtml = '<ul>';
var sortentry = json.feed.entry.sort(compareentry);
var nindex = parseint(json.feed.opensearch$startindex.$t);
var ntotalpost = parseint(json.feed.opensearch$totalresults.$t);
for (var i = 0, post; post = sortentry[i]; i++) {
if (i >= npostshow)
break;
var title = post.title.$t;
var j = 0;
while (j < post.link.length && post.link[j].rel != "alternate")
j++;
var link = post.link[j].href;
var timestamp=post.published.$t.substr(0,10);
shtml += '<li><span class="item-title"><a href="'+link+'">'+ title +'</a> - '+timestamp+'</span></li>';
}
shtml += '</ul>';
shtml += generatepostlink(parseint(json.feed.entry.length), nindex, ntotalpost);
document.getelementbyid('newposts').innerhtml = shtml;
}
function generatepostlink(nfetch, nindex, ntotalpost) {
var bold = (nfetch > npostshow);
if (bold) nfetch = npostshow;
var sresult = '<p align="right">recent '+nindex+'-'+(nindex+nfetch-1)+', total: '+ntotalpost+'. ';
if (nindex > npoststartindex)
sresult += '<a href="javascript:showrecentposts('+(nindex-npostshow)+');" title="newer posts"><<</a> ';
if (bold)
sresult += '<a href="javascript:showrecentposts('+(nindex+npostshow)+');" title="older posts">>></a>';
sresult += '</p>';
return sresult;
}
</script>
<script>showrecentposts();</script>
<noscript>failed!<br/>javascript not supported here!</noscript>
</div>
<script>
var npoststartindex = 1;
var npostshow = 6;
function showrecentposts(nindex) {
if (!nindex)
nindex = npoststartindex;
var sfeedurl = '/feeds/posts/summary?orderby=published&start-index='+nindex+'&max-results='+(npostshow+1)+'&alt=json-in-script&callback=generateposts';
var script = document.createelement('script');
document.getelementbyid('newposts').innerhtml = 'loading <blink>...</blink>';
script.setattribute('src', sfeedurl);
script.setattribute('type', 'text/javascript');
document.documentelement.firstchild.appendchild(script);
}
function generateposts(json) {
function compareentry(a,b) {
order= date.parse(a.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})t([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 gmt')) - date.parse(b.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})t([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 gmt'));
return 0-order;
}
var shtml = '<ul>';
var sortentry = json.feed.entry.sort(compareentry);
var nindex = parseint(json.feed.opensearch$startindex.$t);
var ntotalpost = parseint(json.feed.opensearch$totalresults.$t);
for (var i = 0, post; post = sortentry[i]; i++) {
if (i >= npostshow)
break;
var title = post.title.$t;
var j = 0;
while (j < post.link.length && post.link[j].rel != "alternate")
j++;
var link = post.link[j].href;
var timestamp=post.published.$t.substr(0,10);
shtml += '<li><span class="item-title"><a href="'+link+'">'+ title +'</a> - '+timestamp+'</span></li>';
}
shtml += '</ul>';
shtml += generatepostlink(parseint(json.feed.entry.length), nindex, ntotalpost);
document.getelementbyid('newposts').innerhtml = shtml;
}
function generatepostlink(nfetch, nindex, ntotalpost) {
var bold = (nfetch > npostshow);
if (bold) nfetch = npostshow;
var sresult = '<p align="right">recent '+nindex+'-'+(nindex+nfetch-1)+', total: '+ntotalpost+'. ';
if (nindex > npoststartindex)
sresult += '<a href="javascript:showrecentposts('+(nindex-npostshow)+');" title="newer posts"><<</a> ';
if (bold)
sresult += '<a href="javascript:showrecentposts('+(nindex+npostshow)+');" title="older posts">>></a>';
sresult += '</p>';
return sresult;
}
</script>
<script>showrecentposts();</script>
Recent Comments
<div id="newcomments">
<noscript>failed!<br />javascript not supported here!</noscript>
</div>
<script>
var ncommentstartindex = 1;
var ncommentshow = 6;
function showrecentcomments(nindex) {
if (!nindex)
nindex = ncommentstartindex;
var sfeedurl = '/feeds/comments/summary?orderby=published&start-index='+nindex+'&max-results='+(ncommentshow+1)+'&alt=json-in-script&callback=generatecomments';
var script = document.createelement('script');
document.getelementbyid('newcomments').innerhtml = 'loading <blink>...</blink>';
script.setattribute('src', sfeedurl);
script.setattribute('type', 'text/javascript');
document.documentelement.firstchild.appendchild(script);
}
function generatecomments(json) {
function compareentry(a,b) {
order= date.parse(a.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})t([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 gmt')) - date.parse(b.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})t([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 gmt'));
return 0-order;
}
var shtml = '<ul>';
var sortentry = json.feed.entry.sort(compareentry);
var nindex = parseint(json.feed.opensearch$startindex.$t);
var ntotalcomment = parseint(json.feed.opensearch$totalresults.$t);
for (var i = 0, comment; comment = sortentry[i]; i++) {
if (i >= ncommentshow)
break;
var authorname = comment.author[0].name.$t;
var title = comment.title.$t.substr(0,100);
var j = 0;
while (j < comment.link.length && comment.link[j].rel != "alternate")
j++;
var link = comment.link[j].href.replace("#c", "#comment-");
var timestamp = comment.published.$t.substr(0,10);
shtml += '<li><span class="item-title">'+authorname+': <a href="'+link+'">'+ title +'</a> - '+timestamp+'</span></li>';
}
shtml += '</ul>';
shtml += generatecommentlink(parseint(json.feed.entry.length), nindex, ntotalcomment);
document.getelementbyid('newcomments').innerhtml = shtml;
}
function generatecommentlink(nfetch, nindex, ntotalcomment) {
var bold = (nfetch > ncommentshow);
if (bold) nfetch = ncommentshow;
var sresult = '<p align="right">recent '+nindex+'-'+(nindex+nfetch-1)+', total: '+ntotalcomment+'. ';
if (nindex > ncommentstartindex)
sresult += '<a href="javascript:showrecentcomments('+(nindex-ncommentshow)+');" title="newer comments"><<</a> ';
if (bold)
sresult += '<a href="javascript:showrecentcomments('+(nindex+ncommentshow)+');" title="older comments">>></a>';
sresult += '</p>';
return sresult;
}
</script>
<script>showrecentcomments();</script>
Disuruh terjemahin juga, eh malah dikasih tutorial ini yah ;;) ;))<noscript>failed!<br />javascript not supported here!</noscript>
</div>
<script>
var ncommentstartindex = 1;
var ncommentshow = 6;
function showrecentcomments(nindex) {
if (!nindex)
nindex = ncommentstartindex;
var sfeedurl = '/feeds/comments/summary?orderby=published&start-index='+nindex+'&max-results='+(ncommentshow+1)+'&alt=json-in-script&callback=generatecomments';
var script = document.createelement('script');
document.getelementbyid('newcomments').innerhtml = 'loading <blink>...</blink>';
script.setattribute('src', sfeedurl);
script.setattribute('type', 'text/javascript');
document.documentelement.firstchild.appendchild(script);
}
function generatecomments(json) {
function compareentry(a,b) {
order= date.parse(a.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})t([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 gmt')) - date.parse(b.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})t([0-9:]*)([.0-9]*)(.)(.*)$/, '$1/$2/$3 $4 gmt'));
return 0-order;
}
var shtml = '<ul>';
var sortentry = json.feed.entry.sort(compareentry);
var nindex = parseint(json.feed.opensearch$startindex.$t);
var ntotalcomment = parseint(json.feed.opensearch$totalresults.$t);
for (var i = 0, comment; comment = sortentry[i]; i++) {
if (i >= ncommentshow)
break;
var authorname = comment.author[0].name.$t;
var title = comment.title.$t.substr(0,100);
var j = 0;
while (j < comment.link.length && comment.link[j].rel != "alternate")
j++;
var link = comment.link[j].href.replace("#c", "#comment-");
var timestamp = comment.published.$t.substr(0,10);
shtml += '<li><span class="item-title">'+authorname+': <a href="'+link+'">'+ title +'</a> - '+timestamp+'</span></li>';
}
shtml += '</ul>';
shtml += generatecommentlink(parseint(json.feed.entry.length), nindex, ntotalcomment);
document.getelementbyid('newcomments').innerhtml = shtml;
}
function generatecommentlink(nfetch, nindex, ntotalcomment) {
var bold = (nfetch > ncommentshow);
if (bold) nfetch = ncommentshow;
var sresult = '<p align="right">recent '+nindex+'-'+(nindex+nfetch-1)+', total: '+ntotalcomment+'. ';
if (nindex > ncommentstartindex)
sresult += '<a href="javascript:showrecentcomments('+(nindex-ncommentshow)+');" title="newer comments"><<</a> ';
if (bold)
sresult += '<a href="javascript:showrecentcomments('+(nindex+ncommentshow)+');" title="older comments">>></a>';
sresult += '</p>';
return sresult;
}
</script>
<script>showrecentcomments();</script>
See yah happy new year \m/
Tidak ada komentar:
Posting Komentar