| Server IP : 45.152.65.97 / Your IP : 216.73.216.194 Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1p mod_fcgid/2.3.9a System : Windows NT C20260123164925 10.0 build 20348 (Windows Server 2016) AMD64 User : SYSTEM ( 0) PHP Version : 7.4.33 Disable Function : passthru,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,putenv,exec MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/wwwroot/shujupai.cn/wp-content/plugins/jingcaizuqiu/assets/js/ |
Upload File : |
jQuery(document).ready(function($) {
console.log('JCZP Admin JS loaded');
if ($('#jczp-test-api').length) {
console.log('Test API button found');
} else {
console.log('Test API button not found');
}
$('#jczp-manual-predict').on('click', function() {
console.log('Manual predict button clicked');
var $button = $(this);
var $result = $('#jczp-result');
$button.prop('disabled', true).text('正在处理...');
$result.hide().html('');
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'jczp_manual_predict',
security: typeof jczp_nonce !== 'undefined' ? jczp_nonce : ''
},
success: function(response) {
console.log('Manual predict response:', response);
if (response.success) {
var html = '<div class="jczp-success">';
html += '<h3>预测成功!</h3>';
html += '<p>文章已发布,<a href="' + response.data.post_url + '" target="_blank">点击查看</a></p>';
html += '<h4>今日比赛预测结果:</h4>';
html += '<table class="jczp-matches-table">';
html += '<thead><tr><th>编号</th><th>联赛</th><th>时间</th><th>对阵</th><th>预测</th><th>信心指数</th><th>结果</th></tr></thead>';
html += '<tbody>';
$.each(response.data.matches, function(index, match) {
var predictionClass = '';
if (match.prediction === '胜') {
predictionClass = 'jczp-prediction-win';
} else if (match.prediction === '平') {
predictionClass = 'jczp-prediction-draw';
} else {
predictionClass = 'jczp-prediction-loss';
}
var resultHtml = '-';
if (match.is_correct !== undefined) {
if (match.is_correct) {
resultHtml = '<span class="jczp-result-correct">中</span>';
} else {
resultHtml = '<span class="jczp-result-incorrect">未中</span>';
}
}
html += '<tr data-match-id="' + match.id + '">';
html += '<td><strong>' + match.number + '</strong></td>';
html += '<td>' + match.league + '</td>';
html += '<td>' + match.time + '</td>';
html += '<td>' + match.home_team + ' VS ' + match.away_team + '</td>';
html += '<td><span class="' + predictionClass + '">' + match.home_team + match.prediction + '</span></td>';
html += '<td>' + match.confidence + '%</td>';
html += '<td>' + resultHtml + '</td>';
html += '</tr>';
});
html += '</tbody></table>';
html += '</div>';
$result.html(html).show();
} else {
$result.html('<div class="jczp-error"><h3>出错了!</h3><p>' + response.data + '</p></div>').show();
}
},
error: function(xhr, status, error) {
console.log('Manual predict error:', error);
$result.html('<div class="jczp-error"><h3>请求失败!</h3><p>请稍后重试。</p></div>').show();
},
complete: function() {
$button.prop('disabled', false).text('立即预测并发布');
}
});
});
$('#jczp-test-api').on('click', function() {
console.log('Test API button clicked');
var $button = $(this);
var $result = $('#jczp-result');
$button.prop('disabled', true).text('测试中...');
$result.hide().html('');
console.log('Ajax URL:', ajaxurl);
console.log('Nonce:', typeof jczp_nonce !== 'undefined' ? jczp_nonce : 'undefined');
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'jczp_test_api',
security: typeof jczp_nonce !== 'undefined' ? jczp_nonce : ''
},
success: function(response) {
console.log('Test API response:', response);
if (response.success) {
var html = '<div class="jczp-success">';
html += '<h3>API测试结果</h3>';
html += '<p>' + response.data.message + '</p>';
html += '<p>获取到 ' + response.data.matches_count + ' 场比赛</p>';
html += '</div>';
$result.html(html).show();
} else {
$result.html('<div class="jczp-error"><h3>测试失败!</h3><p>' + response.data + '</p></div>').show();
}
},
error: function(xhr, status, error) {
console.log('Test API error:', error);
$result.html('<div class="jczp-error"><h3>请求失败!</h3><p>请稍后重试。</p></div>').show();
},
complete: function() {
$button.prop('disabled', false).text('测试API连接');
}
});
});
function updateMatchResults() {
$('tr[data-match-id]').each(function() {
var matchId = $(this).data('match-id');
var resultCell = $(this).find('td:last-child');
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: 'jczp_get_match_result',
match_id: matchId,
security: typeof jczp_nonce !== 'undefined' ? jczp_nonce : ''
},
success: function(response) {
if (response.success) {
if (response.data.is_correct) {
resultCell.html('<span class="jczp-result-correct">中</span>');
} else {
resultCell.html('<span class="jczp-result-incorrect">未中</span>');
}
}
}
});
});
}
updateMatchResults();
});