Chủ Nhật, 3 tháng 6, 2012

Code chỉ hiện title theo label trong blogspot

<script type="text/javascript">
home_page = "http://mp3.nethoabinh.com/";
label = "viet-mix";
numposts = 10;
postcount = 100;
sumTitle = 28;
colortitle = "#F9F";
tcolortitle = "#39F";
cmcolor = "#F9F";
nocmtext = "Cm";
cmtext = "Nhận xét";
posttext = "Đăng vào";
</script>
<script type="text/javascript">
function removeHtmlTag(strx,chop){
var s = strx.split("
<");
for(var i=0;i
<s.length;i++){
if(s[i].indexOf(">")!=-1){
s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);
}
}
s = s.join("");
s = s.substring(0,chop-1);
return s;
}

function removeHtmlTag(strx,chop){
var s = strx.split("
<");
for(var i=0;i
<s.length;i++){
if(s[i].indexOf(">")!=-1){
s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);
}
}
s = s.join("");
s = s.substring(0,chop-1);
return s;

}

function showrecentposts(json) {
img = new Array();
var td = new Array();
var sumPost = new Array();
var posttitle = new Array();
var postcontent = new Array();
var comment = new Array();
var postDay = new Array();
document.write("
<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"rc-2cot\">");
for (var i = 0; i
< numposts; i++) {
var entry = json.feed.entry[i];

posttitle[i] = entry.title.$t;
var pcm ;
var posturl;
if (i == json.feed.entry.length) break;
for (var k = 0; k
< entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
posturl = entry.link[k].href;
break;
}
}

for (var k = 0; k
< entry.link.length; k++) {
if (entry.link[k].rel == 'replies' && entry.link[k].type == 'text/html') {
pcm = entry.link[k].title.split(" ")[0];
break;
}
}

var postdate = entry.published.$t;
var month = [1,2,3,4,5,6,7,8,9,10,11,12];
var month2 = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];

var day = postdate.split("-")[2].substring(0,2);
var m = postdate.split("-")[1];
var y = postdate.split("-")[0];

for(var u2=0;u2
<month.length;u2++){
if(parseInt(m)==month[u2]) {
m = month2[u2] ; break;
}
}
postDay[i] = day+ "-" + m + "-" + y ;

if ("content" in entry) {
postcontent[i] = entry.content.$t;}
else
if ("summary" in entry) {
postcontent[i] = entry.summary.$t;}
else postcontent[i] = "";

s = postcontent[i] ; a = s.indexOf("
<img"); b = s.indexOf("src=\"",a); c = s.indexOf("\"",b+5); d = s.substr(b+5,c-b-5);

if((a!=-1)&&(b!=-1)&&(c!=-1)&&(d!="")) {img[i] = d;} else {img[i]="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg-laM9hBN2zmcGkw6UhiQez1dCbtBQvTcKis5oYBLhQNouulXj5Nz0IoRsPXE__ct-XGSSDWG1gPiy8AjOiioO6L8TBmSed4MS4oXaq8lmYSOvKme4AeLqm84PJQ7ZVodhjPv05P2IrAl/s1600/play.gif";}


if (pcm==0) {comment[i] = " (" +nocmtext+ ") ";}
else {comment[i] = " (" + pcm + " " +cmtext+ ") ";}

postcontent[i] = postcontent[i].replace(/"/g, "&#8220;");
posttitle[i] = posttitle[i].replace(/"/g, "&#8220;");

sumPost[i] ="sumPost"+i;
var tilen= posttitle[i].length;
if (tilen > sumTitle) {
td[i]= '
<td id="rc-td"><a href="'+posturl+'"><img title="'+posttitle+'" src="'+img[i]+'"/><a title="'+posttitle+'" onmouseover="showtip('+sumPost[i]+');" onmouseout="hidetip();" href="'+posturl+'" style="color:'+colortitle+';">'+removeHtmlTag(posttitle[i],sumTitle)+' ...</a></td>';
}
else {
td[i]= '
<td id="rc-td"><a href="'+posturl+'"><img title="'+posttitle+'" src="'+img[i]+'"/><a title="'+posttitle+'" onmouseover="showtip('+sumPost[i]+');" onmouseout="hidetip();" href="'+posturl+'" style="color:'+colortitle+';">'+posttitle[i]+'</a></td>';
}
if (i%2==0) { var td1col = '
<tr id="rc-tr0">'+td[i]+'</tr>';
document.write(td1col);
}
else { var td1col = '
<tr id="rc-tr1">'+td[i]+'</tr>';
document.write(td1col);
}
}
document.write("
</table>");
document.getElementById("rc-posts-loading").style.display = "none";
for (var p = 0; p
< numposts; p++) {
document.write("
<script type=\"text/javascript\">var "+sumPost[p]+" =\"<b style='color:"+tcolortitle+"'>"+posttitle[p]+"<\/b> <br\/> <i style='color:"+cmcolor+"'>"+posttext+" : "+postDay[p]+" - "+comment[p]+" <\/i><br\/>"+removeHtmlTag(postcontent[p],postcount)+" ...\";<\/script>");
}
}
document.write("
<script src=\""+home_page+"feeds/posts/default/-/"+label+"?max-results="+numposts+"&orderby=published&alt=json-in-script&callback=showrecentposts\"><\/script>");
</script>

Không có nhận xét nào:

Đăng nhận xét