v1.0.86: один fetch elements_json, обе панели — все элементы

This commit is contained in:
2026-06-21 09:50:16 +04:00
parent febad42e45
commit b26016fcb1
+42 -49
View File
@@ -71,7 +71,7 @@
<body>
<div class="topbar">
<img src="/nubes-logo.svg" alt="Nubes">
<span class="title">Сверка договоров — LLM <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.85 — Lucee</span></span>
<span class="title">Сверка договоров — LLM <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.86 — Lucee</span></span>
</div>
<div class="content">
@@ -562,24 +562,45 @@ async function showText(i) {
modal.classList.add('wide');
document.getElementById('modalOverlay').classList.add('open');
// Левая панель: сырой текст
var leftHtml = '<span style="color:var(--muted);">Загрузка...</span>';
var rightHtml = '';
if (docId) {
try {
var vResp = await fetch('/view.cfm?doc_id=' + docId);
var rawText = await vResp.text();
rawText = rawText.replace(/^\s+/, '');
leftHtml = '<pre>' + rawText.replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</pre>';
} catch(e) {
leftHtml = '<span style="color:var(--destructive);">Ошибка</span>';
}
} else {
leftHtml = '<span style="color:var(--muted);">(ещё не загружен)</span>';
var qResp = await fetch('/api.cfm?action=query&sql=SELECT%20elements_json%20FROM%20documents%20WHERE%20id%3D\'' + docId + '\'');
var qData = await qResp.json();
var elements = [];
if (qData.OK && qData.ROWS && qData.ROWS.length > 0) {
var ej = qData.ROWS[0].ELEMENTS_JSON;
if (typeof ej === 'object' && ej.Value) ej = ej.Value;
elements = JSON.parse(ej);
}
// Правая панель: распарсено — все элементы полностью
var rightHtml = '';
// Базовая инфа сверху
// Общий textify для обеих панелей
var textLines = [];
elements.forEach(function(el) {
var etype = el.type || el.TYPE || '?';
if (etype === 'paragraph') {
textLines.push(el.text || el.TEXT || '');
} else if (etype === 'table') {
var rows = el.rows || el.ROWS || [];
if (rows.length > 0) {
var ncols = (rows[0]||[]).length;
textLines.push('--- Таблица ' + rows.length + '×' + ncols + ' ---');
rows.forEach(function(row) {
var cells = (row||[]).map(function(c){ return String(c||'').replace(/\n/g,' ').replace(/\|/g,'\\|'); });
textLines.push('| ' + cells.join(' | ') + ' |');
});
textLines.push('');
}
}
});
var textify = textLines.join('\n').replace(/</g,'&lt;').replace(/>/g,'&gt;');
// Левая: сырой текст (textify)
leftHtml = '<pre>' + textify + '</pre>';
// Правая: статистика + textify
rightHtml += '<div class="kv"><span class="k">Размер</span><span class="v">' + formatSize(f.size) + '</span></div>';
rightHtml += '<div class="kv"><span class="k">Изменён</span><span class="v">' + formatDate(f.lastModified) + '</span></div>';
if (f.parseInfo) {
@@ -598,47 +619,19 @@ async function showText(i) {
rightHtml += '<pre>' + d.ERRORS.join('\n') + '</pre>';
}
}
// Все элементы из БД
if (docId) {
try {
var qResp = await fetch('/api.cfm?action=query&sql=SELECT%20elements_json%20FROM%20documents%20WHERE%20id%3D\'' + docId + '\'');
var qData = await qResp.json();
if (qData.OK && qData.ROWS && qData.ROWS.length > 0) {
var ej = qData.ROWS[0].ELEMENTS_JSON;
if (typeof ej === 'object' && ej.Value) ej = ej.Value;
var elements = JSON.parse(ej);
rightHtml += '<div style="margin-top:10px;font-weight:600;font-size:12px;">Все элементы:</div>';
var lines = [];
elements.forEach(function(el) {
var etype = el.type || el.TYPE || '?';
if (etype === 'paragraph') {
lines.push((el.text || el.TEXT || ''));
} else if (etype === 'table') {
var rows = el.rows || el.ROWS || [];
if (rows.length > 0) {
var ncols = (rows[0]||[]).length;
lines.push('--- Таблица ' + rows.length + '×' + ncols + ' ---');
rows.forEach(function(row) {
var cells = (row||[]).map(function(c){ return String(c||'').replace(/\n/g,' ').replace(/\|/g,'\\|'); });
lines.push('| ' + cells.join(' | ') + ' |');
});
lines.push('');
}
}
});
rightHtml += '<pre>' + lines.join('\n').replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</pre>';
}
} catch(e) {
rightHtml += '<div style="color:var(--muted);margin-top:8px;">Ошибка загрузки элементов</div>';
}
}
rightHtml += '<pre>' + textify + '</pre>';
rightHtml += '<div class="kv" style="margin-top:10px;"><span class="k">doc_id</span><span class="v">' + (f.doc_id || '—') + '</span></div>';
if (f.supp_id) {
rightHtml += '<div class="kv"><span class="k">supp_id</span><span class="v">' + f.supp_id + '</span></div>';
rightHtml += '<div class="kv"><span class="k">Тип ДС</span><span class="v">' + (f.supp_type || '—') + '</span></div>';
}
} catch(e) {
leftHtml = '<span style="color:var(--destructive);">Ошибка</span>';
}
} else {
leftHtml = '<span style="color:var(--muted);">(ещё не загружен)</span>';
}
var html = '<div class="text-panes">' +
'<div class="text-pane"><div class="pane-title">Сырой текст</div>' + leftHtml + '</div>' +