var curr_error_block_id = ''; function updateErrorBlock( status, comment_id ) { if ( comment_id == '' ) { showCommentReplyForm( '' );}
try { $( curr_error_block_id ).style.display = 'none';} catch( e ) { }
try { if ( status == 1 ) { $( 'error_text_' + comment_id ).style.display = 'block'; curr_error_block_id = 'error_text_' + comment_id;} else if ( status == 2 || status.match(/^badword:/) ) { $( 'error_badword_text_' + comment_id ).innerHTML = '("' + status.substring(status.indexOf(':')+1) + '")'; $( 'error_badword_' + comment_id ).style.display = 'block'; curr_error_block_id = 'error_badword_' + comment_id;} else { $( 'error_unknown_' + comment_id ).style.display = 'block'; curr_error_block_id = 'error_unknown_' + comment_id;}
} catch ( e ) { }
}
function submitForumComment( topic_id, comment_id, page_no, url_params ) { if ( topic_id == '' ) { return false;}
var time = (new Date).getTime(); if (window.lastCommentTime && (time - window.lastCommentTime < 5000) ) { return false;}
window.lastCommentTime = time; var comment_text = $( 'comment_textarea_' + comment_id ).value; comment_text = comment_text.replace( /&/, '%26' ); var url = root_url + 'index.php?act=forums/create_comment/process&topic_id=' + topic_id + '&comment_id=' + comment_id; var params = ''; var postData = 'text=' + comment_text; var ajaxRequest = new Ajax.Request( url, { method: 'post', postBody: postData, parameters: params, onSuccess: function (req) { var response = req.responseText; if ( response.length == 1 || response.match(/^badword:/) ) { updateErrorBlock( response, comment_id );} else { if ( page_no == 'comments_content' ) { reloadContent( response, 'comments_content' );} else { if( url_params != '' ) { changePage( topic_id, 'js/forum_topic', page_no, 'comments_content', url_params );} else { changePage( topic_id, 'js/forum_topic', page_no, 'comments_content' );}
}
}
}, onFailure: function (req) { updateErrorBlock( 0, comment_id );}
} );}
function sortComments( topic_id, order, url_params ) { if ( topic_id == '' || order == '' ) { return false;}
var url = root_url + 'index.php?act=js/forum_topic&item_id=' + topic_id + '&sort=' + order; if( url_params != '' ) { url = url + url_params;}
var params = ''; setPreloader('comments_content'); var ajaxRequest = new Ajax.Request( url, { method: 'get', parameters: params, onSuccess: function (req) { var response = req.responseText; if ( response !== '' ) { reloadContent( response, 'comments_content' );}
}, onFailure: function (req) { unsetBlock('comments_content');}
} );}
function changeWatchingStatus( topic_id, operation, url_params ) { if ( topic_id == '' || operation == '' ) { return false;}
var url = root_url + 'index.php'; if ( operation == 'start' ) { url += '?act=forums/topic_watching/start&topic_id=' + topic_id;} else if ( operation == 'stop' ) { url += '?act=forums/topic_watching/stop&topic_id=' + topic_id;} else { return false;}
if( url_params != '' ) { url = url + url_params;}
var params = ''; setPreloader('comments_content'); var ajaxRequest = new Ajax.Request( url, { method: 'get', parameters: params, onSuccess: function (req) { var response = req.responseText; if ( response.length == 1 ) { unsetBlock('comments_content');} else { reloadContent( response, 'comments_content' );}
}, onFailure: function (req) { unsetBlock('comments_content');}
} );}