| @@ -8,13 +8,11 @@ | ||
| 8 | 8 | const $pagination = $('.mxchat-kb-pagination'); |
| 9 | 9 | const $processButton = $('#mxchat-kb-process-selected'); |
| 10 | 10 | const $selectAll = $('#mxchat-kb-select-all'); |
| 11 | 11 | const $selectionCount = $('.mxchat-kb-selection-count'); |
| 12 | - // ACF→PDF extraction is an install-level setting (Knowledge → ACF Fields); | |
| 13 | - // the server reads the stored option — nothing to collect in this modal. | |
| 14 | - | |
| 12 | + | |
| 15 | 13 | // Filter elements |
| 16 | - const $searchInput = $('#mxchat-kb-content-search'); | |
| 14 | + const $searchInput = $('#mxchat-kb-content-search');1 | |
| 17 | 15 | const $typeFilter = $('#mxchat-kb-content-type-filter'); |
| 18 | 16 | const $statusFilter = $('#mxchat-kb-content-status-filter'); |
| 19 | 17 | const $processedFilter = $('#mxchat-kb-processed-filter'); |
| 20 | 18 | |
| @@ -50,9 +48,9 @@ | ||
| 50 | 48 | $('.mxchat-import-box').removeClass('active'); |
| 51 | 49 | $box.addClass('active'); |
| 52 | 50 | |
| 53 | 51 | // Hide all input areas |
| 54 | - $('#mxchat-url-input-area, #mxchat-content-input-area, #mxchat-pdf-upload-area, #mxchat-document-upload-area, #mxchat-youtube-input-area').hide(); | |
| 52 | + $('#mxchat-url-input-area, #mxchat-content-input-area').hide(); | |
| 55 | 53 | |
| 56 | 54 | // Hide sitemap-specific sections (but NOT for sitemap option - let detection logic handle it) |
| 57 | 55 | if (option !== 'sitemap') { |
| 58 | 56 | $('#mxchat-detected-sitemaps, #mxchat-no-sitemaps, #mxchat-sitemaps-loading').hide(); |
| @@ -59,15 +57,15 @@ | ||
| 59 | 57 | } |
| 60 | 58 | |
| 61 | 59 | // Handle different import options |
| 62 | 60 | switch (option) { |
| 63 | - case 'pdf-url': | |
| 61 | + case 'pdf': | |
| 64 | 62 | case 'sitemap': |
| 65 | 63 | case 'url': |
| 66 | 64 | // Show URL input area with appropriate placeholder |
| 67 | 65 | $('#mxchat-url-input-area').show(); |
| 68 | 66 | $('#sitemap_url').attr('placeholder', $box.data('placeholder')); |
| 69 | - $('#import_type').val(option === 'pdf-url' ? 'pdf' : option); | |
| 67 | + $('#import_type').val(option); | |
| 70 | 68 | |
| 71 | 69 | // UPDATED: Add or update bot_id hidden field for URL forms |
| 72 | 70 | updateBotIdInForm('#mxchat-url-form'); |
| 73 | 71 | |
| @@ -72,9 +70,9 @@ | ||
| 72 | 70 | updateBotIdInForm('#mxchat-url-form'); |
| 73 | 71 | |
| 74 | 72 | // Update the description text based on the import type |
| 75 | 73 | let descriptionText = ''; |
| 76 | - if (option === 'pdf-url') { | |
| 74 | + if (option === 'pdf') { | |
| 77 | 75 | descriptionText = 'Import a PDF document by entering its URL above. PDFs are processed via cron job. If processing does not start, you can manually process batch 5 pages at a time.'; |
| 78 | 76 | } else if (option === 'sitemap') { |
| 79 | 77 | descriptionText = 'Enter a content-specific sub-sitemap URL, not the sitemap index. Sitemaps are processed via cron job. If processing does not start, you can manually process batch 5 pages at a time.'; |
| 80 | 78 | // Re-show sitemap sections if they were previously loaded |
| @@ -99,51 +97,11 @@ | ||
| 99 | 97 | |
| 100 | 98 | // UPDATED: Add or update bot_id hidden field for content forms |
| 101 | 99 | updateBotIdInForm('#mxchat-content-form'); |
| 102 | 100 | break; |
| 103 | - | |
| 104 | - case 'pdf-upload': | |
| 105 | - // Show PDF file upload area | |
| 106 | - $('#mxchat-pdf-upload-area').show(); | |
| 107 | - | |
| 108 | - // Add or update bot_id hidden field for PDF upload form | |
| 109 | - updateBotIdInForm('#mxchat-pdf-upload-form'); | |
| 110 | - break; | |
| 111 | - | |
| 112 | - case 'document-upload': | |
| 113 | - // Show document (.docx/.txt/.md) upload area | |
| 114 | - $('#mxchat-document-upload-area').show(); | |
| 115 | - | |
| 116 | - // Add or update bot_id hidden field for the document upload form | |
| 117 | - updateBotIdInForm('#mxchat-document-upload-form'); | |
| 118 | - break; | |
| 119 | - | |
| 120 | - case 'youtube': | |
| 121 | - // Show YouTube import area | |
| 122 | - $('#mxchat-youtube-input-area').show(); | |
| 123 | - | |
| 124 | - // Add or update bot_id hidden field for YouTube form | |
| 125 | - updateBotIdInForm('#mxchat-youtube-form'); | |
| 126 | - break; | |
| 127 | 101 | } |
| 128 | 102 | }); |
| 129 | 103 | |
| 130 | -// YouTube import: toggle the manual-description box with the mode radios, and | |
| 131 | -// only require the textarea when "Write my own" is selected. | |
| 132 | -$(document).on('change', 'input[name="youtube_description_mode"]', function() { | |
| 133 | - const manual = $('input[name="youtube_description_mode"]:checked').val() === 'manual'; | |
| 134 | - $('#mxchat-youtube-description-field').toggle(manual); | |
| 135 | - $('#mxchat-youtube-description').prop('required', manual); | |
| 136 | -}); | |
| 137 | - | |
| 138 | -// If the server bounced back with prefill state (auto-import found no | |
| 139 | -// transcript), reopen the YouTube form in manual mode ready to augment. | |
| 140 | -if ($('#mxchat-youtube-form').data('yt-prefill')) { | |
| 141 | - $('.mxchat-import-box[data-option="youtube"]').trigger('click'); | |
| 142 | - $('input[name="youtube_description_mode"]').trigger('change'); | |
| 143 | - $('#mxchat-youtube-description').trigger('focus'); | |
| 144 | -} | |
| 145 | - | |
| 146 | 104 | // Helper function to add/update bot_id hidden field in forms |
| 147 | 105 | function updateBotIdInForm(formSelector) { |
| 148 | 106 | const $form = $(formSelector); |
| 149 | 107 | if ($form.length === 0) return; |
| @@ -568,15 +526,10 @@ | ||
| 568 | 526 | title: response.data.title || ('ID: ' + postId) |
| 569 | 527 | }); |
| 570 | 528 | } |
| 571 | 529 | |
| 572 | - let successText = 'Successfully ' + (isUpdate ? 'updated' : 'processed') + ': ' + response.data.title; | |
| 573 | - const pdfCount = parseInt(response.data.pdf_extracted_count, 10) || 0; | |
| 574 | - if (pdfCount > 0) { | |
| 575 | - const suffixTpl = (mxchatSelector.i18n && mxchatSelector.i18n.pdfExtractedSuffix) || ' (%d PDF(s) extracted)'; | |
| 576 | - successText += suffixTpl.replace('%d', pdfCount); | |
| 577 | - } | |
| 578 | - $progressModal.find('.mxchat-kb-current-item').text(successText); | |
| 530 | + $progressModal.find('.mxchat-kb-current-item') | |
| 531 | + .text('Successfully ' + (isUpdate ? 'updated' : 'processed') + ': ' + response.data.title); | |
| 579 | 532 | } else { |
| 580 | 533 | failed++; |
| 581 | 534 | results.failed.push({ |
| 582 | 535 | id: postId, |