$(document).ready(function(){
// Recorremos los comentarios del listado
$("ol.commentlist li").each(function(x, el){
// Cogemos el ID del comentario
var ID = $(el).attr("id");
// Cogemos el nombre del autor del comentario
var author = $(el).find("cite a").text();
// Añadimos el enlace en la parte inferior del comentario.
$(el).append('Responder a ' + author + '');
// Le añadimos funcionalidad
$(el).find(".a-responder").bind("click", function(){
// Guardamos el elemento
var link = $(this);
// Añadimos el y el
$(link).after('');
// Le añadimos funcionalidad al
$(el).find(".btn-responder").bind("click", function(){
// Guardamos el texto anterior
var oldText = $("textarea#comment").val() + "\n";
// Preparamos el nuevo texto.
var newText = '\n' + author +": "+ $(this).prev().val();
// Añadimos el nuevo texto
$("textarea#comment").val(oldText + newText);
// Eliminamos el y el
$(this).parent().remove();
// Mostramos el enlace
$(link).show();
});
// Ocultamos el enlace
$(link).hide();
// Paramos la ejecución del enlace
return false;
});
});
});