| @@ -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')); |
| @@ -104,8 +128,14 @@ | ||
| 104 | 128 | document.getElementById("ask_email_wp_greetings").checked = false; |
| 105 | 129 | document.getElementById("ask_email_wp_greetings").disabled = true; |
| 106 | 130 | } |
| 107 | 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 | + } | |
| 108 | 138 | |
| 109 | 139 | document.getElementById('skip_wp_greetings').addEventListener('change', (event) => { |
| 110 | 140 | if (event.currentTarget.checked) { |
| 111 | 141 | document.getElementById("skip_wp_greetings_donot_show_menu").checked = false; |
| @@ -115,12 +145,19 @@ | ||
| 115 | 145 | if (document.getElementById("ask_email_wp_greetings") != null) { |
| 116 | 146 | document.getElementById("ask_email_wp_greetings").checked = false; |
| 117 | 147 | document.getElementById("ask_email_wp_greetings").disabled = true; |
| 118 | 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 | + } | |
| 119 | 153 | } else { |
| 120 | 154 | if (document.getElementById("ask_email_wp_greetings") != null && !document.getElementById("skip_wp_greetings_donot_show_menu").checked) { |
| 121 | 155 | document.getElementById("ask_email_wp_greetings").disabled = false; |
| 122 | 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 | + } | |
| 123 | 160 | } |
| 124 | 161 | }) |
| 125 | 162 | document.getElementById('skip_wp_greetings_donot_show_menu').addEventListener('change', (event) => { |
| 126 | 163 | if (event.currentTarget.checked) { |
| @@ -131,12 +168,19 @@ | ||
| 131 | 168 | if (document.getElementById("ask_email_wp_greetings") != null) { |
| 132 | 169 | document.getElementById("ask_email_wp_greetings").checked = false; |
| 133 | 170 | document.getElementById("ask_email_wp_greetings").disabled = true; |
| 134 | 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 | + } | |
| 135 | 176 | } else { |
| 136 | 177 | if (document.getElementById("ask_email_wp_greetings") != null && !document.getElementById("skip_wp_greetings").checked) { |
| 137 | 178 | document.getElementById("ask_email_wp_greetings").disabled = false; |
| 138 | 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 | + } | |
| 139 | 183 | } |
| 140 | 184 | }) |
| 141 | 185 | document.getElementById('show_menu_after_greetings').addEventListener('change', (event) => { |
| 142 | 186 | if (event.currentTarget.checked) { |
| @@ -146,8 +190,11 @@ | ||
| 146 | 190 | document.getElementById("skip_wp_greetings_donot_show_menu").checked = false; |
| 147 | 191 | if (document.getElementById("ask_email_wp_greetings") != null && !document.getElementById("skip_wp_greetings").checked && !document.getElementById("skip_wp_greetings_donot_show_menu").checked) { |
| 148 | 192 | document.getElementById("ask_email_wp_greetings").disabled = false; |
| 149 | 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 | + } | |
| 150 | 197 | } |
| 151 | 198 | }) |
| 152 | 199 | |
| 153 | 200 | } |
| @@ -191,9 +238,9 @@ | ||
| 191 | 238 | '<p class="qc-opt-dcs-font qc-opt-dcs-font-faq">FAQ Query </p>'+ |
| 192 | 239 | |
| 193 | 240 | '<input type="text" class="form-control" name="support_query[]" placeholder="FAQ Query">'+ |
| 194 | 241 | |
| 195 | - '<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>'+ | |
| 196 | 243 | |
| 197 | 244 | '<textarea id="'+textarea_id+'" name="support_ans[]" class="form-control chatbot-query-builder" cols="30" rows="2"></textarea>'+ |
| 198 | 245 | |
| 199 | 246 | '</div>'+ |
| @@ -1044,9 +1091,9 @@ | ||
| 1044 | 1091 | drop: function(event, ui) { |
| 1045 | 1092 | var droppable = $(this); |
| 1046 | 1093 | var draggable = ui.draggable; |
| 1047 | 1094 | // Move draggable into droppable |
| 1048 | - 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); | |
| 1049 | 1096 | jQuery('#qc_wpbot_menu_order').val(jQuery('#qc_menu_area').html().trim()); |
| 1050 | 1097 | } |
| 1051 | 1098 | }); |
| 1052 | 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(); |
| @@ -1370,8 +1417,19 @@ | ||
| 1370 | 1417 | var openai_post_type = $("input[name='site_search_posttypes[]']:checked").map(function () { |
| 1371 | 1418 | return this.value; |
| 1372 | 1419 | }).get(); |
| 1373 | 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 | + | |
| 1374 | 1432 | $.ajax({ |
| 1375 | 1433 | url: qcld_gemini_admin_data.ajax_url, |
| 1376 | 1434 | type:'POST', |
| 1377 | 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}), |
| @@ -1476,13 +1534,17 @@ | ||
| 1476 | 1534 | }) //Additional Code - 04-12-2023 ends here |
| 1477 | 1535 | } |
| 1478 | 1536 | var settingsRag = document.getElementById("save_rag_setting"); |
| 1479 | 1537 | if (settingsRag) { |
| 1538 | + $('.qcl-openai').on('change', '.rag_auto_sync_enabled', function () { | |
| 1539 | + $('.rag_auto_sync_enabled').prop('checked', this.checked); | |
| 1540 | + }); | |
| 1541 | + | |
| 1480 | 1542 | $('.qcl-openai').on('click', '#save_rag_setting', function () { |
| 1481 | 1543 | |
| 1482 | 1544 | var rag_embed_pages = $('#rag_embed_pages').is(':checked') ? 1 : 0; |
| 1483 | 1545 | var rag_embed_posts = $('#rag_embed_posts').is(':checked') ? 1 : 0; |
| 1484 | - 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; | |
| 1485 | 1547 | var rag_embed_str = $('#rag_embed_str').is(':checked') ? 1 : 0; |
| 1486 | 1548 | |
| 1487 | 1549 | var rag_embed_cpts = []; |
| 1488 | 1550 | $('.rag_embed_cpts_checkbox:checked').each(function() { |
| @@ -1538,9 +1600,9 @@ | ||
| 1538 | 1600 | btn.text('Saving settings...'); |
| 1539 | 1601 | |
| 1540 | 1602 | var rag_embed_pages = $('#rag_embed_pages').is(':checked') ? 1 : 0; |
| 1541 | 1603 | var rag_embed_posts = $('#rag_embed_posts').is(':checked') ? 1 : 0; |
| 1542 | - 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; | |
| 1543 | 1605 | var rag_embed_str = $('#rag_embed_str').is(':checked') ? 1 : 0; |
| 1544 | 1606 | |
| 1545 | 1607 | var rag_embed_cpts = []; |
| 1546 | 1608 | $('.rag_embed_cpts_checkbox:checked').each(function() { |