rendered paste body// Add a comment
function addComment() {
var commentUrl = window.location + '/add-comment';
var commentName = $F('sm-comment-name');
var commentEmail = $F('sm-comment-email');
var commentComment = $F('sm-comment-comment');
//var commentCaptcha = $F('sm-comment-captcha');
new Ajax.Request(commentUrl, {method:'post', postBody:'name=' + commentName + '&email=' + commentEmail + '&comment=' + commentComment, onSuccess:function(t) {
var responseArray = t.responseText.split('|');
if (responseArray[0] == '0') {
alert(responseArray[3]);
}
else {
createComment(responseArray[1], responseArray[2], commentName, commentEmail, commentComment);
}
bbx }, onFailure:ajaxError});
}
// Create a comment
function createComment(commentId, commentDate, commentName, commentEmail, commentComment) {
var element=$E({
tag:'div',
className:'sm-item-comment',
id:'sm-item-comment-' + commentId,
children:{
tag:'table',
width:'290',
children:[{
tag:'tr',
children:[{
tag:'td',
className:'sm-item-comment-cell',
width:'66',
children:[{
tag:'div',
className:'sm-item-comment-avatar',
children:[{
tag:'img',
height:'64',
width:'64',
src:'http://www.gravatar.com/avatar.php?gravatar_id=' + hex_md5(commentEmail) + '&size=64'
}]
}]
},
{
tag:'td',
className:'sm-item-comment-cell',
align:'left',
width:'224',
children:[{
tag:'div',
className:'sm-item-comment-user',
children:[commentName]
},
{
tag:'div',
className:'sm-item-comment-date',
children:[commentDate]
},
{
tag:'div',
className:'sm-item-comment-comment',
children:[commentComment]
}]
}]
}]
}
});
// In IE, all the following code is excuted and works
// EXCEPT $('sm-comments').appendChild(element);
if ($('sm-comment-no-comments')) {
$('sm-comment-no-comments').style.display = 'none';
}
$('sm-comments').appendChild(element);
$('sm-add-comment').style.display = 'none';
var currentComments = $('comment-count');
currentComments.innerHTML = parseInt(currentComments.innerHTML, 10) + 1;
}