/***************************** Comentarios **********************************/
var ids_noticias = '';
function getNumComentariosPortada(id) {
ids_noticias = (ids_noticias != '') ? ids_noticias + '|' + id : id;
if (window.document.getElementById('num-comentarios-' + id)) window.document.getElementById('num-comentarios-' + id).innerHTML = 'Comenta esta noticia';
}
function setNumComentariosPortada(id, v) {
v = typeof(v) != 'undefined' ? v : '';
var dir;
if (id) {
var http = createRequestObject();
dir = '/backend/comentarios' + v + '/getComentariosPortada.php?id=' + id + '&by=date';
http.open('get', dir);
http.onreadystatechange = function () {
if(http.readyState == 4){
if (http.responseText) {
var campos = http.responseText.split('|');
var limite = campos.length;
var i = limite - 1;
do {
campos2 = campos[i].split('@');
var num = campos2[1];
switch (num) {
case '0':
if (window.document.getElementById('num-comentarios-' + campos2[0])) window.document.getElementById('num-comentarios-' + campos2[0]).innerHTML = 'Comenta esta noticia';
break;
case '1':
if (window.document.getElementById('num-comentarios-' + campos2[0])) window.document.getElementById('num-comentarios-' + campos2[0]).innerHTML = '' + num + ' Comentario';
break;
default:
if (window.document.getElementById('num-comentarios-' + campos2[0])) window.document.getElementById('num-comentarios-' + campos2[0]).innerHTML = '' + num + ' Comentarios';
break;
}
}
while (i--);
}
}
};
http.send(null);
}
}
function getNumComentarios(id) {
if (id) {
var http = createRequestObject();
//http.open("get", "/backend/comentarios/getComentarios.php?id=" + id + "&by=date&r=" + Math.random());
http.open("get", "/backend/comentarios/getComentarios.php?id=" + id + "&by=date");
http.onreadystatechange = function () {
if(http.readyState == 4){
if (http.responseXML) {
if (http.responseText.indexOf('comments') != -1) {
//if (http.responseXML.getElementsByTagName('comments')) {
var num = http.responseXML.getElementsByTagName('total_comments')[0].firstChild.data;
window.document.getElementById('num-comentarios').innerHTML = '(' + num + ')';
}
}
}
};
http.send(null);
}
}
function getComentarios(id, by, v, a) {
v = typeof(v) != 'undefined' ? v : '';
a = typeof(a) != 'undefined' ? a : 1;
var dir;
if (id) {
var http = createRequestObject();
dir = '/backend/comentarios' + v + '/getComentarios.php?id=' + id + '&by=' + by + (a ? '' : '&r=' + Math.random());
http.open('get', dir);
http.onreadystatechange = function () {
if(http.readyState == 4){
if (http.responseXML) {
if (http.responseText.indexOf('comments') != -1) {
eval('muestraComentarios' + v + '(http.responseXML)');
window.document.getElementById('lomasreciente').className = (by == 'date') ? 'activo' : '';
window.document.getElementById('lomasvalorado').className = (by == 'votes') ? 'activo' : '';
}
}
}
};
http.send(null);
}
}
function muestraComentarios(response) {
var contenido;
var html;
var fecha_load = new Date();
var browser = navigator.appName;
var positive_votes;
var negative_votes;
var limite = response.getElementsByTagName('comment').length;
html = '
' + response.getElementsByTagName('total_comments')[0].firstChild.data + ' OPINIONES
';
limite_b = (limite > 5) ? 5 : limite;
for (i = 0; i ';
contenido += '' + fecha + ' | ' + hora + '
';
contenido += '' + unescape(nombre) + '
';
contenido += '' + unescape(texto) + '
';
contenido += '';
contenido += '
';
contenido += '
';
contenido += '
';
contenido += '
';
contenido += '';
contenido += '';
contenido += '';
contenido += '';
html += contenido;
}
window.document.getElementById('listado-comentarios').innerHTML = html;
verMas(limite);
}
function muestraComentarios2(response, pagina) {
var contenido;
var html;
var fecha_load = new Date();
var browser = navigator.appName;
var positive_votes;
var negative_votes;
var max_comentarios = 5;
pagina = typeof(pagina) != 'undefined' ? pagina : 1;
var limite = response.getElementsByTagName('comment').length;
html = '' + response.getElementsByTagName('total_comments')[0].firstChild.data + ' OPINIONES
';
if (window.document.getElementById('num-comentarios')) {
window.document.getElementById('num-comentarios').innerHTML = '(' + response.getElementsByTagName('total_comments')[0].firstChild.data + ')';
}
var limite_b = ((((pagina - 1) * max_comentarios) + max_comentarios) > limite) ? limite : (((pagina - 1) * max_comentarios) + max_comentarios);
var inicio = (pagina - 1) * max_comentarios;
var paginas = Math.ceil(limite / max_comentarios);
var pagina_ver = (pagina ';
contenido += '' + fecha + ' | ' + hora + '
';
contenido += '' + unescape(nombre) + '
';
contenido += '' + unescape(texto) + '
';
contenido += '';
contenido += '
';
contenido += '
';
contenido += '
';
contenido += '
';
contenido += '';
contenido += '';
contenido += '';
contenido += '';
html += contenido;
}
if (limite > max_comentarios) {
html += '';
}
window.document.getElementById('listado-comentarios').innerHTML = html;
if (limite > max_comentarios) {
window.document.getElementById('anterior').onclick = function () {
if (pagina != 1) {
muestraComentarios2(response, (pagina - 1));
}
else {
muestraComentarios2(response, pagina);
}
}
window.document.getElementById('siguiente').onclick = function () {
if (pagina != paginas) {
muestraComentarios2(response, (pagina + 1));
}
else {
muestraComentarios2(response, pagina);
}
}
}
}
function nada() {
return;
}
function desconectar() {
window.location = '/backend/desconectar.php?url=' + window.location.href;
}
function conectar() {
var direccion;
if (window.document.location.href.indexOf('?') > 0) {
var campos = window.document.location.href.split('?');
direccion = campos[0];
}
else {
direccion = window.document.location.href;
}
var qs = 'url=' + direccion;
qs += '&email=' + window.document.logueo.email.value;
qs += '&contrasena=' + window.document.logueo.contrasena.value;
window.location = '/backend/conectar.php?' + qs;
}
function enviaComentario() {
var fecha_submit = new Date();
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if (window.document.formulario.author_name.value == '') {
alert('Por favor, introduce tu nombre');
window.document.formulario.author_name.focus();
return;
}
if (window.document.formulario.author_email.value == '') {
alert('Por favor, introduce tu email');
window.document.formulario.author_email.focus();
return;
}
if (!filter.test(window.document.formulario.author_email.value)) {
alert('El email introducido no es válido');
window.document.formulario.author_email.focus();
return;
}
if (window.document.formulario.message.value == '') {
alert('Por favor, introduce tu opinión');
window.document.formulario.message.focus();
return;
}
if (!window.document.formulario.acepto.checked) {
alert('Tienes que aceptar las condiciones de uso');
return;
}
var registrado = getCookie('registrado') ? ' (Usuario registrado)' : '';
window.document.formulario.message.value = window.document.formulario.message.value;
window.document.formulario.author_name.value = window.document.formulario.author_name.value + registrado;
window.document.formulario.submit_time.value = fecha_submit.getTime();
window.document.formulario.submit();
alert('Gracias por escribir un comentario');
}
function votarComentario(id, tipo, v) {
v = typeof(v) != 'undefined' ? v : '';
var dir;
if (id) {
var http = createRequestObject();
dir = '/backend/comentarios' + v + '/votarComentario.php?id=' + id + '&tipo=' + tipo + '&r=' + Math.random();
http.open('get', dir);
http.onreadystatechange = function () {
if(http.readyState == 4){
if (http.responseText) {
var response = http.responseText;
if (response.indexOf('ok')) {
if (tipo == 1) {
window.document.getElementById('favorcontra-' + id).innerHTML = 'A favor | Gracias por votar';
}
else {
window.document.getElementById('favorcontra-' + id).innerHTML = 'En contra | Gracias por votar';
}
}
}
}
};
http.send(null);
}
}
function mostrarDenunciar(id) {
var display = window.document.getElementById('formdenunciar-' + id).style.display;
/*
if (display == 'none' && !getCookie('registrado')) {
alert('Para denunciar un comentario RegÃstrate');
return;
}
*/
window.document.getElementById('formdenunciar-' + id).style.display = (display == 'none') ? 'block' : 'none';
}
function denunciarComentario(id) {
var fecha_submit = new Date();
eval('var formu = window.document.formulario_' + id);
formu.submit_time.value = fecha_submit.getTime();
formu.submit();
alert('Gracias por denunciar el comentario');
}
function muestraLogueo() {
window.document.getElementById('artlogeo').style.display = '';
}
function borrarTexto() {
if (window.document.formulario.message.value == 'escribe aquà tu comentario') {
window.document.formulario.message.value = '';
}
}
/***************************** FIN Comentarios **********************************/
[ manual java | ubuntu linux | manual mysql | linux socialist | la gomera ]