debug(tracker): визуальный бейдж в правом нижнем углу + серверный лог POST'ов
This commit is contained in:
@@ -214,6 +214,8 @@ router.get('/:slug', (req, res) => {
|
||||
|
||||
/* POST /api/textbooks/:slug/progress — update progress */
|
||||
router.post('/:slug/progress', (req, res) => {
|
||||
// DEBUG: log incoming progress writes
|
||||
console.log('[progress]', new Date().toISOString(), 'user', req.user && req.user.id, '| slug=', req.params.slug, '| body=', JSON.stringify(req.body || {}));
|
||||
const t = db.prepare('SELECT id FROM textbooks WHERE slug=? AND is_active=1').get(req.params.slug);
|
||||
if (!t) return res.status(404).json({ error: 'Учебник не найден' });
|
||||
|
||||
|
||||
@@ -235,6 +235,30 @@
|
||||
refreshCheckUI(key);
|
||||
persist();
|
||||
syncToServer({ mark_read: key });
|
||||
updateDebugBadge();
|
||||
}
|
||||
|
||||
// DEBUG: визуальный бейдж прогресса в правом нижнем углу.
|
||||
function ensureDebugBadge() {
|
||||
if (document.getElementById('tb-debug-badge')) return;
|
||||
const b = document.createElement('div');
|
||||
b.id = 'tb-debug-badge';
|
||||
b.style.cssText = 'position:fixed;bottom:12px;right:12px;z-index:99999;background:rgba(15,23,42,.92);color:#fff;padding:10px 14px;border-radius:10px;font-family:monospace;font-size:12px;line-height:1.5;box-shadow:0 4px 14px rgba(0,0,0,.3);max-width:260px';
|
||||
document.body.appendChild(b);
|
||||
updateDebugBadge();
|
||||
}
|
||||
function updateDebugBadge() {
|
||||
const b = document.getElementById('tb-debug-badge');
|
||||
if (!b) return;
|
||||
const activeParaEl = document.querySelector('.para-pill.active[data-para]');
|
||||
const active = activeParaEl ? activeParaEl.dataset.para : '?';
|
||||
b.innerHTML =
|
||||
'<div><b>tracker debug</b></div>' +
|
||||
'<div>slug: ' + slug + '</div>' +
|
||||
'<div>active pill: ' + active + '</div>' +
|
||||
'<div>localState.last: ' + (localState.last || '?') + '</div>' +
|
||||
'<div>read [' + localState.read.length + ']: ' + (localState.read.slice(-8).join(',') || '—') + '</div>' +
|
||||
'<div style="opacity:.6;margin-top:4px">Кликай пилюли — должно меняться</div>';
|
||||
}
|
||||
|
||||
function wirePillTracking() {
|
||||
@@ -532,6 +556,8 @@
|
||||
|
||||
function boot() {
|
||||
console.log('[tracker] boot, slug =', slug, '| LS:', typeof LS !== 'undefined', '| token:', typeof LS !== 'undefined' && LS.getToken && !!LS.getToken());
|
||||
ensureDebugBadge();
|
||||
setInterval(updateDebugBadge, 1000);
|
||||
injectStyles();
|
||||
installBackButton();
|
||||
installBookmarksBtn();
|
||||
|
||||
Reference in New Issue
Block a user