##CONTINUE##
紅色的部分字可以自行更改的,例如:我的Blog只有我一個作者,所以在最新文章裡面,我就將'+authorname+': 這串字給拿掉,因為不必要顯示!!
最新文章:
<div id="newPosts">
Loading...
<noscript>failed!<br/>Javascript not supported here!</noscript>
</div>
<script>
function handlePosts(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 temp = '<ul>';
var PostShow = 10;
var sortentry = json.feed.entry.sort(compareentry);
for (var i=0, Post; Post = sortentry[i]; i++) {
if (i >= PostShow)
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 authorname=Post.author[0].name.$t;
var timestamp=Post.published.$t.substr(0,10);
temp += '<li><span class="item-title">'+authorname+': <a href="'+link+'">'+ title +'</a> - '+timestamp+'</span></li>';
}
temp+="</ul>";
document.getElementById("newPosts").innerHTML = temp;
}
</script>
<script src="/feeds/posts/default?alt=json-in-script&callback=handlePosts" type="text/javascript">
最新回應
<div id="newComments">
Loading...
<noscript>failed!<br/>Javascript not supported here!</noscript>
</div>
<script>
function handleComments(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 temp = '<ul>';
var CommentShow = 10;
var sortentry = json.feed.entry.sort(compareentry);
for (var i=0, Comment; Comment = sortentry[i]; i++) {
if (i >= CommentShow)
break;
var title=Comment.content.$t.substr(0,30);
title=title.replace(new RegExp("BR","gm"), "");
title=title.replace(new RegExp("</>","gm"), " ");
var link=Comment.link[0].href.replace("#", "#comment-");
var authorname=Comment.author[0].name.$t;
var timestamp=Comment.published.$t.substr(0,10);
temp += '<li><span class="item-title">'+authorname+': <a href="'+link+'">'+ title +'</a> - '+timestamp+'</span></li>';
}
temp+="</ul>";
document.getElementById("newComments").innerHTML = temp;
}
</script>
<script src="/feeds/comments/default?alt=json-in-script&callback=handleComments" type="text/javascript"/></script>