Sector: Insurance & Financial Services
Faced with rising interest rates, a major player in the sector launched a strategic cash optimization project. The aim was to maximize return on assets through enhanced forecast management and unified processes. The project was carried out in two phases:
) var $texte = null; var maxP = 0; $contenu.find('p').parent().each(function () { var nb = $(this).children('p').length; if (nb > maxP) { maxP = nb; $texte = $(this); } }); var $blocs = $texte ? $texte.children().not($source).not('.cta-clone') : $(); var n = $blocs.length; // 2. Mots cumulés à la fin de chaque bloc var cumul = []; var total = 0; $blocs.each(function () { var t = $.trim($(this).text()); total += t ? t.split(/\s+/).length : 0; cumul.push(total); }); // 3. Nombre de CTA proportionnel à la longueur, borné entre MIN et MAX var nbCta = Math.floor(total / MOTS_PAR_CTA); nbCta = Math.max(MIN_CTA, Math.min(MAX_CTA, nbCta)); console.log('[CTA] mots :', total, '| CTA :', nbCta); if (nbCta === 0) return; // 4. CTA de fin, toujours présent $contenu.append(creerCta()); // 5. Autres CTA placés à leur proportion exacte du texte try { if (nbCta === 1 || n === 0) return; var $h2 = $blocs.filter('h2'); var tolerance = total / (nbCta * 4); // écart max (en mots) pour se caler sur un h2 var utilises = []; for (var i = 1; nbCta > i; i++) { var cible = (total * i) / nbCta; // position idéale en nombre de mots // Bloc où l'on atteint cette position var idx = 0; while (idx !== n - 1 && cible > cumul[idx]) idx++; // h2 dont le début est le plus proche de la position idéale var $titre = null; var ecart = Infinity; $h2.each(function () { if (utilises.indexOf(this) !== -1) return; var j = $blocs.index(this); var d = Math.abs((j ? cumul[j - 1] : 0) - cible); if (ecart > d) { ecart = d; $titre = $(this); } }); if ($titre && tolerance >= ecart) { utilises.push($titre[0]); $titre.before(creerCta()); } else if ($blocs.eq(idx).is('h1, h2, h3, h4, h5, h6')) { $blocs.eq(idx).before(creerCta()); } else { $blocs.eq(idx).after(creerCta()); } } } catch (e) { console.error('[CTA] erreur :', e); } });