PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.8.4
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.8.4
8.8.4 8.8.3 8.8.2 8.8.1 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 All 540 releases
← All changes | includes/integration/grok/js/qcld-wp-grok-admin.js +169 -159 8.6.2 → 8.8.4 View file →
@@ -1,160 +1,170 @@
1 -jQuery(document).ready(function($) {
2 - // Function to fetch models from OpenRouter API
3 - var settingsOpenrouter = document.getElementById("qcld_save_grok_setting");
4 - if(settingsOpenrouter){
5 - $('.qcl-openai').on('click', '#qcld_save_grok_setting', function(event){
6 - event.preventDefault();
7 - if ($('#qcld_grok_enabled').is(":checked")){
8 - var grok_enabled = 1;
9 - }else{
10 - var grok_enabled = 0;
11 - }
12 - if ($('#qcld_grok_rag_enabled').is(":checked")){
13 - var grok_rag_enabled = 1;
14 - }else{
15 - var grok_rag_enabled = 0;
16 - }
17 - var qcld_grok_page_suggestion_enabled = jQuery("#qcld_grok_page_suggestion_enabled").is(":checked") ? 1 : 0;
18 - var qcld_grok_api_key = jQuery("#qcld_grok_api_key").val();
19 - var qcld_grok_model = jQuery('#qcld_grok_model').val();
20 - var post_grok_types = $.map($('input[name="site_grok_search_posttypes[]"]:checked'), function(c){return c.value; });
21 - $.ajax({
22 - url: ajax_object.ajax_url,
23 - type:'POST',
24 - data: {
25 - action: 'qcld_grok_settings_option',
26 - nonce: ajax_object.ajax_nonce,
27 - grok_api_key: qcld_grok_api_key,
28 - grok_management_api_key: jQuery("#qcld_grok_management_api_key").val(),
29 - grok_model: qcld_grok_model,
30 - grok_enabled: grok_enabled,
31 - grok_collection_id: jQuery("#qcld_grok_collection_id").val(),
32 - grok_stream_enabled: jQuery("#qcld_grok_stream_enabled").is(":checked") ? 1 : 0,
33 - grok_rag_enabled: grok_rag_enabled,
34 - qcld_grok_system_content: jQuery("#qcld_grok_system_content").val(),
35 - qcld_grok_page_suggestion_enabled: qcld_grok_page_suggestion_enabled,
36 - openai_post_type:post_grok_types
37 - },
38 - success: function(data){
39 - $('#result').html(data);
40 - Swal.fire({
41 - title: 'Your settings are saved.',
42 - html: '<p style=font-size:14px>Please clear your browser <b>cache</b> and <b>cookies</b> both and reload the front end before testing. Alternatively, you can launch a new browser window in <b>Incognito</b>/Private mode (Ctrl+Shift+N in chrome) to test.</p>',
43 - width: 450,
44 - icon: 'success',
45 - confirmButtonText: 'Yes',
46 - confirmButtonWidth: 100,
47 - confirmButtonClass: 'btn btn-lg'
48 - }).then((result) => {
49 - if (result.isConfirmed) {
50 - $.ajax({
51 - url: ajax_object.ajax_url,
52 - type: 'POST',
53 - data: {
54 - action: 'update_settings_option',
55 - nonce: ajax_object.ajax_nonce,
56 - disable_ss: 1
57 - },
58 -
59 - });
60 - }
61 - });
62 - }
63 - });
64 - });
65 - $('.qcl-openai').on('click', '#add_grok_collection', function(event) {
66 - event.preventDefault();
67 - event.stopImmediatePropagation();
68 - event.stopPropagation();
69 - $.ajax({
70 - url: ajax_object.ajax_url,
71 - type:'POST',
72 - data: {
73 - action: 'qcld_grok_add_collection',
74 - nonce: ajax_object.ajax_nonce,
75 - },
76 - success: function(response){
77 - alert('New collection added successfully.');
78 - loadGrokCollections();
79 - }
80 - });
81 - });
82 - $('.qcl-openai').on('click', '.remove_grok_collection', function( event ) {
83 - event.preventDefault();
84 - event.stopImmediatePropagation();
85 - event.stopPropagation();
86 - var collection_id = $(this).data('id');
87 - if (confirm('Are you sure you want to remove this collection?')) {
88 - $.ajax({
89 - url: ajax_object.ajax_url,
90 - type:'POST',
91 - data: {
92 - action: 'qcld_grok_remove_collection',
93 - nonce: ajax_object.ajax_nonce,
94 - collection_id: collection_id
95 - },
96 - success: function( response ){
97 - console.log( JSON.parse( response ).response );
98 - loadGrokCollections();
99 - }
100 - });
101 - }
102 - });
103 - $.ajax({
104 - url: ajax_object.ajax_url,
105 - type:'POST',
106 - data: {
107 - action: 'qcld_grok_collectionlist',
108 - nonce: ajax_object.ajax_nonce,
109 - },
110 - success: function(response){
111 - var data = JSON.parse(response).collections;
112 - var text = "";
113 - data.forEach(function (item) {
114 - text += '<tr><td>' + item.collection_name + '</td><td>' + item.collection_id + '<form class="file_form_gpt" data-collection="' + item.collection_id + '"><input type="file" class="inputfile" id="grokfileinput_gpt" /><label for="grokfileinput_gpt" class="huge ui grey button"><i class="fa fa-upload"></i>Upload CSV/PDF/JSON</label></form></td><td><a class="btn-danger btn floated remove_grok_collection" data-id="' + item.collection_id + '">Remove</a></td></tr>';
115 - });
116 - document.getElementById("grokFileList").innerHTML = text;
117 - }
118 - });
119 - jQuery('.table-responsive').on('change','#grokfileinput_gpt', function() {
120 - var file_data = $(this).prop('files')[0];
121 - if (!file_data) return; // Exit if no file was selected
122 -
123 - var form_data = new FormData();
124 - form_data.append('file', file_data);
125 - form_data.append('name', file_data.name);
126 - form_data.append('collection_id', $(this).parent().attr('data-collection'));
127 - form_data.append('action', 'qcld_grok_file_upload');
128 - form_data.append('purpose', 'assistant');
129 - form_data.append('nonce', ajax_object.ajax_nonce);
130 - $.ajax({
131 - url: ajax_object.ajax_url,
132 - type: 'POST',
133 - data: form_data,
134 - processData: false, // Critical
135 - contentType: false, // Critical
136 - success: function(response) {
137 - console.log('Upload successful', response);
138 - }
139 - });
140 - })
141 - function loadGrokCollections() {
142 - $.ajax({
143 - url: ajax_object.ajax_url,
144 - type:'POST',
145 - data: {
146 - action: 'qcld_grok_collectionlist',
147 - nonce: ajax_object.ajax_nonce,
148 - },
149 - success: function(response){
150 - var data = JSON.parse(response).collections;
151 - var text = "";
152 - data.forEach(function (item) {
153 - text += '<tr><td>' + item.collection_name + '</td><td>' + item.collection_id + '<form class="file_grok_form" data-collection="'+ item.collection_id + '"><input type="file" (change)="fileEvent($event)" class="inputfile" id="grokfileinput" style="display:none"/></form><form class="file_form_gpt" data-collection="' + item.collection_id + '"><input type="file" (change)="fileEvent($event)" class="inputfile" id="grokfileinput_gpt" style="display:none"/><label for="grokfileinput_gpt" class="huge ui grey button"><i class="fa fa-upload"></i>Upload CSV/PDF/JSON</label></form></td><td><a class="btn-danger btn floated remove_grok_collection" data-id="' + item.collection_id + '">Remove</a></td></tr>';
154 - });
155 - document.getElementById("grokFileList").innerHTML = text;
156 - }
157 - });
158 - }
159 - }
1 +jQuery(document).ready(function($) {
2 + // Function to fetch models from OpenRouter API
3 + var settingsOpenrouter = document.getElementById("qcld_save_grok_setting");
4 + if(settingsOpenrouter){
5 + $('.qcl-openai').on('click', '#qcld_save_grok_setting', function(event){
6 + event.preventDefault();
7 + if ($('#qcld_grok_enabled').is(":checked")){
8 + var grok_enabled = 1;
9 + }else{
10 + var grok_enabled = 0;
11 + }
12 + if ($('#qcld_grok_rag_enabled').is(":checked")){
13 + var grok_rag_enabled = 1;
14 + }else{
15 + var grok_rag_enabled = 0;
16 + }
17 + var qcld_grok_page_suggestion_enabled = jQuery("#qcld_grok_page_suggestion_enabled").is(":checked") ? 1 : 0;
18 + var qcld_grok_api_key = jQuery("#qcld_grok_api_key").val();
19 + var qcld_grok_model = jQuery('#qcld_grok_model').val();
20 + var post_grok_types = $.map($('input[name="site_grok_search_posttypes[]"]:checked'), function(c){return c.value; });
21 + Swal.fire({
22 + html: '<div class="qcld-save-settings-spinner"></div>',
23 + allowOutsideClick: false,
24 + allowEscapeKey: false,
25 + showConfirmButton: false,
26 + background: 'transparent',
27 + customClass: {
28 + popup: 'qcld-swal-loading-only'
29 + }
30 + });
31 + $.ajax({
32 + url: ajax_object.ajax_url,
33 + type:'POST',
34 + data: {
35 + action: 'qcld_grok_settings_option',
36 + nonce: ajax_object.ajax_nonce,
37 + grok_api_key: qcld_grok_api_key,
38 + grok_management_api_key: jQuery("#qcld_grok_management_api_key").val(),
39 + grok_model: qcld_grok_model,
40 + grok_enabled: grok_enabled,
41 + grok_collection_id: jQuery("#qcld_grok_collection_id").val(),
42 + grok_stream_enabled: jQuery("#qcld_grok_stream_enabled").is(":checked") ? 1 : 0,
43 + grok_rag_enabled: grok_rag_enabled,
44 + qcld_grok_system_content: jQuery("#qcld_grok_system_content").val(),
45 + qcld_grok_page_suggestion_enabled: qcld_grok_page_suggestion_enabled,
46 + openai_post_type:post_grok_types
47 + },
48 + success: function(data){
49 + $('#result').html(data);
50 + Swal.fire({
51 + title: 'Your settings are saved.',
52 + html: '<p style=font-size:14px>Please clear your browser <b>cache</b> and <b>cookies</b> both and reload the front end before testing. Alternatively, you can launch a new browser window in <b>Incognito</b>/Private mode (Ctrl+Shift+N in chrome) to test.</p>',
53 + width: 450,
54 + icon: 'success',
55 + confirmButtonText: 'Yes',
56 + confirmButtonWidth: 100,
57 + confirmButtonClass: 'btn btn-lg'
58 + }).then((result) => {
59 + if (result.isConfirmed) {
60 + $.ajax({
61 + url: ajax_object.ajax_url,
62 + type: 'POST',
63 + data: {
64 + action: 'update_settings_option',
65 + nonce: ajax_object.ajax_nonce,
66 + disable_ss: 1
67 + },
68 +
69 + });
70 + }
71 + });
72 + }
73 + });
74 + });
75 + $('.qcl-openai').on('click', '#add_grok_collection', function(event) {
76 + event.preventDefault();
77 + event.stopImmediatePropagation();
78 + event.stopPropagation();
79 + $.ajax({
80 + url: ajax_object.ajax_url,
81 + type:'POST',
82 + data: {
83 + action: 'qcld_grok_add_collection',
84 + nonce: ajax_object.ajax_nonce,
85 + },
86 + success: function(response){
87 + alert('New collection added successfully.');
88 + loadGrokCollections();
89 + }
90 + });
91 + });
92 + $('.qcl-openai').on('click', '.remove_grok_collection', function( event ) {
93 + event.preventDefault();
94 + event.stopImmediatePropagation();
95 + event.stopPropagation();
96 + var collection_id = $(this).data('id');
97 + if (confirm('Are you sure you want to remove this collection?')) {
98 + $.ajax({
99 + url: ajax_object.ajax_url,
100 + type:'POST',
101 + data: {
102 + action: 'qcld_grok_remove_collection',
103 + nonce: ajax_object.ajax_nonce,
104 + collection_id: collection_id
105 + },
106 + success: function( response ){
107 + console.log( JSON.parse( response ).response );
108 + loadGrokCollections();
109 + }
110 + });
111 + }
112 + });
113 + $.ajax({
114 + url: ajax_object.ajax_url,
115 + type:'POST',
116 + data: {
117 + action: 'qcld_grok_collectionlist',
118 + nonce: ajax_object.ajax_nonce,
119 + },
120 + success: function(response){
121 + var data = JSON.parse(response).collections;
122 + var text = "";
123 + data.forEach(function (item) {
124 + text += '<tr><td>' + item.collection_name + '</td><td>' + item.collection_id + '<form class="file_form_gpt" data-collection="' + item.collection_id + '"><input type="file" class="inputfile" id="grokfileinput_gpt" /><label for="grokfileinput_gpt" class="huge ui grey button"><i class="fa fa-upload"></i>Upload CSV/PDF/JSON</label></form></td><td><a class="btn-danger btn floated remove_grok_collection" data-id="' + item.collection_id + '">Remove</a></td></tr>';
125 + });
126 + document.getElementById("grokFileList").innerHTML = text;
127 + }
128 + });
129 + jQuery('.table-responsive').on('change','#grokfileinput_gpt', function() {
130 + var file_data = $(this).prop('files')[0];
131 + if (!file_data) return; // Exit if no file was selected
132 +
133 + var form_data = new FormData();
134 + form_data.append('file', file_data);
135 + form_data.append('name', file_data.name);
136 + form_data.append('collection_id', $(this).parent().attr('data-collection'));
137 + form_data.append('action', 'qcld_grok_file_upload');
138 + form_data.append('purpose', 'assistant');
139 + form_data.append('nonce', ajax_object.ajax_nonce);
140 + $.ajax({
141 + url: ajax_object.ajax_url,
142 + type: 'POST',
143 + data: form_data,
144 + processData: false, // Critical
145 + contentType: false, // Critical
146 + success: function(response) {
147 + console.log('Upload successful', response);
148 + }
149 + });
150 + })
151 + function loadGrokCollections() {
152 + $.ajax({
153 + url: ajax_object.ajax_url,
154 + type:'POST',
155 + data: {
156 + action: 'qcld_grok_collectionlist',
157 + nonce: ajax_object.ajax_nonce,
158 + },
159 + success: function(response){
160 + var data = JSON.parse(response).collections;
161 + var text = "";
162 + data.forEach(function (item) {
163 + text += '<tr><td>' + item.collection_name + '</td><td>' + item.collection_id + '<form class="file_grok_form" data-collection="'+ item.collection_id + '"><input type="file" (change)="fileEvent($event)" class="inputfile" id="grokfileinput" style="display:none"/></form><form class="file_form_gpt" data-collection="' + item.collection_id + '"><input type="file" (change)="fileEvent($event)" class="inputfile" id="grokfileinput_gpt" style="display:none"/><label for="grokfileinput_gpt" class="huge ui grey button"><i class="fa fa-upload"></i>Upload CSV/PDF/JSON</label></form></td><td><a class="btn-danger btn floated remove_grok_collection" data-id="' + item.collection_id + '">Remove</a></td></tr>';
164 + });
165 + document.getElementById("grokFileList").innerHTML = text;
166 + }
167 + });
168 + }
169 + }
160 170 });