PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.4
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.4
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / asset / js / ai-chatbot / admin.js

admin.js in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.5.4, at asset/js/ai-chatbot/admin.js

218 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*
2 * AI chatbot setting js
3 */
4 function wpsc_ai_chatbot_settings(is_humbargar = false) {
5 if (is_humbargar) {
6 wpsc_toggle_humbargar();
7 }
8
9 jQuery(".wpsc-setting-nav, .wpsc-humbargar-menu-item").removeClass("active");
10 jQuery(
11 ".wpsc-setting-nav.ai-chatbot-setting, .wpsc-humbargar-menu-item.ai-chatbot-setting",
12 ).addClass("active");
13 jQuery(".wpsc-humbargar-title").html(
14 supportcandy.humbargar_titles.ai_chatbot_setting,
15 );
16
17 if (supportcandy.current_section !== "ai-chatbot-setting") {
18 supportcandy.current_section = "ai-chatbot-setting";
19 supportcandy.current_tab = "general";
20 }
21
22 window.history.replaceState(
23 {},
24 null,
25 "admin.php?page=wpsc-settings&section=" + supportcandy.current_section,
26 );
27 jQuery(".wpsc-setting-body").html(supportcandy.loader_html);
28
29 wpsc_scroll_top();
30 var data = {
31 action: "wpsc_ai_chatbot_settings",
32 tab: supportcandy.current_tab,
33 };
34
35 jQuery.post(supportcandy.ajax_url, data, function (response) {
36 jQuery(".wpsc-setting-body").html(response);
37 wpsc_reset_responsive_style();
38 jQuery(
39 ".wpsc-setting-tab-container button." + supportcandy.current_tab,
40 ).trigger("click");
41 });
42 }
43
44 /**
45 * Load general setting tab ui
46 */
47 function wpsc_get_acb_general_setting() {
48 supportcandy.current_tab = "general";
49 jQuery(".wpsc-setting-tab-container button").removeClass("active");
50 jQuery(
51 ".wpsc-setting-tab-container button." + supportcandy.current_tab,
52 ).addClass("active");
53
54 window.history.replaceState(
55 {},
56 null,
57 "admin.php?page=wpsc-settings&section=" +
58 supportcandy.current_section +
59 "&tab=" +
60 supportcandy.current_tab,
61 );
62 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
63
64 wpsc_scroll_top();
65
66 const data = { action: "wpsc_get_acb_general_setting" };
67 jQuery.post(supportcandy.ajax_url, data, function (response) {
68 jQuery(".wpsc-setting-section-body").html(response);
69 wpsc_reset_responsive_style();
70 wpsc_acb_toggle_dependent_settings();
71 jQuery("#wpsc-acb-service-status").on(
72 "change",
73 wpsc_acb_toggle_dependent_settings,
74 );
75 jQuery("#wpsc-acb-sessions-popup-delay-status").on(
76 "change",
77 wpsc_acb_toggle_dependent_settings,
78 );
79 });
80 }
81
82 /**
83 * Show/hide the AI chatbot general settings that only make sense while their
84 * governing status select is set to "Enable" - settings tied to AI Chatbot
85 * Status (session retention, footer branding, sessions per page) and
86 * settings tied to Popup Delay Status (Popup Delay, Popup Display Limit).
87 */
88 function wpsc_acb_toggle_dependent_settings() {
89 jQuery(".wpsc-acb-status-dependent").toggle(
90 jQuery("#wpsc-acb-service-status").val() === "1",
91 );
92 jQuery(".wpsc-acb-popup-delay-dependent").toggle(
93 jQuery("#wpsc-acb-sessions-popup-delay-status").val() === "1",
94 );
95 }
96
97 /**
98 * Save setting
99 */
100 function wpsc_set_acb_settings(el) {
101 var form = jQuery(".wpsc-frm-acb-settings")[0];
102 var dataform = new FormData(form);
103
104 jQuery(el).text(supportcandy.translations.please_wait);
105 jQuery
106 .ajax({
107 url: supportcandy.ajax_url,
108 type: "POST",
109 data: dataform,
110 processData: false,
111 contentType: false,
112 })
113 .done(function (res) {
114 wpsc_get_acb_general_setting();
115 });
116 }
117
118 /*
119 * Reset settings
120 */
121 function wpsc_reset_acb_settings(el, nonce) {
122 var data = {
123 action: "wpsc_reset_acb_settings",
124 _ajax_nonce: nonce,
125 };
126
127 jQuery(el).text(supportcandy.translations.please_wait);
128 jQuery
129 .ajax({
130 url: supportcandy.ajax_url,
131 type: "POST",
132 data: data,
133 })
134 .done(function (res) {
135 window.location.reload();
136 });
137 }
138
139 /**
140 * Get chatbot appearance settings
141 */
142 function wpsc_get_acb_appearance_setting() {
143 supportcandy.current_tab = "acb-appearance";
144 jQuery(".wpsc-setting-tab-container button").removeClass("active");
145 jQuery(
146 ".wpsc-setting-tab-container button." + supportcandy.current_tab
147 ).addClass("active");
148
149 window.history.replaceState(
150 {},
151 null,
152 "admin.php?page=wpsc-settings&section=" +
153 supportcandy.current_section +
154 "&tab=" +
155 supportcandy.current_tab
156 );
157 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
158
159 wpsc_scroll_top();
160 var data = { action: "wpsc_get_acb_appearance_setting" };
161 jQuery.post(supportcandy.ajax_url, data, function (response) {
162 jQuery(".wpsc-setting-section-body").html(response);
163 wpsc_reset_responsive_style();
164 });
165 }
166
167 /**
168 * Set chatbot appearance settings
169 */
170 function wpsc_set_acb_appearance_setting(el) {
171 var form = jQuery(".wpsc-frm-acb-appearance-general")[0];
172 var dataform = new FormData(form);
173 jQuery(el).text(supportcandy.translations.please_wait);
174 jQuery
175 .ajax({
176 url: supportcandy.ajax_url,
177 type: "POST",
178 data: dataform,
179 processData: false,
180 contentType: false,
181 })
182 .done(function (res) {
183 wpsc_get_acb_appearance_setting();
184 });
185 }
186
187 /**
188 * Reset chatbot appearance settings
189 */
190 function wpsc_reset_acb_appearance_setting(el, nonce) {
191 jQuery(el).text(supportcandy.translations.please_wait);
192 var data = { action: "wpsc_reset_acb_appearance_setting", _ajax_nonce: nonce };
193 jQuery.post(supportcandy.ajax_url, data, function (res) {
194 wpsc_get_acb_appearance_setting();
195 });
196 }
197
198
199 /**
200 * Get session detailed info
201 *
202 * @param {int} session_id
203 */
204 function wpsc_view_session_detailed_info(session_id, nonce) {
205 var url = new URL(window.location.href);
206 url.searchParams.set("session_id", session_id);
207 window.history.replaceState({}, null, url.toString());
208
209 jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
210 var data = {
211 action: "wpsc_view_session_detailed_info",
212 session_id,
213 _ajax_nonce: nonce,
214 };
215 jQuery.post(supportcandy.ajax_url, data, function (res) {
216 jQuery(".wpsc-setting-section-body").html(res);
217 });
218 }