"ESTE TUTORIAL ES PARA PLANTILLAS NO ACTUALIZADAS A EL NUEVO DISEÑO DE BLOGGER."
Muchos desean agregar la posibilidad de agragar emoticones en los blog, tanto en plantillas como comentarios, aqui les muestro la manera de hacerlo. Originalmente este post lo publique en cutepocket.blogspot.com, si tiene dudas, comentarios o sugerencias </head>Una vez localizado colocaremos ENCIMA de este el siguiente script
<!-- (Script Emoticones) -->PROPIEDADES
<script type='text/javascript'>
//<![CDATA[
document.getElementsByClassName = function(clsName){
var retVal = new Array();
var elements = document.getElementsByTagName("*");
for(var i = 0;i < elements.length;i++){
if(elements[i].className.indexOf(" ") >= 0){
var classes = elements[i].className.split(" ");
for(var j = 0;j < classes.length;j++){
if(classes[j] == clsName)
retVal.push(elements[i]);
}
}
else if(elements[i].className == clsName)
retVal.push(elements[i]);
}
return retVal;
}
function addSmiley(){
var postBodyClass = (postBodyClass) ? postBodyClass : 'post-body';
var d = document.getElementsByClassName(postBodyClass);
for(var i=0;i<d.length;i++){
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\)/gi, ' <img src=" http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/9j2m9d.gif" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-S/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/681.jpg" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-P/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/71.jpg" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\[/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/581.jpg" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-D/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/31.jpg" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\}\:\-\]/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/211.jpg" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/x\*/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/811.jpg" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\;\-D/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/111.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\|/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/841.jpg" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\}/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/2hh249d.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\*\)/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/531.jpg" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\(/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/501.jpg" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\;\-\)/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emotic2/2ykzz1s.gif" style="border:0; margin:0; padding:0;" id="new" /> ');
}
var d = document.getElementsByClassName('comment-body');
for(var i=0;i<d.length;i++){
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\)/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img3123.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-S/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0549.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-P/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img1089.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\[/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0813.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-D/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0897.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\}\:\-\]/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0900.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/x\*/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0776.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\;\-D/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0594.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\|/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0453.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\}/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0786.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\*\)/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0987.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\:\-\(/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0687.png" style="border:0; margin:0; padding:0;" id="new" /> ');
d[i].innerHTML = d[i].innerHTML.replace(/\;\-\)/gi, ' <img src="http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0571.png" style="border:0; margin:0; padding:0;" id="new" /> ');
}
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
addLoadEvent(addSmiley);
//]]>
</script>
<!-- (Fin Script Emoticones) -->
Postbodyclass: Son los iconos o emoticones que iran en tus entradas
Comment-body: Son los emoticones que tus visitantes podran utilizar al dejar un comentario.
Rojo: lo que esta en rojo son los simbolos que utilizaras para colocar un emoticon, o en otras palabras la carita, es decir si colocamos :-) en el posto o comentario esto de inmediato se sustituira por una imagen. estos se encuentran divididos por diagonales /, si no quieres experimentar mucho es preferible dejar esos codigos en paz a menos que ya tengas conocimiendo de estos Scripts, de lo contrario puede resultar un dolor de cabeza.
Azul: es la direccion en la cual esta alojada la imagen, si no te gustan los que yo he colocado simplemente puedes cambiarlos por los tuyos.
Bien, ya con esto nuestro blog tendra la habilidad de colocar los emoticones, solo falta hacerle saber a tus visitantes cuales codigos le corresponden a cada imagen, y para eso debajo de:
<h4 id='comment-post-message'><data:postCommentMsg/></h4><p><data:blogCommentMessage/></p>colocaremos un codigo que nos muestre arriba del formulario de comentarios una cajita con los iconos disponibles y sus simbolos correspondientes.
<!-- ini tabla emoticones -->
<table border='0' cellpadding='0' cellspacing='1'>
<tr>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img3123.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0549.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img1089.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0813.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0897.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0900.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0776.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0594.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0453.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0786.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0987.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0687.png' width='20'/></td>
<td align='center' width='26'><img height='21' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img0571.png' width='20'/></td>
<td align='center' width='26'><img height='20' src='http://i491.photobucket.com/albums/rr277/kagamine_ren/emoticons/MsgPlus_Img1246.png' width='20'/></td>
</tr>
<tr>
<td align='center' width='26'>:-)</td>
<td align='center' width='26'>:-S</td>
<td align='center' width='26'>:-P</td>
<td align='center' width='26'>:-[</td>
<td align='center' width='26'>:-D</td>
<td align='center' width='26'>}:-]</td>
<td align='center' width='26'>X*</td>
<td align='center' width='26'>;-D</td>
<td align='center' width='26'>:-|</td>
<td align='center' width='26'>:-}</td>
<td align='center' width='26'>:*)</td>
<td align='center' width='26'>:-(</td>
<td align='center' width='26'>;-)</td>
</tr>
</table>
<!-- fin tabla emoticones -->
PROPIEDADES
Verde: con estas podremos jugar con la altura y anchura de la imagen que estara ensima de nuestro formulario de comentarios.
Azul: Sera la URL de la imagen, asegurate que coincida con las que pusiste en el codigo anterior.
Rojo: le muestra a los usuarios que codigo es el necesario para cada emoticon.
Al final nuestro resultado sera el siguiente.
NOTA:
Para que las caritas se muestren ensima del formulario de comentarios, este tiene que estar incrustrado en la entrada, de lo contrario no se mostrara.
Para solucionar esto ve a Blogger >> Configuracion >> Comentarios
Ubicacion de formulario de comentarios >> entrada incrustada a continuacion.
Si utilizas plantilla clasica no se si este script sirva, lo he intentado colocar y no me da resultado :/ pero de igual manera eres libre de intentarlo
Me gustó mucho este tutorial así que trataré de en breve usarlo. Eso sí, probablemente cambie los emoticones. ¡Gracias! =)
ReplyDeletebuenas muy lindo, que desventajas ofrece esa programación, y por que si la diseñó no la aplica a su página?
ReplyDelete