diff --git a/src/viewer/templates/detail.html b/src/viewer/templates/detail.html
index b86eb9a..2b12a17 100644
--- a/src/viewer/templates/detail.html
+++ b/src/viewer/templates/detail.html
@@ -289,7 +289,7 @@
Diagnostic principal
{{ dp.texte }}
- {% if dp.source_page %}{% endif %}
+ {% if dp.source_page %}{% endif %}
{% if dp.cim10_suggestion %}
{{ dp.cim10_suggestion }}
@@ -358,7 +358,7 @@
{{ das.source }}
{% endif %}
{% if das.source_page %}
-
+
{% endif %}
@@ -430,7 +430,7 @@
{{ alerte }}
{% endfor %}
|
- {% if a.source_page %}{% endif %} |
+ {% if a.source_page %}{% endif %} |
{% endfor %}
@@ -450,7 +450,7 @@
{{ b.test }} |
{{ b.valeur or '' }} |
{% if b.anomalie %}Oui{% else %}—{% endif %} |
- {% if b.source_page %}{% endif %} |
+ {% if b.source_page %}{% endif %} |
{% endfor %}
@@ -466,7 +466,7 @@
{{ img.type }}
{% if img.score %} — Score : {{ img.score }}{% endif %}
- {% if img.source_page %}
{% endif %}
+ {% if img.source_page %}
{% endif %}
{% if img.conclusion %}
{{ img.conclusion }}
{% endif %}
@@ -487,7 +487,7 @@
{{ t.medicament }} |
{{ t.posologie or '' }} |
{% if t.code_atc %}{{ t.code_atc }}{% endif %} |
-
{% if t.source_page %}{% endif %} |
+
{% if t.source_page %}{% endif %} |
{% endfor %}
@@ -501,7 +501,7 @@
Antécédents ({{ dossier.antecedents|length }})
{% for a in dossier.antecedents %}
- - {{ a.texte }}{% if a.source_page %} {% endif %}
+ - {{ a.texte }}{% if a.source_page %} {% endif %}
{% endfor %}
@@ -513,7 +513,7 @@
Complications ({{ dossier.complications|length }})
{% for c in dossier.complications %}
- - {{ c.texte }}{% if c.source_page %} {% endif %}
+ - {{ c.texte }}{% if c.source_page %} {% endif %}
{% endfor %}
@@ -540,7 +540,7 @@ let _sourceCache = null;
function getDossierId() {
// filepath = "103_23056749/103_23056749_fusionne_cim10.json"
// dossier_id = "103_23056749"
- const fp = '{{ filepath }}';
+ const fp = {{ filepath|tojson }};
const parts = fp.split('/');
return parts.length > 1 ? parts.slice(0, -1).join('/') : '';
}
@@ -574,13 +574,25 @@ async function showSource(excerpt, page) {
return;
}
+ // Nettoyer l'extrait : retirer les "..." ajoutés par extract_excerpt()
+ let searchText = (excerpt || '').trim();
+ if (searchText.startsWith('...')) searchText = searchText.substring(3);
+ if (searchText.endsWith('...')) searchText = searchText.slice(0, -3);
+ searchText = searchText.trim();
+
// Chercher l'extrait dans le texte et le surligner
- if (excerpt && excerpt.length > 10) {
- const idx = allText.indexOf(excerpt);
+ if (searchText.length > 10) {
+ let idx = allText.indexOf(searchText);
+ // Fallback : chercher un morceau central (résiste mieux à l'anonymisation)
+ if (idx < 0 && searchText.length > 60) {
+ const mid = Math.floor(searchText.length / 2);
+ searchText = searchText.substring(mid - 30, mid + 30);
+ idx = allText.indexOf(searchText);
+ }
if (idx >= 0) {
const before = allText.substring(0, idx);
- const match = allText.substring(idx, idx + excerpt.length);
- const after = allText.substring(idx + excerpt.length);
+ const match = allText.substring(idx, idx + searchText.length);
+ const after = allText.substring(idx + searchText.length);
content.innerHTML = '';
content.appendChild(document.createTextNode(before));
const mark = document.createElement('mark');
@@ -615,6 +627,14 @@ document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') closeSource();
});
+// Délégation événements pour tous les boutons .src-btn
+document.addEventListener('click', function(e) {
+ const btn = e.target.closest('.src-btn');
+ if (btn && btn.dataset.page) {
+ showSource(btn.dataset.excerpt || '', parseInt(btn.dataset.page));
+ }
+});
+
/* --- Reprocess --- */
document.getElementById('reprocess-btn').addEventListener('click', async () => {
const btn = document.getElementById('reprocess-btn');