Como siempre, es mejor verlo en acción: en la entrada que queráis de mi blog Nada, picad en alguna de sus etiquetas. Cuando a aparezca la tabla Ajax con todas las entradas bajo esa etiqueta, picad en las restantes etiquetas de alguna de esas entradas.
Para conseguirlo tenemos que modificar el script "AjaxLabels,js" que, para abreviar y no confundir a nadie, nos quedaría así:
/*****************************************************/
/* AJAX Labels */
/* Coded by Deepak Ranganathan */
/* http://blogger-hacked.blogspot.com */
/* Protected by Creative Commons License */
/* http://creativecommons.org/licenses/by-nc-sa/2.5/ */
/*****************************************************/
var gCat;
var labelcount;
var startindex;
function getCat(cat,startindex) {
cat = encodeURIComponent(cat); //Support for UTF-8 Categories
if(startindex==null)
var url= '/feeds/posts/summary/-/' + cat + '?max-results=' + maxresults + '&alt=json';
else
var url= '/feeds/posts/summary/-/' + cat + '?max-results=' + maxresults + '&start-index=' + startindex + '&alt=json';
var pars = '';
gCat = cat;
new Ajax.Request(
url,
{
method: 'get',
parameters: pars,
onLoading: function(){Element.show('indicator')},
onSuccess: showCat,
onFailure: showFail
});
}
function showCat(output){
gCat = decodeURIComponent(gCat); //Support for UTF-8 Categories
Element.hide('indicator');
Element.show('search-result');
$('show-result').innerHTML="";
var main = string2JSON(output.responseText);
labelcount = main.feed.openSearch$totalResults.$t;
startindex = main.feed.openSearch$startIndex.$t;
if(labelcount == 0){
showFail();
}else{
attachNav();
attachFeed();
var xtitle, xcat, xcontent;
var title, content,catdisplay;
for (i=0; main.feed.entry[i]; i++) {
xentry = main.feed.entry[i];
xcontent=xentry.summary.$t;
title=document.createElement('h3');
title.className="search-title";
link=document.createElement('a');
link.href=xentry.link[0].href;
link.innerHTML=xentry.title.$t;
title.appendChild(link);
$('show-result').appendChild(title);
content=document.createTextNode(xcontent+"...");
$('show-result').appendChild(content);
catdisplay=document.createElement('div');
catdisplay.className='search-cat';
catdisplay.innerHTML="<span style=\"color:silver;\"> " + catLabel + "<\/span> ";
for (var j=0;xentry.category[j];j++) {
catdisplay.innerHTML+='<a href="javascript:getCat(\'' + xentry.category[j].term + '\')" >'+xentry.category[j].term+'</a>';
/* catdisplay.innerHTML+='<a href="javascript:filterPosts(\'' + xentry.category[j].term + '\')" >'+xentry.category[j].term+'</a>';*/
/* catdisplay.innerHTML+="<a href='javascript:getCat(\"" + xentry.category[j].term + "\",null)\"' >"+xentry.category[j].term+'</a>';*/
/*<a href='#sres' expr:onclick='"javascript:getCat(\"" + data:label.name + "\",null)"' ><data:label.name/></a>*/
if(j<xentry.category.length-1)
catdisplay.innerHTML+=" , ";
}
$('show-result').appendChild(catdisplay);
}
$('search-result').style.display="block";
new Effect.Highlight('search-result',{startcolor:'#C3D9FF', duration: 5.0, endcolor:'#fafafa'});
}
}
function attachNav(){
if(navFlag==1){
var nav = document.createElement('div');
nav.className='search-result-nav';
var index;
var cnt=Math.ceil(labelcount/maxresults);
var navlink;
for(i=0;i<cnt;i++){
index=(i*maxresults)+1;
if(index!=(startindex*1)){
navlink=document.createElement('a');
navlink.href="javascript:getCat('" + gCat + "'," + index + ")";
navlink.innerHTML=(i+1);
nav.appendChild(navlink);
}else{
nav.innerHTML+=(i+1);
}
nav.innerHTML+=" ";
}
$('show-result').appendChild(nav);
}
}
function attachFeed(){
var meta = document.createElement('div');
meta.className="search-result-meta";
var metalink = document.createElement('a');
metalink.href="/feeds/posts/summary/-/"+gCat;
metalink.innerHTML = "<img src=\"http://bloggerhacked.googlepages.com/feed-icon.gif\" title=\"Subscribe to this category\" />";
metalink.innerHTML+= feedLabel + " " + gCat;
meta.appendChild(metalink);
$('show-result').appendChild(meta);
}
function string2JSON(str){
var n;
//We have to do exception handling here because eval might not work in all cases
try {
eval("n="+str);
}
catch (e) {
n= null;
}
return n;
}
function showFail(){
Element.hide('indicator');
$('show-result').innerHTML="Sorry! The page cannot be loaded.";
$('search-result').style.display="block"
}
/**************************/
/* End of AJAX Categories */
/**************************/
Y eso es todo: del resto del hack no tenéis que tocar nada más.
Es cosa de Kaie's Blog
✍ ¿Quieres hacer algún comentario? ✍