diccionario = new Array(); diccionario["parrafo"] = "Párrafo"; diccionario["subtitulo"] = "Subtítulo"; diccionario["imagen"] = "Imagen"; diccionario["video"] = "Video"; diccionario["enlace"] = "Enlace"; diccionario["elegir_imagen"] = "elegir imagen"; diccionario["caracteres"] = "caracteres"; diccionario["pie_imagen"] = "Pie de imagen"; diccionario["texto"] = "Texto"; diccionario["titulo_vacio"] = "El título está vacío"; diccionario["intro_vacio"] = "La entradilla está vacía"; diccionario["cuerpo_vacio"] = "El cuerpo del artículo está vacío"; diccionario["categoria_vacio"] = "La categoría está vacía"; diccionario["tema_vacio"] = "El tema está vacío"; diccionario["cuerpo_con_campos_vacios"] = "El cuerpo del artículo tiene campos vacíos o falta una imagen"; diccionario["error_en_serv_post_sin_guardar"] = "Lo siento, por un error en el servidor no se pudo guardar el artículo"; diccionario["escribe_algo"] = "Escribe algo"; function formateoSnnEnn(tem, epi){ var se = (tem < 10 && tem > -1) ? 'S0' + tem : 'S' + tem; se += (epi < 10 && epi > -1) ? 'E0' + epi : 'E' + epi; return se; } function objAjax(){ var paginaRequested = false; if(window.XMLHttpRequest){//si es mozilla, Safari etc paginaRequested = new XMLHttpRequest(); }else if(window.ActiveXObject){//si es IE try{ paginaRequested = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){//si es versión antigua try{ paginaRequested = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){} } }else{ return false; } return paginaRequested; } function desc(){//desconecto y recargo página var reqLogoff = objAjax(); if(reqLogoff){ reqLogoff.onreadystatechange = function(){ if(reqLogoff.readyState == 4 && reqLogoff.status == 200){ window.location.href = '/'; } } reqLogoff.open('POST', '/' + 'serv/inc/logoff.php', true); reqLogoff.setRequestHeader("Connection", "close"); reqLogoff.send(null); } } function stripTags(text){ return text.replace(/<\/?[^>]+>/gi, ''); } sugerencias = new Array(""); buscando = ''; function reemplazoAmp(cadena){ return cadena.replace(/\&/gi,'&'); } function sugiero(txtbuscado, objBuscado, idFormSubmit, idDivLista, idInputText){ if((sugerencias[0].substr(0,1).toLowerCase() != txtbuscado.substr(0,1).toLowerCase() || objBuscado != buscando) && txtbuscado != ""){ traigosugerencias(txtbuscado.substr(0,1).toLowerCase(), objBuscado, idFormSubmit, idDivLista, idInputText); buscando = objBuscado; } if(sugerencias[0].substr(0,1).toLowerCase() == txtbuscado.substr(0,1).toLowerCase() && txtbuscado != ""){ buscosugerencias(txtbuscado, idFormSubmit, idDivLista, idInputText); } if(txtbuscado == ""){//si tengo el cuadro de búsqueda vacío escondo sugerencias escondosugerencias(idDivLista); } } function traigosugerencias(letra, objBuscado, idFormSubmit, idDivLista, idInputText){ var reqSugerencias = objAjax(); if(reqSugerencias){ reqSugerencias.onreadystatechange = function(){ if (reqSugerencias.readyState == 4 && reqSugerencias.status == 200){ declaroarray = reqSugerencias.responseText; if(declaroarray != ""){ eval(declaroarray);//el array se llama sugerencias //una vez traidas las sugerencias al array busco la que concuerde para mostrar buscosugerencias(document.getElementById(idInputText).value, idFormSubmit, idDivLista, idInputText); } } } reqSugerencias.open('GET', '/' + "serv/ajax/reqSugerencias.php?i=" + letra + "&obj=" + objBuscado, true); reqSugerencias.send(null); } } function buscosugerencias(txtbuscado, idFormSubmit, idDivLista, idInputText){ var desde = 0; var haysugerencia = false; //busco el índice de array desde donde mostrar sugerencias for(ind = 0; ind < sugerencias.length; ind ++){ sugerencia = sugerencias[ind].substr(0,txtbuscado.length); sugerencia = sugerencia.toLowerCase(); if(txtbuscado.toLowerCase() == sugerencia){ desde = ind; haysugerencia = true; ind = sugerencias.length;//para salir del bucle } } //busco el índice de array hasta donde mostrar sugerencias for(ind = sugerencias.length-1; ind > -1; ind --){ sugerencia = sugerencias[ind].substr(0,txtbuscado.length); sugerencia = sugerencia.toLowerCase(); if(txtbuscado.toLowerCase() == sugerencia){ hasta = ind; ind = -1;//para salir del bucle } } if(haysugerencia){ muestrosugerencias(desde, hasta, idFormSubmit, idDivLista, idInputText); }else{ escondosugerencias(idDivLista); } } function muestrosugerencias(desde, hasta, idFormSubmit, idDivLista, idInputText){ var cadenasugerencias = ""; for(ind = desde; ind < desde + 10 && ind <= hasta; ind ++){//muestro como máximo 10 sugerencias cadenasugerencias += "
  • "+sugerencias[ind]+"
  • "; } document.getElementById(idDivLista).innerHTML = cadenasugerencias; document.getElementById(idDivLista).style.display = 'block'; } function escondosugerencias(idDivLista){ document.getElementById(idDivLista).style.display = 'none'; } function selecsugerencia(idmenuitem, idFormSubmit, idInputText){ document.getElementById(idInputText).value = reemplazoAmp(idmenuitem.innerHTML); if(idFormSubmit){ document.getElementById(idFormSubmit).submit(); } } var lastIdCampo = 0; var aIdInputFile = new Array(); function abroEscribirArticulo(conectado){ if(conectado){ if(document.getElementById('frmPublicar').style.display != 'block'){ document.getElementById('separador').style.display = 'block'; document.getElementById('frmPublicar').style.display = 'block'; document.getElementById('idPreview').style.display = 'block'; document.getElementById('flechaEscribir').innerHTML = '↑'; }else{ document.getElementById('separador').style.display = 'none'; document.getElementById('frmPublicar').style.display = 'none'; document.getElementById('idPreview').style.display = 'none'; document.getElementById('flechaEscribir').innerHTML = '↓'; } }else{ document.location.href = '/' + 'registro/'; } } function insertContenido(selContenido){ var cont = selContenido.value; if(cont == 'parrafo'){ lastIdCampo ++; var parrafo = document.createElement('p'); var idParrafo = 'p' + lastIdCampo; parrafo.id = idParrafo; document.getElementById('cuerpoPost').appendChild(parrafo); var fsParrafo = document.createElement('fieldset'); fsParrafo.className = 'parrafo';//para identificar en js, no css var htmlFormParrafo = ''; htmlFormParrafo += ''; // htmlFormParrafo += ''; // htmlFormParrafo += ''; fsParrafo.innerHTML = htmlFormParrafo; selContenido.parentNode.insertBefore(fsParrafo, selContenido); }else if(cont == 'subtitulo'){ lastIdCampo ++; var subtitulo = document.createElement('h3'); var idSubtitulo = 'subt' + lastIdCampo; subtitulo.id = idSubtitulo; document.getElementById('cuerpoPost').appendChild(subtitulo); var fsSubtitulo = document.createElement('fieldset'); fsSubtitulo.className = 'subtitulo';//para identificar en js, no css var htmlFormSubtitulo = ''; htmlFormSubtitulo += ''; fsSubtitulo.innerHTML = htmlFormSubtitulo; selContenido.parentNode.insertBefore(fsSubtitulo, selContenido); }else if(cont == 'imagen'){ lastIdCampo ++; var divImagen = document.createElement('div'); var idImagen = 'img' + lastIdCampo; divImagen.id = 'div' + idImagen; aIdInputFile.push('input'+idImagen); var htmlImagen = ''; htmlImagen += ''; divImagen.innerHTML = htmlImagen; document.getElementById('cuerpoPost').appendChild(divImagen); var fsImagen = document.createElement('fieldset'); fsImagen.style.position = 'relative'; fsImagen.className = 'imagen';//para identificar en js, no css var htmlFormImagen = '
    '; htmlFormImagen += ''; htmlFormImagen += '
    '; htmlFormImagen += ''; htmlFormImagen += ''; // htmlFormImagen += ''; // htmlFormImagen += ''; htmlFormImagen += '
    '; htmlFormImagen += '
    '; htmlFormImagen += '
    '; htmlFormImagen += '
    '+diccionario["elegir_imagen"]+'
    '; htmlFormImagen += ''; htmlFormImagen += '
    '; htmlFormImagen += ''; htmlFormImagen += '
    '; htmlFormImagen += '
    '+diccionario["pie_imagen"]+':
    '; htmlFormImagen += ''; fsImagen.innerHTML = htmlFormImagen; selContenido.parentNode.insertBefore(fsImagen, selContenido); SI.Files.stylizeAll(); }else if(cont == 'video'){ lastIdCampo ++; var idVideo = 'vid' + lastIdCampo; var iframeVideo = document.createElement('iframe'); iframeVideo.id = 'iframe' + idVideo; iframeVideo.title = 'YouTube video player'; iframeVideo.width = '450'; iframeVideo.height = '365'; iframeVideo.frameborder = '0'; document.getElementById('cuerpoPost').appendChild(iframeVideo); var fsVideo = document.createElement('fieldset'); fsVideo.className = 'video';//para identificar en js, no css var htmlFormVideo = '(Id YouTube 11 '+diccionario["caracteres"]+')'; htmlFormVideo += ''; htmlFormVideo += ''; fsVideo.innerHTML = htmlFormVideo; selContenido.parentNode.insertBefore(fsVideo, selContenido); }else if(cont == 'enlace'){ lastIdCampo ++; var idEnlace = 'enlace' + lastIdCampo; var enlace = document.createElement('a'); enlace.id = idEnlace; enlace.target = '_blank'; document.getElementById('cuerpoPost').appendChild(enlace); var fsEnlace = document.createElement('fieldset'); fsEnlace.className = 'enlace';//para identificar en js, no css var htmlEnlace = ''; htmlEnlace += ''+diccionario["texto"]+':'; htmlEnlace += ''; htmlEnlace += ''; htmlEnlace += 'URL:'; htmlEnlace += ''; fsEnlace.innerHTML = htmlEnlace; selContenido.parentNode.insertBefore(fsEnlace, selContenido); } } function traerTags(){ var reqTags = objAjax(); if(reqTags){ document.getElementById('ajaxTag').style.display = 'block'; var param = 'tipoTag=' + encodeURIComponent(document.getElementById('tipoTag').value); reqTags.onreadystatechange = function(){ if(reqTags.readyState == 4 && reqTags.status == 200){ var respuesta = reqTags.responseText; document.getElementById('tag').innerHTML = respuesta; selectTag(); document.getElementById('ajaxTag').style.display = 'none'; } } reqTags.open('POST', '/' + 'serv/ajax/reqTagsBlog.php', true); reqTags.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqTags.setRequestHeader("Content-length", param.length); reqTags.setRequestHeader("Connection", "close"); reqTags.send(param); } } function selectTag(){ var reqSelectTag = objAjax(); if(reqSelectTag){ document.getElementById('ajaxTag').style.display = 'block'; var param = 'tipoTag=' + encodeURIComponent(document.getElementById('tipoTag').value); param += '&tag=' + encodeURIComponent(document.getElementById('tag').value); reqSelectTag.onreadystatechange = function(){ if(reqSelectTag.readyState == 4 && reqSelectTag.status == 200){ var respuesta = reqSelectTag.responseText; document.getElementById('imgTitulo').src = respuesta; document.getElementById('ajaxTag').style.display = 'none'; } } reqSelectTag.open('POST', '/' + 'serv/ajax/reqSelectTagBlog.php', true); reqSelectTag.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqSelectTag.setRequestHeader("Content-length", param.length); reqSelectTag.setRequestHeader("Connection", "close"); reqSelectTag.send(param); } } function traerTagsBuscar(){ var reqTags = objAjax(); if(reqTags){ document.getElementById('ajaxTagBuscar').style.display = 'block'; var param = 'tipoTag=' + encodeURIComponent(document.getElementById('tipoTagBuscar').value); reqTags.onreadystatechange = function(){ if(reqTags.readyState == 4 && reqTags.status == 200){ var respuesta = reqTags.responseText; document.getElementById('tagBuscar').innerHTML = respuesta; document.getElementById('ajaxTagBuscar').style.display = 'none'; } } reqTags.open('POST', '/' + 'serv/ajax/reqTagsBlog.php', true); reqTags.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqTags.setRequestHeader("Content-length", param.length); reqTags.setRequestHeader("Connection", "close"); reqTags.send(param); } } function borrarElemento(idElemento, boton){ document.getElementById(idElemento).parentNode.removeChild(document.getElementById(idElemento)); boton.parentNode.parentNode.removeChild(boton.parentNode); } /* function subirElemento(idElemento, boton){ if(boton.parentNode.previousSibling.previousSibling.id != 'entradilla'){ boton.parentNode.parentNode.insertBefore(boton.parentNode, boton.parentNode.previousSibling); document.getElementById(idElemento).parentNode.insertBefore(document.getElementById(idElemento), document.getElementById(idElemento).previousSibling); } } function bajarElemento(idElemento, boton){ if(boton.parentNode.nextSibling.id != 'contenido'){ boton.parentNode.parentNode.insertBefore(boton.parentNode, boton.parentNode.nextSibling.nextSibling); document.getElementById(idElemento).parentNode.insertBefore(document.getElementById(idElemento), document.getElementById(idElemento).nextSibling.nextSibling); } } */ function eliminarIdInputFile(idInput){ var indice = aIdInputFile.indexOf(idInput); aIdInputFile.splice(indice, 1); } function chequearImgBlog(inputFile, idImagen){ document.getElementById('ajax'+idImagen).style.display = 'block'; inputFile.form.action = '/' + "serv/ajax/chequearImgBlog.php"; inputFile.form.target = idImagen; inputFile.form.submit(); } function infoImagenBlog(texto, idImagen, alto){ document.getElementById('info'+idImagen).innerHTML = texto; document.getElementById(idImagen).style.height = alto + 'px'; document.getElementById('ajax'+idImagen).style.display = 'none'; } function cargarVideo(idIframeVid, inputIdVid){ var idVid = inputIdVid.value; if(idVid.length == 11){ document.getElementById(idIframeVid).src = 'http://www.youtube.com/embed/' + idVid; }else{ if(document.getElementById(idIframeVid).src != ''){ document.getElementById(idIframeVid).src = ''; } } } // · ·· ··· --- == O == --- ··· ·· · function guardarArticulo(idArt){ document.getElementById('ajaxFrmPublicar').style.display = 'block';//oculto en chequearArticulo(), subirTextos() y imagenGuardada() if(chequearArticulo(idArt)){ if(aIdInputFile.length > 0){//hay imagen subirImagen(idArt); }else{ subirTextos(idArt); } } } function chequearArticulo(idArt){ var categoria = document.getElementById('categoria').value; var titulo = document.getElementById('titulo').value; var tag = document.getElementById('tag').value; var entradilla = document.getElementById('entradilla').value; var aFieldsetCuerpo = document.getElementById('frmPublicar').getElementsByTagName('fieldset'); var totElementos = aFieldsetCuerpo.length; var txtError = ''; if(categoria == ''){ txtError += diccionario["categoria_vacio"] + '. '; } if(tag == ''){ txtError += diccionario["tema_vacio"] + '. '; } if(titulo == ''){ txtError += diccionario["titulo_vacio"] + '. '; } if(entradilla == ''){ txtError += diccionario["intro_vacio"] + '. '; } if(totElementos == 0){//cuerpo vacío txtError += diccionario["cuerpo_vacio"] + '. '; } //verifico campos vacíos en el cuerpo var camposVacios = false; for(i = 0; i < totElementos; i ++){//className para identificar en js, no css if((aFieldsetCuerpo[i].className == 'parrafo' && aFieldsetCuerpo[i].childNodes[1].value == '') || (aFieldsetCuerpo[i].className == 'subtitulo' && aFieldsetCuerpo[i].childNodes[1].value == '') || //si estoy editando puede haber imagen vacía (aFieldsetCuerpo[i].className == 'imagen' && aFieldsetCuerpo[i].getElementsByTagName('form')[0].firstChild.lastChild.value == '' && idArt == 0) || (aFieldsetCuerpo[i].className == 'video' && aFieldsetCuerpo[i].childNodes[2].value == '') || (aFieldsetCuerpo[i].className == 'enlace' && (aFieldsetCuerpo[i].childNodes[2].value == '' || aFieldsetCuerpo[i].childNodes[5].value == ''))){ camposVacios = true; break; } } if(camposVacios){ txtError += diccionario["cuerpo_con_campos_vacios"] + '. '; } if(txtError == ''){ document.getElementById('avisoBlog').style.display = 'none'; document.getElementById('avisoBlog').innerHTML = ''; return true; }else{ document.getElementById('ajaxFrmPublicar').style.display = 'none'; document.getElementById('avisoBlog').style.display = 'block'; document.getElementById('avisoBlog').innerHTML = txtError; return false; } } function subirImagen(idArt){ if(aIdInputFile.length > 0){ var idInput = aIdInputFile.shift(); //agrego al form input hidden con el id del artículo var inputIdArt = document.createElement('input'); inputIdArt.type = 'hidden'; inputIdArt.name = 'idArt'; inputIdArt.value = idArt; document.getElementById(idInput).form.appendChild(inputIdArt); document.getElementById(idInput).form.action = '/' + "serv/ajax/reqGuardarArticulo.php"; document.getElementById(idInput).form.target = "targetSubmitImg"; document.getElementById(idInput).form.submit(); }else{ subirTextos(idArt); } } function imagenGuardada(guardada, idArt){ if(guardada){ subirImagen(idArt); }else{ restauroCarga(); borroImgsResiduo(); document.getElementById('ajaxFrmPublicar').style.display = 'none'; document.getElementById('avisoBlog').style.display = 'block'; document.getElementById('avisoBlog').innerHTML = diccionario["error_en_serv_post_sin_guardar"] + '.'; } } function subirTextos(idArt){ var aFieldsetCuerpo = document.getElementById('frmPublicar').getElementsByTagName('fieldset'); var totElementos = aFieldsetCuerpo.length; var param = 'idArt='+idArt; param += '&categoria='+encodeURIComponent(document.getElementById('categoria').value); param += '&tipoTag='+encodeURIComponent(document.getElementById('tipoTag').value); param += '&tag='+encodeURIComponent(document.getElementById('tag').value); param += '&titulo='+encodeURIComponent(document.getElementById('titulo').value); param += '&entradilla='+encodeURIComponent(document.getElementById('entradilla').value); for(i = 0; i < totElementos; i ++){ if(aFieldsetCuerpo[i].className == 'parrafo'){//className para identificar en js, no css param += '&parrafo'+i+'='+encodeURIComponent(aFieldsetCuerpo[i].childNodes[1].value); }else if(aFieldsetCuerpo[i].className == 'subtitulo'){ param += '&subtitulo'+i+'='+encodeURIComponent(aFieldsetCuerpo[i].childNodes[1].value); }else if(aFieldsetCuerpo[i].className == 'imagen'){ param += '&imagen'+i+'='+encodeURIComponent(aFieldsetCuerpo[i].getElementsByTagName('form')[0].firstChild.lastChild.value); param += '&pieImagen'+i+'='+encodeURIComponent(aFieldsetCuerpo[i].lastChild.value); }else if(aFieldsetCuerpo[i].className == 'video'){ param += '&video'+i+'='+encodeURIComponent(aFieldsetCuerpo[i].childNodes[2].value); }else if(aFieldsetCuerpo[i].className == 'enlace'){ param += '&enlTexto'+i+'='+encodeURIComponent(aFieldsetCuerpo[i].childNodes[2].value); param += '&enlUrl'+i+'='+encodeURIComponent(aFieldsetCuerpo[i].childNodes[5].value); } } var reqArticulo = objAjax(); if(reqArticulo){ reqArticulo.onreadystatechange = function(){ if(reqArticulo.readyState == 4 && reqArticulo.status == 200){ var respuesta = reqArticulo.responseText; if(respuesta == 'ok'){ //si llegué acá está todo guardado window.location.href = '/' + 'blog/?pend=1'; }else{ restauroCarga(); borroImgsResiduo(); document.getElementById('ajaxFrmPublicar').style.display = 'none'; document.getElementById('avisoBlog').style.display = 'block'; document.getElementById('avisoBlog').innerHTML = diccionario["error_en_serv_post_sin_guardar"] + '.'; } } } reqArticulo.open('POST', '/' + 'serv/ajax/reqGuardarArticulo.php', true); reqArticulo.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqArticulo.setRequestHeader("Content-length", param.length); reqArticulo.setRequestHeader("Connection", "close"); reqArticulo.send(param); } } function guardarComentario(idArt){ var comentario = encodeURIComponent(document.getElementById('comentario').value); if(comentario != ''){ var reqComentario = objAjax(); if(reqComentario){ document.getElementById('ajaxComentario').style.display = 'block'; reqComentario.onreadystatechange = function(){ if(reqComentario.readyState == 4 && reqComentario.status == 200){ var respuesta = reqComentario.responseText; if(respuesta == 'ok'){ window.location.reload(); } document.getElementById('ajaxComentario').style.display = 'none'; } } var param = 'idArt=' + idArt + '&texto=' + comentario; reqComentario.open('POST', '/' + 'serv/ajax/reqGuardarComentario.php', true); reqComentario.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqComentario.setRequestHeader("Content-length", param.length); reqComentario.setRequestHeader("Connection", "close"); reqComentario.send(param); } }else{ document.getElementById('avisoComentario').innerHTML = diccionario['escribe_algo'] + '.'; document.getElementById('avisoComentario').style.display = 'block'; } } // · ·· ··· --- == O == --- ··· ·· · function votarArticulo(idArticulo, voto){ var reqVotar = objAjax(); if(reqVotar){ document.getElementById('ajaxVotar' + idArticulo).style.display = 'block'; reqVotar.onreadystatechange = function(){ if(reqVotar.readyState == 4 && reqVotar.status == 200){ var respuesta = reqVotar.responseText; if(respuesta == 'ok'){ if(voto == 'si'){ document.getElementById('articuloSi' + idArticulo).innerHTML ++; }else{ document.getElementById('articuloNo' + idArticulo).innerHTML ++; } } document.getElementById('ajaxVotar' + idArticulo).style.display = 'none'; } } param = "idArticulo="+idArticulo+"&voto="+voto; reqVotar.open('POST', '/' + 'serv/ajax/reqVotoArticulo.php', true); reqVotar.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqVotar.setRequestHeader("Content-length", param.length); reqVotar.setRequestHeader("Connection", "close"); reqVotar.send(param); } } function articuloErroneo(idArticulo){ var reqError = objAjax(); if(reqError){ document.getElementById('ajaxVotar' + idArticulo).style.display = 'block'; reqError.onreadystatechange = function(){ if(reqError.readyState == 4 && reqError.status == 200){ var respuesta = reqError.responseText; document.getElementById('botonErroneo').innerHTML = '' + respuesta + ''; document.getElementById('ajaxVotar' + idArticulo).style.display = 'none'; } } param = "idArticulo="+idArticulo; reqError.open('POST', '/' + 'serv/ajax/reqArticuloErroneo.php', true); reqError.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqError.setRequestHeader("Content-length", param.length); reqError.setRequestHeader("Connection", "close"); reqError.send(param); } } // · ·· ··· --- == O == --- ··· ·· · function restauroCarga(){ //limpio globales lastIdCampo = 0; aIdInputFile = new Array(); //restauro campos document.getElementById('categoria').options[0].selected = true; document.getElementById('tipoTag').options[0].selected = true; traerTags(); document.getElementById('titulo').value = ''; document.getElementById('entradilla').value = ''; //elimino fieldsets de frmPublicar var aFieldsetCuerpo = document.getElementById('frmPublicar').getElementsByTagName('fieldset'); var totElementos = aFieldsetCuerpo.length; for(i = 0; i < totElementos; i ++){ document.getElementById('frmPublicar').removeChild(aFieldsetCuerpo[0]);//elimino primer fieldset } //limpio vista previa document.getElementById('cat').innerHTML = ''; document.getElementById('tit').innerHTML = ''; document.getElementById('entra').innerHTML = ''; document.getElementById('cuerpoPost').innerHTML = ''; } function borroImgsResiduo(){ //borro las imágenes que pueda haber subido antes de la falla var reqBorroImgs = objAjax(); if(reqBorroImgs){ reqBorroImgs.open('GET', '/' + 'serv/ajax/reqBorrarImgsBlog.php', true); reqBorroImgs.setRequestHeader("Connection", "close"); reqBorroImgs.send(null); } } // · ·· ··· --- == O == --- ··· ·· · function buscarArticulo(){ var param = ''; var blogBuscar, portada, pendientes, categoriaBuscar, tipoTagBuscar, tagBuscar, autor, fechaDesde, fechaHasta; if(document.getElementById('frmBuscarArticulo').style.display != 'block'){//si la búsqueda avanzada está cerrada if((blogBuscar = document.getElementById('blogBuscar').value) != ''){ param += '&blogBuscar=' + encodeURIComponent(blogBuscar); } }else{ if((blogBuscar = document.getElementById('blogBuscar').value) != ''){ param += '&blogBuscar=' + encodeURIComponent(blogBuscar); } if(document.getElementById('portada').checked){ param += '&portPend=portada'; } if(document.getElementById('pendientes').checked){ param += '&portPend=pendientes'; } if((categoriaBuscar = document.getElementById('categoriaBuscar').value) != ''){ param += '&categoriaBuscar=' + encodeURIComponent(categoriaBuscar); } if((tipoTagBuscar = document.getElementById('tipoTagBuscar').value) != ''){ param += '&tipoTagBuscar=' + encodeURIComponent(tipoTagBuscar); } if((tagBuscar = document.getElementById('tagBuscar').value) != ''){ param += '&tagBuscar=' + encodeURIComponent(tagBuscar); } if((autor = document.getElementById('autor').value) != ''){ param += '&autor=' + encodeURIComponent(autor); } if((fechaDesde = document.getElementById('fechaDesde').value) != ''){ param += '&fechaDesde=' + encodeURIComponent(fechaDesde); } if((fechaHasta = document.getElementById('fechaHasta').value) != '' && document.getElementById('fechaHasta').value != document.getElementById('fechaHoy').value){ param += '&fechaHasta=' + encodeURIComponent(fechaHasta); } } if(param != ''){//si hay criterio de búsqueda param = param.substr(1);//quito primer "&" window.location.href = '/' + 'blog/filtro.php?' + param; }else{ window.location.href = '/' + 'blog/filtro.php'; } } function buscarOnEnter(e){ if(window.event){ var tecla = window.event.keyCode; }else if(e){ var tecla = e.which; }else{ return true; } if(tecla == 13){ buscarArticulo(); } } function masBuscarArticulo(){ if(document.getElementById('frmBuscarArticulo').style.display != 'block'){ document.getElementById('frmBuscarArticulo').style.display = 'block'; document.getElementById('flechaMasBuscar').innerHTML = '↑'; }else{ document.getElementById('frmBuscarArticulo').style.display = 'none'; document.getElementById('flechaMasBuscar').innerHTML = '↓'; //restauro form document.getElementById('portada').checked = false; document.getElementById('pendientes').checked = false; document.getElementById('todo').checked = true; document.getElementById('categoriaBuscar').selectedIndex = 0; document.getElementById('tipoTagBuscar').selectedIndex = 0; document.getElementById('tagBuscar').innerHTML = ''; document.getElementById('autor').selectedIndex = 0; document.getElementById('fechaDesde').value = ''; document.getElementById('fechaHasta').value = document.getElementById('fechaHoy').value; } } function cargoModulos(){ var reqVisitados = objAjax(); if(reqVisitados){ reqVisitados.onreadystatechange = function(){ if(reqVisitados.readyState == 4 && reqVisitados.status == 200){ var respuesta = reqVisitados.responseText; document.getElementById('modMasVisitados').innerHTML = respuesta; } } reqVisitados.open('GET', '/' + 'ajax/modMasVisitados.php', true); reqVisitados.setRequestHeader("Connection", "close"); reqVisitados.send(null); } var reqVotados = objAjax(); if(reqVotados){ reqVotados.onreadystatechange = function(){ if(reqVotados.readyState == 4 && reqVotados.status == 200){ var respuesta = reqVotados.responseText; document.getElementById('modMasVotados').innerHTML = respuesta; } } reqVotados.open('GET', '/' + 'ajax/modMasVotados.php', true); reqVotados.setRequestHeader("Connection", "close"); reqVotados.send(null); } var reqUltimasFichas = objAjax(); if(reqUltimasFichas){ reqUltimasFichas.onreadystatechange = function(){ if(reqUltimasFichas.readyState == 4 && reqUltimasFichas.status == 200){ var respuesta = reqUltimasFichas.responseText; document.getElementById('modUltimasFichas').innerHTML = respuesta; } } reqUltimasFichas.open('GET', '/' + 'ajax/modUltimasFichas.php', true); reqUltimasFichas.setRequestHeader("Connection", "close"); reqUltimasFichas.send(null); } } function agendoDesagendo(idSerie, confirm){ var agendada = document.getElementById('imgAgendar'+idSerie).src == '/' + 'img/star_si.png' ? true : false; if(agendada){ if(confirm){ //seguro que la quitás? var confirmo = document.getElementById("estasDesagendando").value; confirmo += ''; confirmo += document.getElementById("cancelar").value + ''; confirmo += ''; confirmo += document.getElementById("continuar").value + ''; document.getElementById('txtAvisoTemporadas'+idSerie).innerHTML = confirmo; document.getElementById('avisoTemporadas'+idSerie).style.display = "block"; }else{ desagendo(idSerie, confirm); } }else{ agendo(idSerie, confirm); } } function agendo(idSerie, confirm){ var reqAgendoDesagendo = objAjax(); if(reqAgendoDesagendo){ document.getElementById('ajaxSerie'+idSerie).style.display = 'block'; reqAgendoDesagendo.onreadystatechange = function(){ if(reqAgendoDesagendo.readyState == 4 && reqAgendoDesagendo.status == 200){ var respuesta = reqAgendoDesagendo.responseText; //si agendé traigo ok/error, titleAgendar, titleVisto, aviso eval('var aRespuesta = ' + respuesta); if(aRespuesta[0] = 'ok'){ document.getElementById('imgAgendar'+idSerie).src = '/' + 'img/star_si.png'; document.getElementById('agendar'+idSerie).title = aRespuesta[1]; if(confirm){ cuandoAgendo(idSerie, aRespuesta[2], aRespuesta[3]); } } document.getElementById('ajaxSerie'+idSerie).style.display = 'none'; } } var parametros = 'idserie=' + idSerie + '&accion=agregar'; reqAgendoDesagendo.open('POST', '/' + 'serv/ajax/reqAgendar.php', true); reqAgendoDesagendo.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqAgendoDesagendo.setRequestHeader("Content-length", parametros.length); reqAgendoDesagendo.setRequestHeader("Connection", "close"); reqAgendoDesagendo.send(parametros); } } function desagendo(idSerie, confirm){ var reqAgendoDesagendo = objAjax(); if(reqAgendoDesagendo){ document.getElementById('ajaxSerie'+idSerie).style.display = 'block'; reqAgendoDesagendo.onreadystatechange = function(){ if(reqAgendoDesagendo.readyState == 4 && reqAgendoDesagendo.status == 200){ var respuesta = reqAgendoDesagendo.responseText; //si desagendé traigo ok/error, titleAgendar, titleVisto eval('var aRespuesta = ' + respuesta); if(aRespuesta[0] = 'ok'){ document.getElementById('imgAgendar'+idSerie).src = '/' + 'img/star_no.png'; document.getElementById('agendar'+idSerie).title = aRespuesta[1]; if(confirm){ cuandoDesagendo(idSerie, aRespuesta[2]); } } document.getElementById('ajaxSerie'+idSerie).style.display = 'none'; } } var parametros = 'idserie=' + idSerie + '&accion=quitar'; reqAgendoDesagendo.open('POST', '/' + 'serv/ajax/reqAgendar.php', true); reqAgendoDesagendo.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); reqAgendoDesagendo.setRequestHeader("Content-length", parametros.length); reqAgendoDesagendo.setRequestHeader("Connection", "close"); reqAgendoDesagendo.send(parametros); } } function cuandoAgendo(idSerie, titleVisto, aviso){ if(document.getElementById('temporadas'+idSerie).style.display == "block"){ abroCierroTemps(idSerie); abroCierroFicha(idSerie); } document.getElementById('txtAvisoTemporadas'+idSerie).innerHTML = aviso; document.getElementById('avisoTemporadas'+idSerie).style.display = "block"; var aVistoEpiActual = document.getElementsByName('visto'+idSerie); var aEstado = document.getElementsByName('estado'+idSerie); var aBarraEpi = document.getElementsByName('barraEpiActual'+idSerie);//para extraer tem y epi del id de la barra var totalVistoEpiActual = aVistoEpiActual.length; for(var nn = 0; nn < totalVistoEpiActual; nn ++){ if(aEstado[nn].value != "noEmitido"){ aVistoEpiActual[nn].style.cursor = "pointer"; aVistoEpiActual[nn].title = titleVisto; var posS = aBarraEpi[nn].id.indexOf('S'); var tem = parseInt(aBarraEpi[nn].id.substr(posS + 1, 2), 10); var posE = posS + 3; var epi = parseInt(aBarraEpi[nn].id.substr(posE + 1, 2), 10); var se = formateoSnnEnn(tem, epi); eval('aVistoEpiActual['+nn+'].onclick = function (){epiVisto('+idSerie+','+tem+','+epi+')}'); } } } function cuandoDesagendo(idSerie, titleVisto){ if(document.getElementById('temporadas'+idSerie).style.display == "block"){ abroCierroTemps(idSerie); abroCierroFicha(idSerie); } var aVistoEpiActual = document.getElementsByName('visto'+idSerie); var aImgVistoEpiActual = document.getElementsByName('imgVisto'+idSerie); var aEstado = document.getElementsByName('estado'+idSerie); var totalVistoEpiActual = aVistoEpiActual.length; for(var nn = 0; nn < totalVistoEpiActual; nn ++){ if(aEstado[nn].value != "noEmitido"){ aVistoEpiActual[nn].style.cursor = "default"; aImgVistoEpiActual[nn].src = '/' + 'img/chk_no.png'; aVistoEpiActual[nn].title = ''; aVistoEpiActual[nn].onclick = function (){void(0)}; } } } // STYLING FILE INPUTS 1.0 | Shaun Inman | 2007-09-07 if (!window.SI) { var SI = {}; }; SI.Files = { htmlClass : 'SI-FILES-STYLIZED', fileClass : 'file', wrapClass : 'botonFile', fini : false, able : false, init : function() { this.fini = true; var ie = 0 //@cc_on + @_jscript_version if (window.opera || (ie && ie < 5.5) || !document.getElementsByTagName) { return; } // no support for opacity or the DOM this.able = true; var html = document.getElementsByTagName('html')[0]; html.className += (html.className != '' ? ' ' : '') + this.htmlClass; }, stylize : function(elem) { if (!this.fini) { this.init(); }; if (!this.able) { return; }; elem.parentNode.file = elem; elem.parentNode.onmousemove = function(e) { if (typeof e == 'undefined') e = window.event; if (typeof e.pageY == 'undefined' && typeof e.clientX == 'number' && document.documentElement) { e.pageX = e.clientX + document.documentElement.scrollLeft; e.pageY = e.clientY + document.documentElement.scrollTop; }; var ox = oy = 0; var elem = this; if (elem.offsetParent) { ox = elem.offsetLeft; oy = elem.offsetTop; while (elem = elem.offsetParent) { ox += elem.offsetLeft; oy += elem.offsetTop; }; }; var x = e.pageX - ox; var y = e.pageY - oy; var w = this.file.offsetWidth; var h = this.file.offsetHeight; this.file.style.top = y - (h / 2) + 'px'; this.file.style.left = x - (w - 30) + 'px'; }; }, stylizeById : function(id) { this.stylize(document.getElementById(id)); }, stylizeAll : function() { if (!this.fini) { this.init(); }; if (!this.able) { return; }; var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { var input = inputs[i]; if (input.type == 'file' && input.className.indexOf(this.fileClass) != -1 && input.parentNode.className.indexOf(this.wrapClass) != -1) { this.stylize(input); }; }; } };