PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.8.0
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.8.0
8.8.0 8.7.9 8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 All 536 releases
← All changes | includes/chat-sessions/js/admin.js +423 -417 8.6.8 → 8.8.0 View file →
@@ -1,417 +1,423 @@
1 -jQuery(document).ready(function(){
2 - 'use strict'
3 - //start new-update-for-codecanyon
4 - jQuery('#qcld_chatsessions_enter_license_or_purchase_key').on('focusout', function(){
5 - qc_chatsessions_set_plugin_license_fields();
6 - });
7 -
8 - jQuery('#qcld_chatsessions_enter_license_or_purchase_key').on('keypress',function (e) {
9 - qc_chatsessions_set_plugin_license_fields();
10 - });
11 -
12 - jQuery('#qc-license-form input[type="submit"]').on('click', function(){
13 - qc_chatsessions_set_plugin_license_fields();
14 - jQuery('#qc-license-form').removeAttr('onsubmit').submit();
15 - });
16 -
17 - function qc_chatsessions_set_plugin_license_fields(){
18 - var license_input = jQuery('#qcld_chatsessions_enter_license_or_purchase_key').val();
19 - if( /^(\w{8})-((\w{4})-){3}(\w{12})$/.test(license_input) ){
20 - jQuery('input[name="qcld_chatsessions_buy_from_where"]').val('codecanyon');
21 - jQuery('input[name="qcld_chatsessions_enter_envato_key"]').val(license_input);
22 - }else{
23 - jQuery('input[name="qcld_chatsessions_buy_from_where"]').val('quantumcloud');
24 - jQuery('input[name="qcld_chatsessions_enter_license_key"]').val(license_input);
25 - }
26 - }
27 - function htmlspecialchars_decode(text) {
28 - const parser = new DOMParser();
29 - const doc = parser.parseFromString(text, 'text/html');
30 - return doc.documentElement.textContent;
31 - }
32 - var session_hover_state = '';
33 - const modal = document.getElementById("session_details_modal");
34 - jQuery('.session_detail_hover').hover(function(e) {
35 - var self = this;
36 - var hoverTimer = '';
37 - const modal = document.getElementById("session_details_modal");
38 -
39 - window.onclick = function(event) {
40 - if (event.target == modal) {
41 - modal.style.display = "none";
42 - }
43 - }
44 - if(session_hover_state == ''){
45 - session_hover_state = 1;
46 - modal.style.display = "none";
47 - jQuery('.details_modal_body').html('');
48 - modal.style.left = '';
49 - modal.style.top = '';
50 - setTimeout(function() {
51 - modal.style.display = "block";
52 - jQuery('.loader-mask').show();
53 - jQuery('.loader').show();
54 - jQuery.ajax({
55 - url: ajax_object.ajax_url,
56 - type: 'POST',
57 - dataType: "JSON",
58 - data: {
59 - action : 'wpbot_session_hover_details',
60 - security: ajax_object.ajax_nonce,
61 - session_id: jQuery(self).attr('data-id'),
62 - },
63 - success: function (response) {
64 - jQuery('.loader').fadeOut();
65 - jQuery('.loader-mask').delay(350).fadeOut('slow');
66 - let htmlString = response.conversation;
67 - let doc = '<div class="session-details-sction-modal">' ;
68 - doc += htmlspecialchars_decode(htmlString);
69 - doc += '</div>';
70 - if (response.email) {
71 - doc += '<div class="email-reply-container">' +
72 - '<p class="email-reply-meta">Reply via <strong>Email to:</strong> ' + response.email + ' <strong>From:</strong> <input type="email" id="reply_from_email" class="form-control" value="' + ( response.email_from ? '' + response.email_from : '' ) + '"></p>' +
73 - '<div class="form-group mb-2">' +
74 - '<input type="text" id="reply_subject" class="form-control" placeholder="Reply to your chat session">' +
75 - '</div>' +
76 - '<div class="form-group mb-2">' +
77 - '<textarea id="reply_message" class="form-control" rows="4" placeholder="Type your reply here..."></textarea>' +
78 - '</div>' +
79 - '<button type="button" class="btn btn-primary" id="btn_send_reply_email" data-email="' + response.email + '">Send Reply</button>' +
80 - '</div>';
81 - } else {
82 - doc += '<div class="email-reply-container">' +
83 - '<p class="email-reply-warning">Enable Asking for Email to get email reply option</p>' +
84 - '</div>';
85 - }
86 - jQuery('.details_modal_body').html(doc);
87 - session_hover_state = '';
88 - // location.reload();
89 - },
90 - });
91 - }, 100);
92 - }
93 - });
94 - jQuery('#chatsession-table').on('click', '.show_details_click', function(e) {
95 - var self = this;
96 - const modal = document.getElementById("session_details_modal");
97 -
98 - window.onclick = function(event) {
99 - if (event.target == modal) {
100 - modal.style.display = "none";
101 - }
102 - }
103 - if(session_hover_state == ''){
104 - session_hover_state = 1;
105 - modal.style.display = "none";
106 - jQuery('.details_modal_body').html('');
107 - modal.style.left = '';
108 - modal.style.top = '';
109 -
110 - if (typeof Swal !== 'undefined') {
111 - Swal.fire({
112 - html: '<div class="qcld-save-settings-spinner"></div>',
113 - allowOutsideClick: false,
114 - allowEscapeKey: false,
115 - showConfirmButton: false,
116 - background: 'transparent',
117 - customClass: {
118 - popup: 'qcld-swal-loading-only'
119 - }
120 - });
121 - }
122 -
123 - jQuery.ajax({
124 - url: ajax_object.ajax_url,
125 - type: 'POST',
126 - dataType: "JSON",
127 - data: {
128 - action : 'wpbot_session_hover_details',
129 - security: ajax_object.ajax_nonce,
130 - session_id: jQuery(self).attr('data-id'),
131 - },
132 - success: function (response) {
133 - if (typeof Swal !== 'undefined') {
134 - Swal.close();
135 - }
136 - let htmlString = response.conversation;
137 - let doc = '<div class="session-details-sction-modal">' ;
138 - doc += htmlspecialchars_decode(htmlString);
139 - doc += '</div>';
140 - if (response.email) {
141 - var replyEmail = response.email || '';
142 - var replyEmailText = jQuery('<div>').text(replyEmail).html();
143 - var replyEmailLink = '<a href="mailto:' + encodeURIComponent(replyEmail) + '">' + replyEmailText + '</a>';
144 - doc += '<div class="email-reply-container">' +
145 - '<p class="email-reply-meta">Reply via <strong>Email to:</strong> ' + replyEmailLink + ' <strong>From:</strong> <input type="email" id="reply_from_email" value="' + ( response.email_from ? '' + response.email_from : '' ) + '"></p>' +
146 - '<div class="form-group mb-2">' +
147 - '<input type="text" id="reply_subject" class="form-control" placeholder="Reply to your chat session">' +
148 - '</div>' +
149 - '<div class="form-group mb-2">' +
150 - '<textarea id="reply_message" class="form-control" rows="4" placeholder="Type your reply here..."></textarea>' +
151 - '</div>' +
152 - '<button type="button" class="btn btn-primary" id="btn_send_reply_email" data-email="' + response.email + '">Send Reply</button>' +
153 - '</div>';
154 - } else {
155 - doc += '<div class="email-reply-container">' +
156 - '<p class="email-reply-warning">To email this user and chat session, enable Asking for Email in General Settings</p>' +
157 - '<p class="email-reply-meta">Reply via <strong>Email to:</strong> ' + (response.email || '') + ' <strong>From:</strong> <input type="email" id="reply_from_email" disabled value="' + ( response.email_from ? '' + response.email_from : '' ) + '"></p>' +
158 - '<div class="form-group mb-2">' +
159 - '<input type="text" id="reply_subject" disabled class="form-control" placeholder="Reply to your chat session">' +
160 - '</div>' +
161 - '<div class="form-group mb-2">' +
162 - '<textarea id="reply_message" disabled class="form-control" rows="4" placeholder="Type your reply here..."></textarea>' +
163 - '</div>' +
164 - '<button type="button" disabled class="btn btn-primary" id="btn_send_reply_email" data-email="' + response.email + '">Send Reply</button>' +
165 - '</div>';
166 - }
167 - jQuery('.details_modal_body').html(doc);
168 - modal.style.display = "block";
169 - session_hover_state = '';
170 - },
171 - error: function () {
172 - if (typeof Swal !== 'undefined') {
173 - Swal.close();
174 - }
175 - session_hover_state = '';
176 - }
177 - });
178 - }
179 - });
180 - jQuery('#session_details_modal').on('click','.details_session_close',function(){
181 - const modal = document.getElementById("session_details_modal");
182 - modal.style.display = "none";
183 - });
184 -
185 - jQuery(document).on('click', '#btn_send_reply_email', function () {
186 - var email = jQuery(this).attr('data-email');
187 - var container = jQuery(this).closest('.email-reply-container');
188 - var fromEmail = container.find('#reply_from_email').val();
189 - var subject = container.find('#reply_subject').val();
190 - var message = container.find('#reply_message').val();
191 - var btn = jQuery(this);
192 -
193 - if (!message.trim()) {
194 - alert('Please enter a message.');
195 - return;
196 - }
197 -
198 - btn.prop('disabled', true).text('Sending...');
199 -
200 - jQuery.ajax({
201 - url: ajax_object.ajax_url,
202 - type: 'POST',
203 - dataType: "JSON",
204 - data: {
205 - action: 'wpbot_send_reply_email',
206 - security: ajax_object.ajax_nonce,
207 - email: email,
208 - from_email: fromEmail,
209 - subject: subject,
210 - message: message
211 - },
212 - success: function (response) {
213 - btn.prop('disabled', false).text('Send Reply');
214 - if (response.success) {
215 - if (typeof Swal !== 'undefined') {
216 - Swal.fire({
217 - title: 'Success',
218 - text: response.msg,
219 - icon: 'success',
220 - confirmButtonText: 'OK'
221 - });
222 - } else {
223 - alert(response.msg);
224 - }
225 - container.find('#reply_message').val('');
226 - } else {
227 - if (typeof Swal !== 'undefined') {
228 - Swal.fire({
229 - title: 'Error',
230 - text: response.msg,
231 - icon: 'error',
232 - confirmButtonText: 'OK'
233 - });
234 - } else {
235 - alert(response.msg);
236 - }
237 - }
238 - },
239 - error: function() {
240 - btn.prop('disabled', false).text('Send Reply');
241 - alert('An error occurred. Please try again.');
242 - }
243 - });
244 - });
245 - jQuery('#wpchatbot-sessioncorn-settings').on('click','#save_wpsseion_corn_setting',function(){
246 - Swal.showLoading();
247 - if (jQuery('#is_ai_enabled').is(":checked")){
248 - var is_ai_enabled = 1;
249 - }else{
250 - var is_ai_enabled = 0;
251 - }
252 - var corn_schedule_interval = jQuery("[id*='corn_schedule_interval'] :selected").val();
253 - var qcld_wbsession_corn_starttime = jQuery('#qcld_wbsession_corn_starttime').val();
254 - var qcld_wpsession_corn_promt = jQuery('#wpsession_corn_promt').val();
255 - jQuery.ajax({
256 - url: ajax_object.ajax_url,
257 - type: 'POST',
258 - dataType: "JSON",
259 - data: {
260 - action : 'wpbot_seesion_corn_save',
261 - security: ajax_object.ajax_nonce,
262 - ai_enabled: is_ai_enabled,
263 - corn_schedule_interval: corn_schedule_interval,
264 - qcld_wbsession_corn_starttime: qcld_wbsession_corn_starttime,
265 - qcld_wpsession_corn_promt: qcld_wpsession_corn_promt,
266 - },
267 - success: function (response) {
268 - var cleanResponse = response.response ? response.response.replace(/<br\s*\/?>/gi, '\n').replace(/<\/?[^>]+(>|$)/g, "") : "";
269 - var cleanMsg = response.msg ? response.msg.replace(/<br\s*\/?>/gi, '\n').replace(/<\/?[^>]+(>|$)/g, "") : "";
270 - Swal.fire({
271 - title: cleanMsg,
272 - text: cleanResponse,
273 - icon: response.icon,
274 - width: 450,
275 - confirmButtonText: 'Got it',
276 - confirmButtonWidth: 100,
277 - confirmButtonClass: 'btn btn-lg'
278 - }).then(() => {
279 - // location.reload();
280 - })
281 -
282 - },
283 - });
284 - })
285 - jQuery('#wpchatbot-sessioncorn-mannual').on('click','#swpsseion_mannual_scraper_corn',function(){
286 - Swal.showLoading();
287 - var wpchatbot_sessioncorn_mannual_number = jQuery('#wpchatbot-sessioncorn-mannual-number').val();
288 - jQuery.ajax({
289 - url: ajax_object.ajax_url,
290 - type: 'POST',
291 - dataType: "JSON",
292 - data: {
293 - action : 'qcld_chatbot_session_mannual_scraper',
294 - security: ajax_object.ajax_nonce,
295 - wpchatbot_session_mannual_number : wpchatbot_sessioncorn_mannual_number,
296 - },
297 - success: function (response) {
298 - var cleanResponse = response.response ? response.response.replace(/<br\s*\/?>/gi, '\n').replace(/<\/?[^>]+(>|$)/g, "") : "";
299 - var cleanMsg = response.msg ? response.msg.replace(/<br\s*\/?>/gi, '\n').replace(/<\/?[^>]+(>|$)/g, "") : "";
300 - Swal.fire({
301 - title: cleanMsg,
302 - text: cleanResponse,
303 - icon: response.icon,
304 - width: 450,
305 - confirmButtonText: 'Got it',
306 - confirmButtonWidth: 100,
307 - confirmButtonClass: 'btn btn-lg'
308 - }).then(() => {
309 - // location.reload();
310 - })
311 - },
312 - });
313 - })
314 -
315 - //end new-update-for-codecanyon
316 - jQuery('#wpcs_form_sessions').on('change', '#is_enabled_session_email_notice', function() {
317 - if(this.checked) {
318 - jQuery.ajax({
319 - url: ajax_object.ajax_url,
320 - type: 'POST',
321 - dataType: "JSON",
322 - data: {
323 - action : 'session_email_notification_update',
324 - security: ajax_object.ajax_nonce,
325 - email_notification: 'checked',
326 - },
327 - success: function (response) {
328 - location.reload();
329 - },
330 - });
331 - }else{
332 - jQuery.ajax({
333 - url: ajax_object.ajax_url,
334 - type: 'POST',
335 - dataType: "JSON",
336 - data: {
337 - action : 'session_email_notification_update',
338 - security: ajax_object.ajax_nonce,
339 - email_notification: '',
340 - },
341 - success: function (response) {
342 - location.reload();
343 - },
344 - });
345 - }
346 - });
347 -
348 - jQuery('#chatsession-table').on('click', '.forward_session', function () {
349 - jQuery('.details_modal_body').html('');
350 -
351 - const forwardModal = document.getElementById("session_foward_modal");
352 - if (forwardModal) {
353 - forwardModal.style.display = "block";
354 - jQuery('#details_session_id').val(jQuery(this).attr('data-id'));
355 - }
356 -
357 - });
358 - jQuery('#session_foward_modal').on('click', '.forward_session_close', function () {
359 - const forwardModal = document.getElementById("session_foward_modal");
360 - if (forwardModal) {
361 - forwardModal.style.display = "none";
362 - }
363 - });
364 -
365 - jQuery('#session_foward_modal').on('click', '#qcld_details_forward_submit', function () {
366 - var session_id = jQuery('#details_session_id').val();
367 - jQuery.ajax({
368 - url: ajax_object.ajax_url,
369 - type: 'POST',
370 - dataType: "JSON",
371 - data: {
372 - action : 'forward_session_to_email',
373 - security: ajax_object.ajax_nonce,
374 - session_id: session_id,
375 - email: jQuery('#details_session_email').val(),
376 - subject: jQuery('#details_session_subject').val(),
377 - },
378 - success: function (response) {
379 - jQuery('#session_foward_modal').hide()
380 - }
381 - });
382 - });
383 - jQuery('.wp-chatbot-messages-wrapper').on('click', '.forward_session', function () {
384 -
385 - var session_id = jQuery('#details_session_id').val();
386 - jQuery.ajax({
387 - url: ajax_object.ajax_url,
388 - type: 'POST',
389 - dataType: "JSON",
390 - data: {
391 - action : 'forward_session_to_email',
392 - security: ajax_object.ajax_nonce,
393 - session_id: session_id,
394 - email: jQuery('#details_session_email').val(),
395 - subject: jQuery('#details_session_subject').val(),
396 - },
397 - success: function (response) {
398 - if(response.success){
399 - Swal.fire({
400 - title: 'Success',
401 - text: response.message,
402 - icon: 'success',
403 - confirmButtonText: 'OK'
404 - });
405 - } else {
406 - Swal.fire({
407 - title: 'Error',
408 - text: response.message,
409 - icon: 'error',
410 - confirmButtonText: 'OK'
411 - });
412 - }
413 - }
414 - });
415 - });
416 -
417 -});
1 +jQuery(document).ready(function(){
2 + 'use strict'
3 + //start new-update-for-codecanyon
4 + jQuery('#qcld_chatsessions_enter_license_or_purchase_key').on('focusout', function(){
5 + qc_chatsessions_set_plugin_license_fields();
6 + });
7 +
8 + jQuery('#qcld_chatsessions_enter_license_or_purchase_key').on('keypress',function (e) {
9 + qc_chatsessions_set_plugin_license_fields();
10 + });
11 +
12 + jQuery('#qc-license-form input[type="submit"]').on('click', function(){
13 + qc_chatsessions_set_plugin_license_fields();
14 + jQuery('#qc-license-form').removeAttr('onsubmit').submit();
15 + });
16 +
17 + function qc_chatsessions_set_plugin_license_fields(){
18 + var license_input = jQuery('#qcld_chatsessions_enter_license_or_purchase_key').val();
19 + if( /^(\w{8})-((\w{4})-){3}(\w{12})$/.test(license_input) ){
20 + jQuery('input[name="qcld_chatsessions_buy_from_where"]').val('codecanyon');
21 + jQuery('input[name="qcld_chatsessions_enter_envato_key"]').val(license_input);
22 + }else{
23 + jQuery('input[name="qcld_chatsessions_buy_from_where"]').val('quantumcloud');
24 + jQuery('input[name="qcld_chatsessions_enter_license_key"]').val(license_input);
25 + }
26 + }
27 + function htmlspecialchars_decode(text) {
28 + const parser = new DOMParser();
29 + const doc = parser.parseFromString(text, 'text/html');
30 + return doc.documentElement.textContent;
31 + }
32 + var session_hover_state = '';
33 + const modal = document.getElementById("session_details_modal");
34 + jQuery('.session_detail_hover').hover(function(e) {
35 + var self = this;
36 + var hoverTimer = '';
37 + const modal = document.getElementById("session_details_modal");
38 +
39 + window.onclick = function(event) {
40 + if (event.target == modal) {
41 + modal.style.display = "none";
42 + }
43 + }
44 + if(session_hover_state == ''){
45 + session_hover_state = 1;
46 + modal.style.display = "none";
47 + jQuery('.details_modal_body').html('');
48 + modal.style.left = '';
49 + modal.style.top = '';
50 + setTimeout(function() {
51 + modal.style.display = "block";
52 + jQuery('.loader-mask').show();
53 + jQuery('.loader').show();
54 + jQuery.ajax({
55 + url: ajax_object.ajax_url,
56 + type: 'POST',
57 + dataType: "JSON",
58 + data: {
59 + action : 'wpbot_session_hover_details',
60 + security: ajax_object.ajax_nonce,
61 + session_id: jQuery(self).attr('data-id'),
62 + },
63 + success: function (response) {
64 + jQuery('.loader').fadeOut();
65 + jQuery('.loader-mask').delay(350).fadeOut('slow');
66 + // SECURITY FIX: Server now returns sanitized HTML (wp_kses output).
67 + // Do NOT run htmlspecialchars_decode() on conversation data before .html();
68 + // that decode-then-inject pattern was the DOM XSS sink.
69 + let htmlString = response.conversation;
70 + let doc = '<div class="session-details-sction-modal">' ;
71 + doc += htmlString;
72 + doc += '</div>';
73 + if (response.email) {
74 + doc += '<div class="email-reply-container">' +
75 + '<p class="email-reply-meta">Reply via <strong>Email to:</strong> ' + response.email + ' <strong>From:</strong> <input type="email" id="reply_from_email" class="form-control" value="' + ( response.email_from ? '' + response.email_from : '' ) + '"></p>' +
76 + '<div class="form-group mb-2">' +
77 + '<input type="text" id="reply_subject" class="form-control" placeholder="Reply to your chat session">' +
78 + '</div>' +
79 + '<div class="form-group mb-2">' +
80 + '<textarea id="reply_message" class="form-control" rows="4" placeholder="Type your reply here..."></textarea>' +
81 + '</div>' +
82 + '<button type="button" class="btn btn-primary" id="btn_send_reply_email" data-email="' + response.email + '">Send Reply</button>' +
83 + '</div>';
84 + } else {
85 + doc += '<div class="email-reply-container">' +
86 + '<p class="email-reply-warning">Enable Asking for Email to get email reply option</p>' +
87 + '</div>';
88 + }
89 + jQuery('.details_modal_body').html(doc);
90 + session_hover_state = '';
91 + // location.reload();
92 + },
93 + });
94 + }, 100);
95 + }
96 + });
97 + jQuery('#chatsession-table').on('click', '.show_details_click', function(e) {
98 + var self = this;
99 + const modal = document.getElementById("session_details_modal");
100 +
101 + window.onclick = function(event) {
102 + if (event.target == modal) {
103 + modal.style.display = "none";
104 + }
105 + }
106 + if(session_hover_state == ''){
107 + session_hover_state = 1;
108 + modal.style.display = "none";
109 + jQuery('.details_modal_body').html('');
110 + modal.style.left = '';
111 + modal.style.top = '';
112 +
113 + if (typeof Swal !== 'undefined') {
114 + Swal.fire({
115 + html: '<div class="qcld-save-settings-spinner"></div>',
116 + allowOutsideClick: false,
117 + allowEscapeKey: false,
118 + showConfirmButton: false,
119 + background: 'transparent',
120 + customClass: {
121 + popup: 'qcld-swal-loading-only'
122 + }
123 + });
124 + }
125 +
126 + jQuery.ajax({
127 + url: ajax_object.ajax_url,
128 + type: 'POST',
129 + dataType: "JSON",
130 + data: {
131 + action : 'wpbot_session_hover_details',
132 + security: ajax_object.ajax_nonce,
133 + session_id: jQuery(self).attr('data-id'),
134 + },
135 + success: function (response) {
136 + if (typeof Swal !== 'undefined') {
137 + Swal.close();
138 + }
139 + // SECURITY FIX: Server now returns sanitized HTML (wp_kses output).
140 + // Do NOT run htmlspecialchars_decode() on conversation data before .html();
141 + // that decode-then-inject pattern was the DOM XSS sink.
142 + let htmlString = response.conversation;
143 + let doc = '<div class="session-details-sction-modal">' ;
144 + doc += htmlString;
145 + doc += '</div>';
146 + if (response.email) {
147 + var replyEmail = response.email || '';
148 + var replyEmailText = jQuery('<div>').text(replyEmail).html();
149 + var replyEmailLink = '<a href="mailto:' + encodeURIComponent(replyEmail) + '">' + replyEmailText + '</a>';
150 + doc += '<div class="email-reply-container">' +
151 + '<p class="email-reply-meta">Reply via <strong>Email to:</strong> ' + replyEmailLink + ' <strong>From:</strong> <input type="email" id="reply_from_email" value="' + ( response.email_from ? '' + response.email_from : '' ) + '"></p>' +
152 + '<div class="form-group mb-2">' +
153 + '<input type="text" id="reply_subject" class="form-control" placeholder="Reply to your chat session">' +
154 + '</div>' +
155 + '<div class="form-group mb-2">' +
156 + '<textarea id="reply_message" class="form-control" rows="4" placeholder="Type your reply here..."></textarea>' +
157 + '</div>' +
158 + '<button type="button" class="btn btn-primary" id="btn_send_reply_email" data-email="' + response.email + '">Send Reply</button>' +
159 + '</div>';
160 + } else {
161 + doc += '<div class="email-reply-container">' +
162 + '<p class="email-reply-warning">To email this user and chat session, enable Asking for Email in General Settings</p>' +
163 + '<p class="email-reply-meta">Reply via <strong>Email to:</strong> ' + (response.email || '') + ' <strong>From:</strong> <input type="email" id="reply_from_email" disabled value="' + ( response.email_from ? '' + response.email_from : '' ) + '"></p>' +
164 + '<div class="form-group mb-2">' +
165 + '<input type="text" id="reply_subject" disabled class="form-control" placeholder="Reply to your chat session">' +
166 + '</div>' +
167 + '<div class="form-group mb-2">' +
168 + '<textarea id="reply_message" disabled class="form-control" rows="4" placeholder="Type your reply here..."></textarea>' +
169 + '</div>' +
170 + '<button type="button" disabled class="btn btn-primary" id="btn_send_reply_email" data-email="' + response.email + '">Send Reply</button>' +
171 + '</div>';
172 + }
173 + jQuery('.details_modal_body').html(doc);
174 + modal.style.display = "block";
175 + session_hover_state = '';
176 + },
177 + error: function () {
178 + if (typeof Swal !== 'undefined') {
179 + Swal.close();
180 + }
181 + session_hover_state = '';
182 + }
183 + });
184 + }
185 + });
186 + jQuery('#session_details_modal').on('click','.details_session_close',function(){
187 + const modal = document.getElementById("session_details_modal");
188 + modal.style.display = "none";
189 + });
190 +
191 + jQuery(document).on('click', '#btn_send_reply_email', function () {
192 + var email = jQuery(this).attr('data-email');
193 + var container = jQuery(this).closest('.email-reply-container');
194 + var fromEmail = container.find('#reply_from_email').val();
195 + var subject = container.find('#reply_subject').val();
196 + var message = container.find('#reply_message').val();
197 + var btn = jQuery(this);
198 +
199 + if (!message.trim()) {
200 + alert('Please enter a message.');
201 + return;
202 + }
203 +
204 + btn.prop('disabled', true).text('Sending...');
205 +
206 + jQuery.ajax({
207 + url: ajax_object.ajax_url,
208 + type: 'POST',
209 + dataType: "JSON",
210 + data: {
211 + action: 'wpbot_send_reply_email',
212 + security: ajax_object.ajax_nonce,
213 + email: email,
214 + from_email: fromEmail,
215 + subject: subject,
216 + message: message
217 + },
218 + success: function (response) {
219 + btn.prop('disabled', false).text('Send Reply');
220 + if (response.success) {
221 + if (typeof Swal !== 'undefined') {
222 + Swal.fire({
223 + title: 'Success',
224 + text: response.msg,
225 + icon: 'success',
226 + confirmButtonText: 'OK'
227 + });
228 + } else {
229 + alert(response.msg);
230 + }
231 + container.find('#reply_message').val('');
232 + } else {
233 + if (typeof Swal !== 'undefined') {
234 + Swal.fire({
235 + title: 'Error',
236 + text: response.msg,
237 + icon: 'error',
238 + confirmButtonText: 'OK'
239 + });
240 + } else {
241 + alert(response.msg);
242 + }
243 + }
244 + },
245 + error: function() {
246 + btn.prop('disabled', false).text('Send Reply');
247 + alert('An error occurred. Please try again.');
248 + }
249 + });
250 + });
251 + jQuery('#wpchatbot-sessioncorn-settings').on('click','#save_wpsseion_corn_setting',function(){
252 + Swal.showLoading();
253 + if (jQuery('#is_ai_enabled').is(":checked")){
254 + var is_ai_enabled = 1;
255 + }else{
256 + var is_ai_enabled = 0;
257 + }
258 + var corn_schedule_interval = jQuery("[id*='corn_schedule_interval'] :selected").val();
259 + var qcld_wbsession_corn_starttime = jQuery('#qcld_wbsession_corn_starttime').val();
260 + var qcld_wpsession_corn_promt = jQuery('#wpsession_corn_promt').val();
261 + jQuery.ajax({
262 + url: ajax_object.ajax_url,
263 + type: 'POST',
264 + dataType: "JSON",
265 + data: {
266 + action : 'wpbot_seesion_corn_save',
267 + security: ajax_object.ajax_nonce,
268 + ai_enabled: is_ai_enabled,
269 + corn_schedule_interval: corn_schedule_interval,
270 + qcld_wbsession_corn_starttime: qcld_wbsession_corn_starttime,
271 + qcld_wpsession_corn_promt: qcld_wpsession_corn_promt,
272 + },
273 + success: function (response) {
274 + var cleanResponse = response.response ? response.response.replace(/<br\s*\/?>/gi, '\n').replace(/<\/?[^>]+(>|$)/g, "") : "";
275 + var cleanMsg = response.msg ? response.msg.replace(/<br\s*\/?>/gi, '\n').replace(/<\/?[^>]+(>|$)/g, "") : "";
276 + Swal.fire({
277 + title: cleanMsg,
278 + text: cleanResponse,
279 + icon: response.icon,
280 + width: 450,
281 + confirmButtonText: 'Got it',
282 + confirmButtonWidth: 100,
283 + confirmButtonClass: 'btn btn-lg'
284 + }).then(() => {
285 + // location.reload();
286 + })
287 +
288 + },
289 + });
290 + })
291 + jQuery('#wpchatbot-sessioncorn-mannual').on('click','#swpsseion_mannual_scraper_corn',function(){
292 + Swal.showLoading();
293 + var wpchatbot_sessioncorn_mannual_number = jQuery('#wpchatbot-sessioncorn-mannual-number').val();
294 + jQuery.ajax({
295 + url: ajax_object.ajax_url,
296 + type: 'POST',
297 + dataType: "JSON",
298 + data: {
299 + action : 'qcld_chatbot_session_mannual_scraper',
300 + security: ajax_object.ajax_nonce,
301 + wpchatbot_session_mannual_number : wpchatbot_sessioncorn_mannual_number,
302 + },
303 + success: function (response) {
304 + var cleanResponse = response.response ? response.response.replace(/<br\s*\/?>/gi, '\n').replace(/<\/?[^>]+(>|$)/g, "") : "";
305 + var cleanMsg = response.msg ? response.msg.replace(/<br\s*\/?>/gi, '\n').replace(/<\/?[^>]+(>|$)/g, "") : "";
306 + Swal.fire({
307 + title: cleanMsg,
308 + text: cleanResponse,
309 + icon: response.icon,
310 + width: 450,
311 + confirmButtonText: 'Got it',
312 + confirmButtonWidth: 100,
313 + confirmButtonClass: 'btn btn-lg'
314 + }).then(() => {
315 + // location.reload();
316 + })
317 + },
318 + });
319 + })
320 +
321 + //end new-update-for-codecanyon
322 + jQuery('#wpcs_form_sessions').on('change', '#is_enabled_session_email_notice', function() {
323 + if(this.checked) {
324 + jQuery.ajax({
325 + url: ajax_object.ajax_url,
326 + type: 'POST',
327 + dataType: "JSON",
328 + data: {
329 + action : 'session_email_notification_update',
330 + security: ajax_object.ajax_nonce,
331 + email_notification: 'checked',
332 + },
333 + success: function (response) {
334 + location.reload();
335 + },
336 + });
337 + }else{
338 + jQuery.ajax({
339 + url: ajax_object.ajax_url,
340 + type: 'POST',
341 + dataType: "JSON",
342 + data: {
343 + action : 'session_email_notification_update',
344 + security: ajax_object.ajax_nonce,
345 + email_notification: '',
346 + },
347 + success: function (response) {
348 + location.reload();
349 + },
350 + });
351 + }
352 + });
353 +
354 + jQuery('#chatsession-table').on('click', '.forward_session', function () {
355 + jQuery('.details_modal_body').html('');
356 +
357 + const forwardModal = document.getElementById("session_foward_modal");
358 + if (forwardModal) {
359 + forwardModal.style.display = "block";
360 + jQuery('#details_session_id').val(jQuery(this).attr('data-id'));
361 + }
362 +
363 + });
364 + jQuery('#session_foward_modal').on('click', '.forward_session_close', function () {
365 + const forwardModal = document.getElementById("session_foward_modal");
366 + if (forwardModal) {
367 + forwardModal.style.display = "none";
368 + }
369 + });
370 +
371 + jQuery('#session_foward_modal').on('click', '#qcld_details_forward_submit', function () {
372 + var session_id = jQuery('#details_session_id').val();
373 + jQuery.ajax({
374 + url: ajax_object.ajax_url,
375 + type: 'POST',
376 + dataType: "JSON",
377 + data: {
378 + action : 'forward_session_to_email',
379 + security: ajax_object.ajax_nonce,
380 + session_id: session_id,
381 + email: jQuery('#details_session_email').val(),
382 + subject: jQuery('#details_session_subject').val(),
383 + },
384 + success: function (response) {
385 + jQuery('#session_foward_modal').hide()
386 + }
387 + });
388 + });
389 + jQuery('.wp-chatbot-messages-wrapper').on('click', '.forward_session', function () {
390 +
391 + var session_id = jQuery('#details_session_id').val();
392 + jQuery.ajax({
393 + url: ajax_object.ajax_url,
394 + type: 'POST',
395 + dataType: "JSON",
396 + data: {
397 + action : 'forward_session_to_email',
398 + security: ajax_object.ajax_nonce,
399 + session_id: session_id,
400 + email: jQuery('#details_session_email').val(),
401 + subject: jQuery('#details_session_subject').val(),
402 + },
403 + success: function (response) {
404 + if(response.success){
405 + Swal.fire({
406 + title: 'Success',
407 + text: response.message,
408 + icon: 'success',
409 + confirmButtonText: 'OK'
410 + });
411 + } else {
412 + Swal.fire({
413 + title: 'Error',
414 + text: response.message,
415 + icon: 'error',
416 + confirmButtonText: 'OK'
417 + });
418 + }
419 + }
420 + });
421 + });
422 +
423 +});