PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.5.0
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.5.0
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 8.5.4 8.5.3 All 534 releases
chatbot / inc / qcld-floating-icons.js

qcld-floating-icons.js in WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services 8.5.0, at inc/qcld-floating-icons.js

469 lines 25.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($){
2 'use strict';
3
4 $( document ).ready(function() {
5
6
7 $(document).on('click','#qc_wpbotpro_content_generator', function(){
8
9 //console.log('working');
10 $('#qc_wpbotpro_content_generator_modal').modal( { backdrop: 'static', keyboard: false }, 'show');
11 jQuery('#qc_wpbotpro_content_generator_modal').modal('show')
12
13 });
14
15
16 $(document).on('click','#qc_wpbotpro_floating_openai_keyword_suggestion', function(){
17 var qcld_keyword_suggestion = $('#qc_wpbotpro_floating_openai_keyword_suggestion_mf').val();
18 var qcld_keyword_number = $('#qcld_keyword_number').val();
19 var qc_wpbotpro_article_language = $('#qc_wpbotpro_article_language').val();
20 var qc_wpbotpro_article_number_of_heading = $('#qc_wpbotpro_article_number_of_heading').val();
21 var qc_wpbotpro_article_heading_tag = $('#qc_wpbotpro_article_heading_tag').val();
22 var qc_wpbotpro_article_heading_style = $('#qc_wpbotpro_article_heading_style').val();
23 var qc_wpbotpro_article_heading_tone = $('#qc_wpbotpro_article_heading_tone').val();
24 var qc_wpbotpro_article_heading_img = $('#qc_wpbotpro_article_heading_img').val();
25 var qc_wpbotpro_article_heading_img = $("input[name=qc_wpbotpro_article_heading_img]:checked").val();
26 var qc_wpbotpro_article_heading_tagline = $("input[name=qc_wpbotpro_article_heading_tagline]:checked").val();
27 var qc_wpbotpro_article_heading_intro = $("input[name=qc_wpbotpro_article_heading_intro]:checked").val();
28 var qc_wpbotpro_article_heading_conclusion = $("input[name=qc_wpbotpro_article_heading_conclusion]:checked").val();
29 var qc_wpbotpro_article_label_anchor_text = $('#qc_wpbotpro_article_label_anchor_text').val();
30 var qc_wpbotpro_article_target_url = $('#qc_wpbotpro_article_target_url').val();
31 var qc_wpbotpro_article_target_label_cta = $('#qc_wpbotpro_article_target_label_cta').val();
32 var qc_wpbotpro_article_cta_pos = $('#qc_wpbotpro_article_cta_pos').val();
33 var qc_wpbotpro_article_label_keywords = $('#qc_wpbotpro_article_label_keywords').val();
34 var qc_wpbotpro_article_label_word_to_avoid= $('#qc_wpbotpro_article_label_word_to_avoid').val();
35 var qc_wpbotpro_article_label_keywords_bold= $("input[name=qc_wpbotpro_article_label_keywords_bold]:checked").val();
36 var qc_wpbotpro_article_heading_faq = $("input[name=qc_wpbotpro_article_heading_faq]:checked").val();
37 var qc_wpbotpro_article_img_size = $('#qc_wpbotpro_article_img_size').val();
38
39 $('#qc_wpbotpro_floating_openai_keyword_suggestion').addClass('spinning');
40 $('#qc_wpbotpro_floating_openai_keyword_suggestion').prop("disabled",true);
41 $('#qc_wpbotpro_floating_bait_article_keyword_data').hide();
42 $('.qcld_seo-playground-buttons').hide();
43
44 $.ajax({
45 url: qc_wpbotpro_floating_ajaxurl,
46 method: 'POST',
47 data: {
48 'action': 'qc_wpbotpro_floating_openai_keyword_suggestion_content_function',
49 'keyword' : qcld_keyword_suggestion,
50 'keyword_number' : qcld_keyword_number,
51 'qc_wpbotpro_article_language' : qc_wpbotpro_article_language,
52 'qc_wpbotpro_article_number_of_heading' : qc_wpbotpro_article_number_of_heading,
53 'qc_wpbotpro_article_heading_tag' : qc_wpbotpro_article_heading_tag,
54 'qc_wpbotpro_article_heading_style' : qc_wpbotpro_article_heading_style,
55 'qc_wpbotpro_article_heading_tone' : qc_wpbotpro_article_heading_tone,
56 'qc_wpbotpro_article_heading_img' : qc_wpbotpro_article_heading_img,
57 'qc_wpbotpro_article_heading_tagline' : qc_wpbotpro_article_heading_tagline,
58 'qc_wpbotpro_article_heading_intro' : qc_wpbotpro_article_heading_intro,
59 'qc_wpbotpro_article_heading_conclusion' : qc_wpbotpro_article_heading_conclusion,
60 'qc_wpbotpro_article_label_anchor_text' : qc_wpbotpro_article_label_anchor_text,
61 'qc_wpbotpro_article_target_url' : qc_wpbotpro_article_target_url,
62 'qc_wpbotpro_article_target_label_cta' : qc_wpbotpro_article_target_label_cta,
63 'qc_wpbotpro_article_cta_pos' : qc_wpbotpro_article_cta_pos,
64 'qc_wpbotpro_article_label_keywords' : qc_wpbotpro_article_label_keywords,
65 'qc_wpbotpro_article_label_word_to_avoid': qc_wpbotpro_article_label_word_to_avoid,
66 'qc_wpbotpro_article_label_keywords_bold': qc_wpbotpro_article_label_keywords_bold,
67 'qc_wpbotpro_article_heading_faq' : qc_wpbotpro_article_heading_faq,
68 'qc_wpbotpro_article_img_size' : qc_wpbotpro_article_img_size,
69 'security' : qc_wpbotpro_floating_ajax_nonce
70 //'selectedlanguage': selectedlanguage,
71 },
72 dataType: 'json',
73 success: function(response) {
74 //$('#qc_wpbotpro_floating_bait_keyword_data').append(response.keywords);
75 $('#qc_wpbotpro_floating_openai_keyword_suggestion').prop("disabled",false);
76 $('#qc_wpbotpro_floating_openai_keyword_suggestion').removeClass('spinning');
77 $('.qcld_seo-playground-buttons').show();
78 //$('#qc_wpbotpro_floating_bait_article_keyword_data').html('<div class="qcld_copied-content-wrap"><div class="qcld_copied-content_text btn d-none link-success">Copied</div><a class="btn btn-sm btn-secondary qcld-copied-content_text"><span class="dashicons dashicons-admin-page"></span></a></div><textarea id="qc_wpbotpro_floating_content_result_msg">' + response.keywords +'</textarea>');
79 //$('#qc_wpbotpro_floating_bait_article_keyword_data').append('<div class="qc_wpbotpro_floating_content_result_wrap"><div class="qc_wpbotpro_floating_rewrite_result_count">' + response.keywords.length +'</div></div>');
80 // qc_wpbotpro_floating_content_result_msg
81 $('#qc_wpbotpro_floating_content_result_msg').focus();
82 $('#qc_wpbotpro_floating_content_result_msg').focusout();
83 $('#qc_wpbotpro_floating_bait_article_keyword_data').show();
84 $('#qc_wpbotpro_floating_content_rewrite_result').show();
85 $('.qc_wpbotpro_floating_bait_single_field .qc_wpbotpro_floating_rewrite_result_count').text( response.keywords.length );
86 var editor = tinyMCE.get('qc_wpbotpro_floating_content_result_msg');
87 var basicEditor = true;
88 if ( $('#wp-qc_wpbotpro_floating_content_result_msg-wrap').hasClass('tmce-active') && editor ) {
89 basicEditor = false;
90 }
91 if(basicEditor){
92 $('#qc_wpbotpro_floating_content_result_msg').val( response.keywords );
93 }else{
94 editor.setContent( response.keywords );
95 }
96 }
97 });
98
99 });
100
101
102 $(document).on('click', '.qc_wpbotpro_floating_openai_article_save', function (e) {
103 var qc_wpbotpro_floating_draft_btn = $(this);
104 var title = $('#qc_wpbotpro_floating_openai_keyword_suggestion_mf').val();
105 var content = $('#qc_wpbotpro_floating_content_result_msg').val();
106
107 var editor = tinyMCE.get('qc_wpbotpro_floating_content_result_msg');
108 var basicEditor = true;
109 if ( $('#wp-qc_wpbotpro_floating_content_result_msg-wrap').hasClass('tmce-active') && editor ) {
110 basicEditor = false;
111 }
112
113 if(!basicEditor){
114 var content = editor.getContent();
115
116 }
117
118 if(title === ''){
119 alert('Please enter title');
120 }else if(content === ''){
121 alert('Please wait content generated');
122 }else{
123 $.ajax({
124 url: qc_wpbotpro_floating_ajaxurl,
125 data: {title: title, content: content, action: 'qc_wpbotpro_floating_openai_save_draft_post_extra', security: qc_wpbotpro_floating_ajax_nonce },
126 dataType: 'json',
127 type: 'POST',
128 beforeSend: function (){
129 qc_wpbotpro_floating_draft_btn.attr('disabled','disabled');
130 qc_wpbotpro_floating_draft_btn.append('<span class="spinner"></span>');
131 qc_wpbotpro_floating_draft_btn.find('.spinner').css('visibility','unset');
132 },
133 success: function (res){
134 qc_wpbotpro_floating_draft_btn.removeAttr('disabled');
135 qc_wpbotpro_floating_draft_btn.find('.spinner').remove();
136 if(res.status === 'success'){
137 window.location.replace( res.post_link );
138 }
139 else{
140 alert(res.msg);
141 }
142 },
143 error: function (){
144 qc_wpbotpro_floating_draft_btn.removeAttr('disabled');
145 qc_wpbotpro_floating_draft_btn.find('.spinner').remove();
146 alert('Something went wrong');
147 }
148 });
149 }
150 });
151
152 $(document).on('click','#qc_wpbotpro_floating_openai_keyword_rewrite_article',function(event){
153 var qc_wpbotpro_floating_content_rewrite = $('#qc_wpbotpro_floating_content_rewrite').val();
154 $('#qc_wpbotpro_floating_openai_keyword_rewrite_article').addClass('spinning');
155 $('#qc_wpbotpro_floating_content_rewrite_result').hide();
156 $.ajax({
157 url: qc_wpbotpro_floating_ajaxurl,
158 method: 'POST',
159 data: {
160 'action': 'qc_wpbotpro_floating_openai_keyword_rewrite_article',
161 'security': qc_wpbotpro_floating_ajax_nonce,
162 'keyword': qc_wpbotpro_floating_content_rewrite,
163 },
164 dataType: 'json',
165 success: function(response) {
166 //$('#qc_wpbotpro_floating_content_rewrite_result').html('<div class="qcld_copied-content-wrap"><div class="qcld_copied-content btn d-none link-success">Copied</div><a class="btn btn-sm btn-secondary qcld-copied-content"><span class="dashicons dashicons-admin-page"></span></a></div><textarea id="qc_wpbotpro_floating_content_rewrite_result_msg">' + response.keywords +'</textarea>');
167 //$('#qc_wpbotpro_floating_content_rewrite_result').append('<div class="qc_wpbotpro_floating_rewrite_result_count_wrap"><div class="qc_wpbotpro_floating_rewrite_result_count">' + response.keywords.length +'</div></div>');
168 $('#qc_wpbotpro_floating_content_rewrite_result').show();
169 var editor = tinyMCE.get('qc_wpbotpro_floating_content_rewrite_result_msg');
170 var basicEditor = true;
171 if ( $('#wp-qc_wpbotpro_floating_content_rewrite_result_msg-wrap').hasClass('tmce-active') && editor ) {
172 basicEditor = false;
173 }
174 if(basicEditor){
175 $('#qc_wpbotpro_floating_content_rewrite_result_msg').val( response.keywords );
176 }else{
177 editor.setContent( response.keywords );
178 }
179 var words = $.trim(response.keywords).split(" ");
180 //console.log(words.length)
181 $('.qc_wpbotpro_floating_rewrite_result_count_wrap .qc_wpbotpro_floating_rewrite_result_count').text( words.length );
182 $('#qc_wpbotpro_floating_content_rewrite_result_msg').focus();
183 $('#qc_wpbotpro_floating_content_rewrite_result_msg').focusout();
184 $('#qc_wpbotpro_floating_openai_keyword_rewrite_article').removeClass('spinning');
185 }
186 });
187
188
189 });
190
191 $(document).on('click', '.qc_wpbotpro_floating_openai_article_clear', function (e) {
192
193 $('#qc_wpbotpro_floating_openai_keyword_suggestion_mf').val('');
194 $('#qc_wpbotpro_floating_content_result_msg').val('');
195 $('.qcld_seo-playground-buttons').hide();
196 $('.qc_wpbotpro_floating_rewrite_result_count').hide();
197
198 });
199
200 $(document).on('keyup focusout','#qc_wpbotpro_floating_content_rewrite',function(event){
201 var currentDom = $(this);
202 $('.qc_wpbotpro_floating_content_rewrite_count').remove();
203 var words = $.trim(currentDom.val()).split(" ");
204 $('.qc_wpbotpro_floating_content_rewrite_count_wrap').html('<span class="qc_wpbotpro_floating_content_rewrite_count">'+words.length+'</span>');
205 });
206
207 $(document).on('keyup focusout','#qc_wpbotpro_floating_content_rewrite_result_msg',function(event){
208 var currentDomss = $(this);
209 var editor = tinyMCE.get('qc_wpbotpro_floating_content_rewrite_result_msg');
210 var basicEditor = true;
211 if ( $('#wp-qc_wpbotpro_floating_content_rewrite_result_msg-wrap').hasClass('tmce-active') && editor ) {
212 basicEditor = false;
213 }
214 if(basicEditor){
215 var wordsss = $.trim(currentDomss.val()).split(" ");
216 }else{
217 var datasssss = editor.setContent( );
218 var wordsss = $.trim(datasssss).split(" ");
219 }
220 $('.qc_wpbotpro_floating_rewrite_result_count_wrap .qc_wpbotpro_floating_rewrite_result_count').text(wordsss.length);
221 });
222
223 $(document).on('keyup focusout','#qc_wpbotpro_floating_content_result_msg',function(event){
224 var currentDoms = $(this);
225 var wordss = $.trim(currentDoms.val()).split(" ");
226 $('.qc_wpbotpro_floating_bait_single_field .qc_wpbotpro_floating_rewrite_result_count').text(wordss.length);
227 });
228
229 $(document).on('click','.qcld-copied-content',function(event){
230 var currentDom = $(this);
231 var copy_con = $('#qc_wpbotpro_floating_content_rewrite_result_msg').val();
232
233 var editor = tinyMCE.get('qc_wpbotpro_floating_content_rewrite_result_msg');
234 var basicEditor = true;
235 if ( $('#wp-qc_wpbotpro_floating_content_rewrite_result_msg-wrap').hasClass('tmce-active') && editor ) {
236 basicEditor = false;
237 }
238
239 if(!basicEditor){
240 var copy_con = editor.getContent();
241
242 }
243
244
245 $(this).addClass("qcld_copied");
246
247 $(".qcld_copied-content").removeClass("d-none");
248 setTimeout(() => {
249 $(".qcld_copied-content").addClass("d-none");
250 }, 1500);
251 var $temp = $("<input>");
252 //$("body").append($temp);
253 currentDom.append($temp);
254 $temp.val( copy_con ).select();
255 document.execCommand("copy");
256 $temp.remove();
257
258 });
259 $(document).on('click','.qcld-copied-content_text',function(event){
260 var currentDom = $(this);
261 var copy_con = currentDom.parent().parent().parent().find('#qc_wpbotpro_floating_content_result_msg').val();
262 var copy_text = (copy_con !== '') ? copy_con : currentDom.parent().parent().parent().find('#qc_wpbotpro_floating_content_result_msg').text();
263
264 var editor = tinyMCE.get('qc_wpbotpro_floating_content_result_msg');
265 var basicEditor = true;
266 if ( $('#wp-qc_wpbotpro_floating_content_result_msg-wrap').hasClass('tmce-active') && editor ) {
267 basicEditor = false;
268 }
269
270 if(!basicEditor){
271 var copy_text = editor.getContent();
272 }
273
274 currentDom.addClass("qcld_copied");
275
276 currentDom.parent().find(".qcld_copied-content_text").removeClass("d-none");
277 setTimeout(() => {
278 currentDom.parent().find(".qcld_copied-content_text").addClass("d-none");
279 }, 1500);
280
281 var $temp = $("<input>");
282 currentDom.append($temp);
283 $temp.val( copy_text ).select();
284 document.execCommand("copy");
285 $temp.remove();
286
287 });
288
289 var qc_wpbotpro_floating_generator_working = false;
290 var eventGenerator = false;
291 var qc_wpbotpro_floating_limitLines = 5;
292 function qcld_stopOpenAIGenerator(){
293 $('.qcld_seo-playground-buttons').show();
294 $('.qc_wpbotpro_floating_openai_generator_stop').hide();
295 qc_wpbotpro_floating_generator_working = false;
296 $('.qc_wpbotpro_floating_generator_button .spinner').hide();
297 $('.qc_wpbotpro_floating_generator_button').removeAttr('disabled');
298 //eventGenerator.close();
299 }
300 $(document).on('click', '.qc_wpbotpro_floating_openai_generator_stop', function (e) {
301 qcld_stopOpenAIGenerator();
302 });
303
304 $(document).on('click', '.qc_wpbotpro_floating_openai_generator_button', function (e) {
305 var btn = $(this);
306 var title = $('.qc_wpbotpro_floating_prompt').val();
307 if( title !== '' ) {
308 var count_line = 0;
309 var qc_wpbotpro_floating_generator_result = $('.qc_wpbotpro_floating_generator_result');
310 qc_wpbotpro_floating_generator_result.val('');
311 $('.qc_wpbotpro_floating_openai_generator_stop').show();
312 $('.qcld_seo-playground-buttons').hide();
313 $('.qc_wpbotpro_floating_openai_generator_button').addClass('spinning');
314
315 var editor = tinyMCE.get('qc_wpbotpro_floating_generator_result');
316 var basicEditor = true;
317 if ( $('#wp-qc_wpbotpro_floating_generator_result-wrap').hasClass('tmce-active') && editor ) {
318 basicEditor = false;
319 }
320 var qc_wpbotpro_floating_currentContent_Text = '';
321 //console.log( eventGenerator );
322
323 $.ajax({
324 url: qc_wpbotpro_floating_ajaxurl,
325 data: { title: title, action: 'qc_wpbotpro_floating_openai_qc_wpbotpro_content_generator_by_ajax', security: qc_wpbotpro_floating_ajax_nonce },
326 dataType: 'json',
327 type: 'POST',
328 beforeSend: function (){
329 btn.attr('disabled','disabled');
330 btn.find('.spinner').show();
331 btn.find('.spinner').css('visibility','unset');
332 },
333 success: function (res){
334 btn.removeAttr('disabled');
335 $('.qc_wpbotpro_floating_openai_generator_stop').hide();
336 $('.qc_wpbotpro_floating_openai_generator_button').removeClass('spinning');
337 //console.log( res)
338 if(res.status === 'success'){
339 //window.location.href;
340 $('.qcld_seo-playground-buttons').show();
341 if(basicEditor){
342 qc_wpbotpro_floating_currentContent_Text = $('#qc_wpbotpro_floating_generator_result').val();
343 }else{
344 qc_wpbotpro_floating_currentContent_Text = editor.getContent();
345 qc_wpbotpro_floating_currentContent_Text = qc_wpbotpro_floating_currentContent_Text.replace(/<\/?p(>|$)/g, "");
346 }
347 if(e.data === "[DONE]"){
348 count_line += 1;
349 if(basicEditor) {
350
351 $('#qc_wpbotpro_floating_generator_result').val( qc_wpbotpro_floating_currentContent_Text + '<br><br>' );
352
353 }else{
354
355 editor.setContent( qc_wpbotpro_floating_currentContent_Text + '<br><br>' );
356
357 }
358 } else{
359
360
361 if(basicEditor){
362
363 if(res.title){
364 $('.qc_wpbotpro_floating_prompt').val( res.title );
365 }
366 $('#qc_wpbotpro_floating_generator_result').val( res.data );
367
368 }else{
369 if(res.title){
370 $('.qc_wpbotpro_floating_prompt').val( res.title );
371 }
372 editor.setContent(qc_wpbotpro_floating_currentContent_Text+ res.data );
373
374 }
375
376
377 }
378
379 if(count_line === qc_wpbotpro_floating_limitLines){
380 qcld_stopOpenAIGenerator();
381 }
382
383
384
385
386 }else{
387 alert(res.msg);
388 }
389 },
390 error: function (){
391 btn.removeAttr('disabled');
392 btn.find('.spinner').remove();
393 $('.qc_wpbotpro_floating_openai_generator_stop').hide();
394 alert('Something went wrong');
395 }
396 });
397
398 }
399 });
400
401 $(document).on('click', '.qc_wpbotpro_floating_openai_playground_save', function (e) {
402 var qc_wpbotpro_floating_draft_btn = $(this);
403 var title = $('.qc_wpbotpro_floating_prompt').val();
404 var editor = tinyMCE.get('qc_wpbotpro_floating_generator_result');
405 var basicEditor = true;
406 if ( $('#wp-qc_wpbotpro_floating_generator_result-wrap').hasClass('tmce-active') && editor ) {
407 basicEditor = false;
408 }
409 var content = '';
410 if (basicEditor){
411 content = $('#qc_wpbotpro_floating_generator_result').val();
412 }else{
413 content = editor.getContent();
414 }
415 if(title === ''){
416 alert('Please enter title');
417 }
418 else if(content === ''){
419 alert('Please wait content generated');
420 }
421 else{
422 $.ajax({
423 url: ajaxurl,
424 data: {title: title, content: content, action: 'qc_wpbotpro_floating_openai_save_draft_post_extra', security: qc_wpbotpro_floating_ajax_nonce },
425 dataType: 'json',
426 type: 'POST',
427 beforeSend: function (){
428 qc_wpbotpro_floating_draft_btn.attr('disabled','disabled');
429 qc_wpbotpro_floating_draft_btn.append('<span class="spinner"></span>');
430 qc_wpbotpro_floating_draft_btn.find('.spinner').css('visibility','unset');
431 },
432 success: function (res){
433 qc_wpbotpro_floating_draft_btn.removeAttr('disabled');
434 qc_wpbotpro_floating_draft_btn.find('.spinner').remove();
435 if(res.status === 'success'){
436 //window.location.href;
437 window.location.replace( res.post_link );
438 }
439 else{
440 alert(res.msg);
441 }
442 },
443 error: function (){
444 qc_wpbotpro_floating_draft_btn.removeAttr('disabled');
445 qc_wpbotpro_floating_draft_btn.find('.spinner').remove();
446 alert('Something went wrong');
447 }
448 });
449 }
450 });
451 $(document).on('click', '.qc_wpbotpro_floating_openai_playground_clear', function (e) {
452
453 $('.qc_wpbotpro_floating_prompt').val('');
454 var editor = tinyMCE.get('qc_wpbotpro_floating_generator_result');
455 var basicEditor = true;
456 if ( $('#wp-qc_wpbotpro_floating_generator_result-wrap').hasClass('tmce-active') && editor ) {
457 basicEditor = false;
458 }
459 if(basicEditor){
460 $('#qc_wpbotpro_floating_generator_result').val('');
461 }
462 else{
463 editor.setContent('');
464 }
465 });
466
467 });
468
469 })(jQuery)