| @@ -1086,12 +1086,11 @@ | ||
| 1086 | 1086 | $(this).remove(); |
| 1087 | 1087 | // Update entry count displays (header and sidebar) |
| 1088 | 1088 | var $countSpan = $('#mxchat-entry-count'); |
| 1089 | 1089 | if ($countSpan.length) { |
| 1090 | - var currentText = $countSpan.text(); | |
| 1091 | - var match = currentText.match(/\((\d+)\)/); | |
| 1092 | - if (match) { | |
| 1093 | - var newCount = Math.max(0, parseInt(match[1]) - 1); | |
| 1090 | + var currentCount = readEntryCount($countSpan); | |
| 1091 | + if (!isNaN(currentCount)) { | |
| 1092 | + var newCount = Math.max(0, currentCount - 1); | |
| 1094 | 1093 | updateEntryCount(newCount); |
| 1095 | 1094 | } |
| 1096 | 1095 | } |
| 1097 | 1096 | }); |
| @@ -1150,12 +1149,11 @@ | ||
| 1150 | 1149 | $(this).remove(); |
| 1151 | 1150 | // Update entry count displays (header and sidebar) |
| 1152 | 1151 | var $countSpan = $('#mxchat-entry-count'); |
| 1153 | 1152 | if ($countSpan.length) { |
| 1154 | - var currentText = $countSpan.text(); | |
| 1155 | - var match = currentText.match(/\((\d+)\)/); | |
| 1156 | - if (match) { | |
| 1157 | - var newCount = Math.max(0, parseInt(match[1]) - 1); | |
| 1153 | + var currentCount = readEntryCount($countSpan); | |
| 1154 | + if (!isNaN(currentCount)) { | |
| 1155 | + var newCount = Math.max(0, currentCount - 1); | |
| 1158 | 1156 | updateEntryCount(newCount); |
| 1159 | 1157 | } |
| 1160 | 1158 | } |
| 1161 | 1159 | }); |
| @@ -1351,12 +1349,11 @@ | ||
| 1351 | 1349 | // Update entry count displays (header and sidebar) |
| 1352 | 1350 | if (successCount > 0) { |
| 1353 | 1351 | var $countSpan = $('#mxchat-entry-count'); |
| 1354 | 1352 | if ($countSpan.length) { |
| 1355 | - var currentText = $countSpan.text(); | |
| 1356 | - var match = currentText.match(/\((\d+)\)/); | |
| 1357 | - if (match) { | |
| 1358 | - var newCount = Math.max(0, parseInt(match[1]) - successCount); | |
| 1353 | + var currentCount = readEntryCount($countSpan); | |
| 1354 | + if (!isNaN(currentCount)) { | |
| 1355 | + var newCount = Math.max(0, currentCount - successCount); | |
| 1359 | 1356 | updateEntryCount(newCount); |
| 1360 | 1357 | } |
| 1361 | 1358 | } |
| 1362 | 1359 | } |
| @@ -1529,9 +1526,9 @@ | ||
| 1529 | 1526 | } |
| 1530 | 1527 | |
| 1531 | 1528 | // Update the count display |
| 1532 | 1529 | if (response.data.total_count !== undefined) { |
| 1533 | - updateEntryCount(response.data.total_count); | |
| 1530 | + updateEntryCount(response.data.total_count, response.data.count_unit); | |
| 1534 | 1531 | } |
| 1535 | 1532 | |
| 1536 | 1533 | // Show success feedback |
| 1537 | 1534 | showNotification('success', 'Entries refreshed successfully!'); |
| @@ -1744,9 +1741,9 @@ | ||
| 1744 | 1741 | success: function(response) { |
| 1745 | 1742 | if (response.success && response.data) { |
| 1746 | 1743 | // Update count |
| 1747 | 1744 | if (response.data.total_count !== undefined) { |
| 1748 | - updateEntryCount(response.data.total_count); | |
| 1745 | + updateEntryCount(response.data.total_count, response.data.count_unit); | |
| 1749 | 1746 | } |
| 1750 | 1747 | |
| 1751 | 1748 | // Handle Pinecone data source differently |
| 1752 | 1749 | if (response.data.data_source === 'pinecone') { |
| @@ -1819,14 +1816,32 @@ | ||
| 1819 | 1816 | } |
| 1820 | 1817 | }); |
| 1821 | 1818 | } |
| 1822 | 1819 | |
| 1823 | - // Update the entry count display | |
| 1824 | - function updateEntryCount(count) { | |
| 1820 | + // Read the heading's count from its data attribute, not from the text: the | |
| 1821 | + // text now carries a thousands separator and a unit ("(1,240 vectors)") on | |
| 1822 | + // the Pinecone cursor path (plan dd6e10). | |
| 1823 | + function readEntryCount($countSpan) { | |
| 1824 | + var stored = parseInt($countSpan.attr('data-count'), 10); | |
| 1825 | + if (!isNaN(stored)) { | |
| 1826 | + return stored; | |
| 1827 | + } | |
| 1828 | + var match = $countSpan.text().match(/\(([\d,]+)/); | |
| 1829 | + return match ? parseInt(match[1].replace(/,/g, ''), 10) : NaN; | |
| 1830 | + } | |
| 1831 | + | |
| 1832 | + // Update the entry count display. `unit` is 'vectors' on the Pinecone | |
| 1833 | + // cursor path and '' otherwise; omitted = keep whatever the span carries. | |
| 1834 | + function updateEntryCount(count, unit) { | |
| 1825 | 1835 | // Update main table count |
| 1826 | 1836 | const $countSpan = $('#mxchat-entry-count'); |
| 1827 | 1837 | if ($countSpan.length) { |
| 1828 | - $countSpan.text('(' + count + ')'); | |
| 1838 | + if (unit === undefined) { | |
| 1839 | + unit = $countSpan.attr('data-unit') || ''; | |
| 1840 | + } | |
| 1841 | + var shown = Number(count).toLocaleString(); | |
| 1842 | + $countSpan.attr('data-count', count).attr('data-unit', unit); | |
| 1843 | + $countSpan.text('(' + shown + (unit === 'vectors' ? ' vectors' : '') + ')'); | |
| 1829 | 1844 | |
| 1830 | 1845 | // Flash animation to indicate update |
| 1831 | 1846 | $countSpan.addClass('mxchat-count-updated'); |
| 1832 | 1847 | setTimeout(function() { |
| @@ -1893,9 +1908,9 @@ | ||
| 1893 | 1908 | } |
| 1894 | 1909 | |
| 1895 | 1910 | // Update count display |
| 1896 | 1911 | if (response.data.total_count !== undefined) { |
| 1897 | - updateEntryCount(response.data.total_count); | |
| 1912 | + updateEntryCount(response.data.total_count, response.data.count_unit); | |
| 1898 | 1913 | } |
| 1899 | 1914 | } |
| 1900 | 1915 | }, |
| 1901 | 1916 | error: function(xhr, status, error) { |
| @@ -1929,9 +1944,9 @@ | ||
| 1929 | 1944 | const sourceHtml = entry.has_link |
| 1930 | 1945 | ? '<a href="' + entry.source_url + '" target="_blank" style="color: var(--mxch-primary); text-decoration: none;"><span class="dashicons dashicons-external" style="font-size: 14px;"></span> View</a>' |
| 1931 | 1946 | : '<span style="color: var(--mxch-text-muted);">Manual</span>'; |
| 1932 | 1947 | |
| 1933 | - const deleteUrl = mxchatAdmin.admin_url + 'admin-post.php?action=mxchat_delete_prompt&id=' + entry.id + '&_wpnonce=' + entry.delete_nonce; | |
| 1948 | + const deleteUrl = mxchatAdmin.admin_url + 'admin-post.php?action=mxchat_delete_prompt&id=' + entry.id + '&bot_id=' + encodeURIComponent(mxchatAdmin.bot_id || 'default') + '&_wpnonce=' + entry.delete_nonce; | |
| 1934 | 1949 | |
| 1935 | 1950 | // Check if content needs expand button (content longer than preview) |
| 1936 | 1951 | const needsExpand = entry.content_length > entry.preview_length; |
| 1937 | 1952 | |
| @@ -2383,5 +2398,17 @@ | ||
| 2383 | 2398 | $chip.find('.mxchat-meta-chip-tick').text('✓ Added'); |
| 2384 | 2399 | } |
| 2385 | 2400 | }); |
| 2386 | 2401 | })(); |
| 2402 | + | |
| 2403 | + // ======================================== | |
| 2404 | + // VIDEO CARDS — threshold follows the master switch (plan f52492) | |
| 2405 | + // ======================================== | |
| 2406 | + // Presentation only. The server gate does NOT consult the threshold when | |
| 2407 | + // the switch is off, so hiding the field never changes behavior — it just | |
| 2408 | + // stops the page offering a number that is currently inert. Mirrors the | |
| 2409 | + // YouTube import form's own show/hide idiom on this same page. Autosave is | |
| 2410 | + // untouched: both fields keep their own change handler in mxchat-admin.js. | |
| 2411 | + $('#mxchat_video_embed_enabled').on('change', function() { | |
| 2412 | + $('#mxchat-video-embed-threshold-field').toggle($(this).is(':checked')); | |
| 2413 | + }); | |
| 2387 | 2414 | }); |