|
2758 | 2758 | } |
2759 | 2759 |
|
2760 | 2760 | const lastNewTableRow = outTableBody.lastElementChild; // фиксация последней строки |
2761 | | - const defaultRowCellColors = []; // для цветов |
| 2761 | + if (!lastNewTableRow) return; // нет строки.. возврат |
2762 | 2762 |
|
2763 | | - if (lastNewTableRow) { |
2764 | | - // перемещение к "новому" клиенту/к последней строке таблицы |
2765 | | - lastNewTableRow.scrollIntoView({ |
2766 | | - behavior: 'smooth', |
2767 | | - block: 'center', |
2768 | | - }); |
| 2763 | + // кого предстоит перекрасить/выделить |
| 2764 | + const highlightClasses = [ |
| 2765 | + 'crm__output-table-body-cell_fio', |
| 2766 | + 'crm__output-table-body-cell_crt-d-time', |
| 2767 | + 'crm__output-table-body-cell_chg-d-time', |
| 2768 | + ]; |
| 2769 | + |
| 2770 | + const defaultColorsMap = new Map(); // хранение исходных цветов/красок |
| 2771 | + |
| 2772 | + // перемещение к "новому" клиенту/к последней строке таблицы |
| 2773 | + lastNewTableRow.scrollIntoView({ |
| 2774 | + behavior: 'smooth', |
| 2775 | + block: 'center', |
| 2776 | + }); |
2769 | 2777 |
|
2770 | | - // изменение цвета/выделение строки |
2771 | | - lastNewTableRow.querySelectorAll('td').forEach((td) => { |
2772 | | - defaultRowCellColors.push(td.style.color); |
2773 | | - td.style.fontWeight = '500'; |
| 2778 | + // изменение цвета/выделение строки |
| 2779 | + lastNewTableRow.querySelectorAll('td').forEach((td) => { |
| 2780 | + if (highlightClasses.some((cls) => td.classList.contains(cls))) { |
| 2781 | + defaultColorsMap.set(td, td.style.color); // сохранение default цвета |
| 2782 | + td.style.fontWeight = 'bold'; |
2774 | 2783 | td.style.color = '#7458c2'; // --cold-purple |
2775 | | - }); |
| 2784 | + } |
| 2785 | + }); |
2776 | 2786 |
|
2777 | | - // возврат к default цвету, через несколько секунды |
2778 | | - setTimeout(() => { |
2779 | | - lastNewTableRow.querySelectorAll('td').forEach((td, index) => { |
2780 | | - td.style.fontWeight = 'normal'; |
2781 | | - td.style.color = defaultRowCellColors[index]; |
2782 | | - }); |
2783 | | - }, 2000); |
2784 | | - } |
| 2787 | + // возврат к default цвету, через несколько секунды |
| 2788 | + setTimeout(() => { |
| 2789 | + defaultColorsMap.forEach((color, td) => { |
| 2790 | + td.style.fontWeight = 'normal'; |
| 2791 | + td.style.color = color; |
| 2792 | + }); |
| 2793 | + }, 2000); |
2785 | 2794 | } |
2786 | 2795 | })(); |
0 commit comments