/**
* WordPress jQuery-Ajax-Comments v1.3 by Willin Kan.
* URI: http://kan.willin.org/?p=1271
*/
var i = 0, got = -1, len = document.getElementsByTagName('script').length;
while ( i <= len && got == -1){
var js_url = document.getElementsByTagName('script')[i].src,
got = js_url.indexOf('comments-ajax.js'); i++ ;
}
var edit_mode = '1', // 再編輯模式 ( '1'=開; '0'=不開 )
ajax_php_url = js_url.replace('-ajax.js','-ajax.php'),
wp_url = js_url.substr(0, js_url.indexOf('wp-content')),
pic_sb = wp_url + 'wp-admin/images/loading.gif', // 提交 icon
pic_no = wp_url + 'wp-admin/images/no.png', // 錯誤 icon
pic_ys = wp_url + 'wp-admin/images/yes.png', // 成功 icon
txt1 = '

正在提交, 請稍候...
',
txt2 = '#
',
txt3 = '">
留言成功',
edt1 = ', 刷新页面之前可以',
cancel_edit = '取消编辑',
edit, num = 1, comm_array=[]; comm_array.push('');
jQuery(document).ready(function($) {
$comments = $('#comments-title'); // 評論數的 ID
$cancel = $('#cancel-comment-reply-link'); cancel_text = $cancel.text();
$submit = $('#commentform #submit'); $submit.attr('disabled', false);
$('#submit').after( txt1 + txt2 ); $('#loading').hide(); $('#error').hide();
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
/** submit */
$('#commentform').submit(function() {
$('#loading').show();
$submit.attr('disabled', true).fadeTo('slow', 0.5);
if ( edit ) $('#comment').after('');
/** Ajax */
$.ajax({
url: ajax_php_url,
data: $(this).serialize(),
type: $(this).attr('method'),
error: function(request) {
$('#loading').hide();
$('#error').show().html('
' + request.responseText);
setTimeout(function() {$submit.attr('disabled', false).fadeTo('slow', 1); $('#error').hide();}, 1500);
},
success: function(data) {
$('#loading').hide();
comm_array.push($('#comment').val());
$('textarea').each(function() {this.value = ''});
var t = addComment, cancel = t.I('cancel-comment-reply-link'), temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId), post = t.I('comment_post_ID').value, parent = t.I('comment_parent').value;
// comments
if ( ! edit && $comments.length ) {
n = parseInt($comments.text().match(/\d+/));
$comments.text($comments.text().replace( n, n + 1 ));
}
// show comment
new_htm = '"id="new_comm_' + num + '">';
new_htm = ( parent == '0' ) ? ('\n