<?php ?> <script nonce="<?= $cspNonce ?> "> (function(){ var panel = document.getElementById('panel-wd-predict'); if(!panel) return; panel.innerHTML = '<div class="wd-toolbar"><button id="wd-pred-refresh" class="btn btn-sm">Refresh</button></div>' + '<div id="wd-pred-grid" class="wd-grid"></div>'; var grid = document.getElementById('wd-pred-grid'); function loadPredictions(){ fetch('api/system/pulse.php?scope=watchdog_predictions&_t='+Date.now(), {credentials:'same-origin'}) .then(function(r){return r.json()}) .then(function(d){ grid.innerHTML = ''; if(!d.predictions || !d.predictions.length){ grid.innerHTML = '<div class="wd-empty">No active predictions</div>'; return; } d.predictions.forEach(function(p){ var card = document.createElement('div'); card.className = 'wd-card wd-pred-card'; var conf = Math.round(p.confidence); var confColor = conf >= 70 ? '#4a9' : conf >= 40 ? '#fa3' : '#888'; card.innerHTML = '<div class="wd-card-header"><span class="wd-fp">'+(p.fp||'').substring(0,12)+'</span><span class="wd-trust" style="color:'+confColor+'">'+conf+'%</span></div>' + '<div class="wd-card-body">' + '<div class="wd-pred-action">Next: <strong>'+p.predicted+'</strong></div>' + '<div class="wd-meta">Current: '+p.current_page+'</div>' + '<div class="wd-meta">Session: '+p.session_time+'s · '+p.pages+' pages</div>' + (p.was_correct !== null ? '<div class="wd-pred-result '+(p.was_correct?'wd-correct':'wd-wrong')+'">'+(p.was_correct?'✓ Correct':'✗ Wrong')+'</div>' : '') + '</div>'; grid.appendChild(card); }); }).catch(function(){}); } document.getElementById('wd-pred-refresh').addEventListener('click', loadPredictions); setInterval(loadPredictions, 5000); loadPredictions(); })(); </script>