Actualizar index.html
This commit is contained in:
39
index.html
39
index.html
@@ -113,17 +113,34 @@
|
||||
}
|
||||
|
||||
function summarizeDescription(rawText) {
|
||||
if (!rawText) return "Avería reportada.";
|
||||
let text = rawText.replace(/\n/g, ' ');
|
||||
const regexCorte = /(\(|\bM\.O\b|\bMATERIAL\b|\bASEGURADO\b|\bTELEFONO\b|\bURGENTE\b)/i;
|
||||
if (!rawText) return "Revisión técnica de avería en el domicilio.";
|
||||
|
||||
// 1. Quitar saltos de línea
|
||||
let text = String(rawText).replace(/(\r\n|\n|\r)/gm, " ");
|
||||
|
||||
// 2. Cortar basura interna de las aseguradoras (M.O., MATERIALES, teléfonos, código de propuesta, etc.)
|
||||
const regexCorte = /(\bM\.O\b|\bMATERIAL\b|\bASEGURADO\b|\bTELEFONO\b|\bTEL\b|\bURGENTE\b|\bFRANQUICIA\b|\[PROPUESTA)/i;
|
||||
let cutPos = text.search(regexCorte);
|
||||
if (cutPos > 5) text = text.substring(0, cutPos);
|
||||
if (cutPos > 15) text = text.substring(0, cutPos);
|
||||
|
||||
// 3. Limpiar prefijos inútiles que no aportan nada al cliente
|
||||
text = text.replace(/^(Aver[ií]a|Descripci[oó]n|Motivo|Siniestro|Detalle)[\s:]*/i, '');
|
||||
|
||||
text = text.trim();
|
||||
text = text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
||||
|
||||
// 4. Capitalizar solo la primera letra (sin destrozar el resto de mayúsculas como hacía antes)
|
||||
if (text.length > 0) {
|
||||
text = text.charAt(0).toUpperCase() + text.slice(1);
|
||||
}
|
||||
|
||||
// 5. Límite elástico y elegante (25 palabras máximo, para que se lea un buen trozo sin saturar)
|
||||
let words = text.split(/\s+/);
|
||||
if (words.length > 10) return words.slice(0, 10).join(" ") + "...";
|
||||
if (text.length < 5) return "Reparación general solicitada.";
|
||||
return text.endsWith('.') ? text : text + ".";
|
||||
if (words.length > 25) {
|
||||
text = words.slice(0, 25).join(" ") + "...";
|
||||
}
|
||||
|
||||
if (text.length < 5) return "Revisión general en el domicilio.";
|
||||
return text.endsWith('.') || text.endsWith('...') ? text : text + ".";
|
||||
}
|
||||
|
||||
function addOneHour(timeStr) {
|
||||
@@ -434,8 +451,10 @@
|
||||
${contactHtml}
|
||||
${clientDataHtml}
|
||||
<div class="pt-5 mt-5 border-t border-slate-100">
|
||||
<p class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-1.5">Motivo de la Visita</p>
|
||||
<h3 class="font-black text-slate-800 text-sm leading-relaxed">${descLimpia}</h3>
|
||||
<p class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-2 flex items-center gap-1.5">
|
||||
<i data-lucide="info" class="w-3.5 h-3.5 text-blue-400"></i> Motivo de la Visita
|
||||
</p>
|
||||
<p class="font-bold text-slate-700 text-sm leading-relaxed">${descLimpia}</p>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user