| @@ -1,7 +1,35 @@ | ||
| 1 | 1 | jQuery(function ($) { |
| 2 | 2 | |
| 3 | 3 | $(document).ready(function () { |
| 4 | + var wpChatbotTabSections = { | |
| 5 | + started: '#section-flip-1', | |
| 6 | + general: '#section-flip-2', | |
| 7 | + themes: '#section-flip-3', | |
| 8 | + social: '#section-flip-51', | |
| 9 | + language: '#section-flip-5', | |
| 10 | + support: '#section-flip-4', | |
| 11 | + startmenu: '#section-flip-6', | |
| 12 | + ai: '#section-flip-7', | |
| 13 | + rpl: '#section-flip-9', | |
| 14 | + custom_css: '#section-flip-13' | |
| 15 | + }; | |
| 16 | + | |
| 17 | + function wpChatbotShowTabSection(tabData, fallbackIndex, sectionSelector) { | |
| 18 | + $(".content-wrap section").removeClass('content-current'); | |
| 19 | + | |
| 20 | + if (sectionSelector) { | |
| 21 | + $(sectionSelector).addClass('content-current'); | |
| 22 | + return; | |
| 23 | + } | |
| 24 | + | |
| 25 | + if (wpChatbotTabSections[tabData]) { | |
| 26 | + $(wpChatbotTabSections[tabData]).addClass('content-current'); | |
| 27 | + return; | |
| 28 | + } | |
| 29 | + | |
| 30 | + $(".content-wrap section").eq(fallbackIndex).addClass('content-current'); | |
| 31 | + } | |
| 4 | 32 | |
| 5 | 33 | var sbdstoredNoticeId = localStorage.getItem('qcld_wpbot_Notice_set'); |
| 6 | 34 | var qcld_chatbot_Notice_time_set = localStorage.getItem('qcld_wpbot_Notice_time_set'); |
| 7 | 35 | var notice_current_time = Math.round(new Date().getTime() / 1000); |
| @@ -26,10 +54,8 @@ | ||
| 26 | 54 | }); |
| 27 | 55 | |
| 28 | 56 | if(localStorage.getItem('tabData')){ |
| 29 | 57 | |
| 30 | - $(".content-wrap section").removeClass('content-current'); | |
| 31 | - | |
| 32 | 58 | $(".wp-chatbot-tabs nav ul li").each(function (index, elm) { |
| 33 | 59 | |
| 34 | 60 | if(localStorage.getItem('tabData')==$(this).attr('tab-data')){ |
| 35 | 61 | |
| @@ -34,9 +60,9 @@ | ||
| 34 | 60 | if(localStorage.getItem('tabData')==$(this).attr('tab-data')){ |
| 35 | 61 | |
| 36 | 62 | $(this).addClass('tab-current'); |
| 37 | 63 | |
| 38 | - $(".content-wrap section").eq(index).addClass('content-current'); | |
| 64 | + wpChatbotShowTabSection($(this).attr('tab-data'), index, $(this).attr('data-section')); | |
| 39 | 65 | |
| 40 | 66 | }else{ |
| 41 | 67 | |
| 42 | 68 | $(this).removeClass('tab-current'); |
| @@ -58,15 +84,13 @@ | ||
| 58 | 84 | // Remove others tab and contents |
| 59 | 85 | |
| 60 | 86 | $(".wp-chatbot-tabs nav ul li").removeClass('tab-current'); |
| 61 | 87 | |
| 62 | - $(".content-wrap section").removeClass('content-current'); | |
| 63 | - | |
| 64 | 88 | // add current tab and contents |
| 65 | 89 | |
| 66 | 90 | $(this).parent().addClass('tab-current'); |
| 67 | 91 | |
| 68 | - $(".content-wrap section").eq($(".wp-chatbot-tabs nav ul li a ").index(this)).addClass('content-current'); | |
| 92 | + wpChatbotShowTabSection($(this).parent().attr('tab-data'), $(".wp-chatbot-tabs nav ul li a ").index(this), $(this).parent().attr('data-section')); | |
| 69 | 93 | |
| 70 | 94 | //Change action url , set add localStorge and url change. |
| 71 | 95 | |
| 72 | 96 | $('#wp-chatbot-admin-form').attr('action',$(this).attr('href')); |
| @@ -98,23 +122,66 @@ | ||
| 98 | 122 | |
| 99 | 123 | $('#wp_chatbot_floatingiconbg_color').wpColorPicker(); |
| 100 | 124 | if( (document.getElementById('skip_wp_greetings') != null)){ |
| 101 | 125 | |
| 126 | + if (document.getElementById('ask_email_wp_greetings') != null) { | |
| 127 | + if (document.getElementById('skip_wp_greetings').checked || document.getElementById('skip_wp_greetings_donot_show_menu').checked) { | |
| 128 | + document.getElementById("ask_email_wp_greetings").checked = false; | |
| 129 | + document.getElementById("ask_email_wp_greetings").disabled = true; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + if (document.getElementById('enable_asking_for_email') != null) { | |
| 133 | + if (document.getElementById('skip_wp_greetings').checked || document.getElementById('skip_wp_greetings_donot_show_menu').checked) { | |
| 134 | + document.getElementById("enable_asking_for_email").checked = false; | |
| 135 | + document.getElementById("enable_asking_for_email").disabled = true; | |
| 136 | + } | |
| 137 | + } | |
| 138 | + | |
| 102 | 139 | document.getElementById('skip_wp_greetings').addEventListener('change', (event) => { |
| 103 | - if (event.currentTarget.checked) { | |
| 104 | - document.getElementById("skip_wp_greetings_donot_show_menu").checked = false; | |
| 105 | - document.getElementById("show_menu_after_greetings").checked = false; | |
| 106 | - var intetns = document.getElementsByClassName("qc_wp_intent_select"); | |
| 107 | - Array.prototype.map.call(intetns, (x) => x.style = "display:none" ) | |
| 108 | - } | |
| 140 | + if (event.currentTarget.checked) { | |
| 141 | + document.getElementById("skip_wp_greetings_donot_show_menu").checked = false; | |
| 142 | + document.getElementById("show_menu_after_greetings").checked = false; | |
| 143 | + var intetns = document.getElementsByClassName("qc_wp_intent_select"); | |
| 144 | + Array.prototype.map.call(intetns, (x) => x.style = "display:none" ) | |
| 145 | + if (document.getElementById("ask_email_wp_greetings") != null) { | |
| 146 | + document.getElementById("ask_email_wp_greetings").checked = false; | |
| 147 | + document.getElementById("ask_email_wp_greetings").disabled = true; | |
| 148 | + } | |
| 149 | + if (document.getElementById("enable_asking_for_email") != null) { | |
| 150 | + document.getElementById("enable_asking_for_email").checked = false; | |
| 151 | + document.getElementById("enable_asking_for_email").disabled = true; | |
| 152 | + } | |
| 153 | + } else { | |
| 154 | + if (document.getElementById("ask_email_wp_greetings") != null && !document.getElementById("skip_wp_greetings_donot_show_menu").checked) { | |
| 155 | + document.getElementById("ask_email_wp_greetings").disabled = false; | |
| 156 | + } | |
| 157 | + if (document.getElementById("enable_asking_for_email") != null && !document.getElementById("skip_wp_greetings_donot_show_menu").checked) { | |
| 158 | + document.getElementById("enable_asking_for_email").disabled = false; | |
| 159 | + } | |
| 160 | + } | |
| 109 | 161 | }) |
| 110 | 162 | document.getElementById('skip_wp_greetings_donot_show_menu').addEventListener('change', (event) => { |
| 111 | - if (event.currentTarget.checked) { | |
| 112 | - document.getElementById("skip_wp_greetings").checked = false; | |
| 113 | - document.getElementById("show_menu_after_greetings").checked = false; | |
| 114 | - var intetns = document.getElementsByClassName("qc_wp_intent_select"); | |
| 115 | - Array.prototype.map.call(intetns, (x) => x.style = "display:none" ) | |
| 116 | - } | |
| 163 | + if (event.currentTarget.checked) { | |
| 164 | + document.getElementById("skip_wp_greetings").checked = false; | |
| 165 | + document.getElementById("show_menu_after_greetings").checked = false; | |
| 166 | + var intetns = document.getElementsByClassName("qc_wp_intent_select"); | |
| 167 | + Array.prototype.map.call(intetns, (x) => x.style = "display:none" ) | |
| 168 | + if (document.getElementById("ask_email_wp_greetings") != null) { | |
| 169 | + document.getElementById("ask_email_wp_greetings").checked = false; | |
| 170 | + document.getElementById("ask_email_wp_greetings").disabled = true; | |
| 171 | + } | |
| 172 | + if (document.getElementById("enable_asking_for_email") != null) { | |
| 173 | + document.getElementById("enable_asking_for_email").checked = false; | |
| 174 | + document.getElementById("enable_asking_for_email").disabled = true; | |
| 175 | + } | |
| 176 | + } else { | |
| 177 | + if (document.getElementById("ask_email_wp_greetings") != null && !document.getElementById("skip_wp_greetings").checked) { | |
| 178 | + document.getElementById("ask_email_wp_greetings").disabled = false; | |
| 179 | + } | |
| 180 | + if (document.getElementById("enable_asking_for_email") != null && !document.getElementById("skip_wp_greetings").checked) { | |
| 181 | + document.getElementById("enable_asking_for_email").disabled = false; | |
| 182 | + } | |
| 183 | + } | |
| 117 | 184 | }) |
| 118 | 185 | document.getElementById('show_menu_after_greetings').addEventListener('change', (event) => { |
| 119 | 186 | if (event.currentTarget.checked) { |
| 120 | 187 | document.getElementById("skip_wp_greetings").checked = false; |
| @@ -120,11 +187,17 @@ | ||
| 120 | 187 | document.getElementById("skip_wp_greetings").checked = false; |
| 121 | 188 | var intetns = document.getElementsByClassName("qc_wp_intent_select"); |
| 122 | 189 | Array.prototype.map.call(intetns, (x) => x.style = "display:none" ) |
| 123 | 190 | document.getElementById("skip_wp_greetings_donot_show_menu").checked = false; |
| 191 | + if (document.getElementById("ask_email_wp_greetings") != null && !document.getElementById("skip_wp_greetings").checked && !document.getElementById("skip_wp_greetings_donot_show_menu").checked) { | |
| 192 | + document.getElementById("ask_email_wp_greetings").disabled = false; | |
| 193 | + } | |
| 194 | + if (document.getElementById("enable_asking_for_email") != null && !document.getElementById("skip_wp_greetings").checked && !document.getElementById("skip_wp_greetings_donot_show_menu").checked) { | |
| 195 | + document.getElementById("enable_asking_for_email").disabled = false; | |
| 196 | + } | |
| 124 | 197 | } |
| 125 | 198 | }) |
| 126 | - | |
| 199 | + | |
| 127 | 200 | } |
| 128 | 201 | $('#disable_wp_chatbot_site_search').on('change', function() { |
| 129 | 202 | |
| 130 | 203 | if($(this).is(':checked')) { |
| @@ -132,11 +205,11 @@ | ||
| 132 | 205 | } |
| 133 | 206 | }); |
| 134 | 207 | jQuery("#qcld-show-more-wrapper-box").on('click','.qcld-show-more-show-more', function () { |
| 135 | 208 | if(jQuery(".qcld-show-more-text").hasClass("qcld-show-more-show-more-height")) { |
| 136 | - jQuery(this).html('<i class="dashicons dashicons-remove" aria-hidden="true"></i>'); | |
| 209 | + jQuery(this).html('<div class="Collapsemore">Collapse Options</div>'); | |
| 137 | 210 | } else { |
| 138 | - jQuery(this).html('<i class="dashicons dashicons-plus-alt" aria-hidden="true"></i>'); | |
| 211 | + jQuery(this).html('<div class="Expandmore">Expand for More Options<span>+</span></div>'); | |
| 139 | 212 | } |
| 140 | 213 | |
| 141 | 214 | jQuery(".qcld-show-more-text").toggleClass("qcld-show-more-show-more-height"); |
| 142 | 215 | }); |
| @@ -165,9 +238,9 @@ | ||
| 165 | 238 | '<p class="qc-opt-dcs-font qc-opt-dcs-font-faq">FAQ Query </p>'+ |
| 166 | 239 | |
| 167 | 240 | '<input type="text" class="form-control" name="support_query[]" placeholder="FAQ Query">'+ |
| 168 | 241 | |
| 169 | - '<p class="qc-opt-dcs-font"><br><strong>Support answer</strong></p>'+ | |
| 242 | + '<p class="qc-opt-dcs-font"><br><strong>FAQ answer</strong></p>'+ | |
| 170 | 243 | |
| 171 | 244 | '<textarea id="'+textarea_id+'" name="support_ans[]" class="form-control chatbot-query-builder" cols="30" rows="2"></textarea>'+ |
| 172 | 245 | |
| 173 | 246 | '</div>'+ |
| @@ -1018,9 +1091,9 @@ | ||
| 1018 | 1091 | drop: function(event, ui) { |
| 1019 | 1092 | var droppable = $(this); |
| 1020 | 1093 | var draggable = ui.draggable; |
| 1021 | 1094 | // Move draggable into droppable |
| 1022 | - draggable.clone().removeClass("qc_draggable_item").addClass("qc_draggable_item_remove").appendTo(droppable); | |
| 1095 | + draggable.clone().removeClass("qc_draggable_item").addClass("qc_draggable_item_remove").removeAttr("style").appendTo(droppable); | |
| 1023 | 1096 | jQuery('#qc_wpbot_menu_order').val(jQuery('#qc_menu_area').html().trim()); |
| 1024 | 1097 | } |
| 1025 | 1098 | }); |
| 1026 | 1099 | $('#wp_chatbot_floatingiconbg_color, #wp_chatbot_text_color, #wp_chatbot_link_color,#wp_chatbot_link_hover_color,#wp_chatbot_bot_msg_bg_color,#wp_chatbot_bot_msg_text_color,#wp_chatbot_user_msg_bg_color,#wp_chatbot_header_background_color,#wp_chatbot_user_msg_text_color,#wp_chatbot_buttons_bg_color,#wp_chatbot_buttons_text_color,#wp_chatbot_theme_primary_color,#wp_chatbot_theme_secondary_color').wpColorPicker(); |
| @@ -1344,8 +1417,19 @@ | ||
| 1344 | 1417 | var openai_post_type = $("input[name='site_search_posttypes[]']:checked").map(function () { |
| 1345 | 1418 | return this.value; |
| 1346 | 1419 | }).get(); |
| 1347 | 1420 | |
| 1421 | + Swal.fire({ | |
| 1422 | + html: '<div class="qcld-save-settings-spinner"></div>', | |
| 1423 | + allowOutsideClick: false, | |
| 1424 | + allowEscapeKey: false, | |
| 1425 | + showConfirmButton: false, | |
| 1426 | + background: 'transparent', | |
| 1427 | + customClass: { | |
| 1428 | + popup: 'qcld-swal-loading-only' | |
| 1429 | + } | |
| 1430 | + }); | |
| 1431 | + | |
| 1348 | 1432 | $.ajax({ |
| 1349 | 1433 | url: qcld_gemini_admin_data.ajax_url, |
| 1350 | 1434 | type:'POST', |
| 1351 | 1435 | data: ({action : 'openai_settings_option',nonce: qcld_gemini_admin_data.ajax_nonce,api_key: api_key,openai_engines:openai_engines,qcld_openai_prompt: qcld_openai_prompt,max_tokens:max_tokens,file_id:file_id,temperature:temperature,presence_penalty:presence_penalty,frequency_penalty:frequency_penalty,qcld_openai_prompt_custom: qcld_openai_prompt_custom,openai_exclude_keyword:openai_exclude_keyword,is_relevant_enabled:is_relevant_enabled,openai_include_keyword:openai_include_keyword,ai_enabled:is_ai_enabled,is_page_suggestion_enabled:is_page_suggestion_enabled,is_context_awareness_enabled:is_context_awareness_enabled,qcld_openai_system_content:qcld_openai_system_content,qcld_openai_append_content:qcld_openai_append_content,ai_only_mode: is_ai_only_mode,conversation_continuity:conversation_continuity,openai_post_type:openai_post_type,is_page_rag_enabled:is_page_rag_enabled,is_stream_enabled:is_stream_enabled}), |
| @@ -1450,13 +1534,17 @@ | ||
| 1450 | 1534 | }) //Additional Code - 04-12-2023 ends here |
| 1451 | 1535 | } |
| 1452 | 1536 | var settingsRag = document.getElementById("save_rag_setting"); |
| 1453 | 1537 | if (settingsRag) { |
| 1538 | + $('.qcl-openai').on('change', '.rag_auto_sync_enabled', function () { | |
| 1539 | + $('.rag_auto_sync_enabled').prop('checked', this.checked); | |
| 1540 | + }); | |
| 1541 | + | |
| 1454 | 1542 | $('.qcl-openai').on('click', '#save_rag_setting', function () { |
| 1455 | 1543 | |
| 1456 | 1544 | var rag_embed_pages = $('#rag_embed_pages').is(':checked') ? 1 : 0; |
| 1457 | 1545 | var rag_embed_posts = $('#rag_embed_posts').is(':checked') ? 1 : 0; |
| 1458 | - var rag_auto_sync_enabled = $('#rag_auto_sync_enabled').is(':checked') ? 1 : 0; | |
| 1546 | + var rag_auto_sync_enabled = $('.rag_auto_sync_enabled').first().is(':checked') ? 1 : 0; | |
| 1459 | 1547 | var rag_embed_str = $('#rag_embed_str').is(':checked') ? 1 : 0; |
| 1460 | 1548 | |
| 1461 | 1549 | var rag_embed_cpts = []; |
| 1462 | 1550 | $('.rag_embed_cpts_checkbox:checked').each(function() { |
| @@ -1512,9 +1600,9 @@ | ||
| 1512 | 1600 | btn.text('Saving settings...'); |
| 1513 | 1601 | |
| 1514 | 1602 | var rag_embed_pages = $('#rag_embed_pages').is(':checked') ? 1 : 0; |
| 1515 | 1603 | var rag_embed_posts = $('#rag_embed_posts').is(':checked') ? 1 : 0; |
| 1516 | - var rag_auto_sync_enabled = $('#rag_auto_sync_enabled').is(':checked') ? 1 : 0; | |
| 1604 | + var rag_auto_sync_enabled = $('.rag_auto_sync_enabled').first().is(':checked') ? 1 : 0; | |
| 1517 | 1605 | var rag_embed_str = $('#rag_embed_str').is(':checked') ? 1 : 0; |
| 1518 | 1606 | |
| 1519 | 1607 | var rag_embed_cpts = []; |
| 1520 | 1608 | $('.rag_embed_cpts_checkbox:checked').each(function() { |
| @@ -1812,17 +1900,27 @@ | ||
| 1812 | 1900 | // location.reload(); |
| 1813 | 1901 | } |
| 1814 | 1902 | }); |
| 1815 | 1903 | }) |
| 1816 | - $('#ai-provider-selector').on('change', function () { | |
| 1817 | - | |
| 1818 | - var selected = $(this).val(); | |
| 1904 | + $(document).on('click', '.ai-provider-card', function () { | |
| 1905 | + var selected = $(this).data('provider'); | |
| 1819 | 1906 | console.log('Provider changed to: ' + selected); |
| 1907 | + $('.ai-provider-card').removeClass('active'); | |
| 1908 | + $(this).addClass('active'); | |
| 1909 | + $('#ai-provider-selector').val(selected); | |
| 1820 | 1910 | $('.ai-settings-provider').hide(); |
| 1821 | 1911 | $('#' + selected + '-settings').show(); |
| 1822 | 1912 | $('#rag-settings').hide(); // Ensure RAG is hidden when switching providers |
| 1823 | 1913 | }); |
| 1824 | 1914 | |
| 1915 | + // Avatar Location card click handler | |
| 1916 | + $(document).on('click', '.avatar-location-card', function () { | |
| 1917 | + var location = $(this).data('location'); | |
| 1918 | + $('.avatar-location-card').removeClass('active'); | |
| 1919 | + $(this).addClass('active'); | |
| 1920 | + $('#qcld-avatar-location').val(location); | |
| 1921 | + }); | |
| 1922 | + | |
| 1825 | 1923 | if (window.location.hash.indexOf('#ai-knowledge-base-tab') === 0) { |
| 1826 | 1924 | $('.ai-settings-provider').hide(); |
| 1827 | 1925 | $('#rag-settings').show(); |
| 1828 | 1926 | } |
| @@ -2038,10 +2136,13 @@ | ||
| 2038 | 2136 | |
| 2039 | 2137 | |
| 2040 | 2138 | }); |
| 2041 | 2139 | |
| 2042 | - $('#ai-provider-selector').on('change', function() { | |
| 2043 | - var selected = $(this).val(); | |
| 2140 | + $(document).on('click', '.ai-provider-card', function() { | |
| 2141 | + var selected = $(this).data('provider'); | |
| 2142 | + $('.ai-provider-card').removeClass('active'); | |
| 2143 | + $(this).addClass('active'); | |
| 2144 | + $('#ai-provider-selector').val(selected); | |
| 2044 | 2145 | $('.ai-settings-provider').hide(); |
| 2045 | 2146 | $('#' + selected + '-settings').show(); |
| 2046 | 2147 | }); |
| 2047 | 2148 | |