Actualizar index.html
This commit is contained in:
39
index.html
39
index.html
@@ -113,17 +113,34 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function summarizeDescription(rawText) {
|
function summarizeDescription(rawText) {
|
||||||
if (!rawText) return "Avería reportada.";
|
if (!rawText) return "Revisión técnica de avería en el domicilio.";
|
||||||
let text = rawText.replace(/\n/g, ' ');
|
|
||||||
const regexCorte = /(\(|\bM\.O\b|\bMATERIAL\b|\bASEGURADO\b|\bTELEFONO\b|\bURGENTE\b)/i;
|
// 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);
|
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.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+/);
|
let words = text.split(/\s+/);
|
||||||
if (words.length > 10) return words.slice(0, 10).join(" ") + "...";
|
if (words.length > 25) {
|
||||||
if (text.length < 5) return "Reparación general solicitada.";
|
text = words.slice(0, 25).join(" ") + "...";
|
||||||
return text.endsWith('.') ? text : text + ".";
|
}
|
||||||
|
|
||||||
|
if (text.length < 5) return "Revisión general en el domicilio.";
|
||||||
|
return text.endsWith('.') || text.endsWith('...') ? text : text + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
function addOneHour(timeStr) {
|
function addOneHour(timeStr) {
|
||||||
@@ -434,8 +451,10 @@
|
|||||||
${contactHtml}
|
${contactHtml}
|
||||||
${clientDataHtml}
|
${clientDataHtml}
|
||||||
<div class="pt-5 mt-5 border-t border-slate-100">
|
<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>
|
<p class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-2 flex items-center gap-1.5">
|
||||||
<h3 class="font-black text-slate-800 text-sm leading-relaxed">${descLimpia}</h3>
|
<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>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user