﻿// COM JSON feed for blog
numnotas=10; numletras=120;
titulos=new Array(numnotas); enlaces=new Array(numnotas); elautor=new Array(numnotas); contenido=new Array(numnotas);
leereste='" title="Leer este artículo" '; var numer1; var numer2; var entrada;
//
function vernotas(json) { 
for (var i = 0; i < numnotas; i++) {	// start a loop to get the entry from the feed and parse it
	if (i == json.feed.entry.length) break;
	entrada = json.feed.entry[i];		// get entry i from feed
	if (entrada == null) {alert('Hubo un problema en el servidor. Será redireccionado.'); location.href="http://la5tapatanet.blogspot.com/search/label/Mendoza";}
	titulos[i] = entrada.title.$t;		// get the title of the post
	for (var k = 0; k < entrada.link.length; k++) {
		if (entrada.link[k].rel == 'alternate')	{enlaces[i] = '#' + entrada.title.$t; break;}	// get the post url; check all links for those with rel=alternate
	}
	numer1 = entrada.content.$t.indexOf('<h5>');	// the author -h5 tag-
	if (numer1 != -1) {
		numer2 = entrada.content.$t.indexOf('</h5>', numer1);
		if (numer2  > numer1)	{elautor[i] = entrada.content.$t.substring(numer1 + 4, numer2);}
	} else {elautor[i] = 'nada';}
	numer1 = entrada.content.$t.indexOf('<h6>');	// the subtitlte/drop-down text -h6 tag-
	if (numer1 != -1) {
		numer2 = entrada.content.$t.indexOf('</h6>', numer1);
		if (numer2  > numer1) {
			contenido[i] = entrada.content.$t.substring(numer1 + 4, numer2);
			if (contenido[i].length > numletras) {
				contenido[i] = contenido[i].substring(0,numletras);	// reduce content to numletras characters
				 contenido[i] = contenido[i].substring(0, contenido[i].lastIndexOf(' ')) + '...';
			}
		}
	} else {contenido[i] = 'nada';}
	}
// CEN DIVISION
document.write('<div class="cen">') 
var titus = 0; for (var i = 0; titus < numnotas && i < numnotas; i++) { 
document.write('<br /><p class="titul"><a href="' + enlaces[i] + leereste + '>' + titulos[i] + '</a></p>');
if (elautor[i] !='nada') {
	document.write('<p class="autor"><a href="' + enlaces[i] + leereste + '>' + elautor[i] + '</a></p>'); }
if (contenido[i] !='nada') {
	document.write('<p class="conte"><a href="' + enlaces[i] + leereste + '>' + contenido[i] + '</a></p>'); }
titus++;
}
document.write('<br /></div>');
}	// FIN JSON feed
