From 31c2aa5c6380bb27b69014ab545034a808dd6573 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sun, 16 Feb 2025 19:54:58 +0100 Subject: [PATCH 1/2] Fix js syntax error --- htdocs/core/class/html.formmail.class.php | 71 ++++++++++++----------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 21f064ba8ca..114c01ec5e1 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1579,49 +1579,50 @@ class FormMail extends Form CKEDITOR.instances.".$htmlContent.".setReadOnly(1); } - $.ajax({ - url: '". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."', - type: 'POST', - contentType: 'application/json', - data: JSON.stringify({ - 'format': '".dol_escape_js($format)."', /* the format for output */ - 'function': '".dol_escape_js($function)."', /* the AI feature to call */ - 'instructions': instructions, /* the prompt string */ - }), - success: function(response) { - console.log('Add response into field \'#".$htmlContent."\': '+response); + $.ajax({ + url: '". DOL_URL_ROOT."/ai/ajax/generate_content.php?token=".currentToken()."', + type: 'POST', + contentType: 'application/json', + data: JSON.stringify({ + 'format': '".dol_escape_js($format)."', /* the format for output */ + 'function': '".dol_escape_js($function)."', /* the AI feature to call */ + 'instructions': instructions, /* the prompt string */ + }), + success: function(response) { + console.log('Add response into field \'#".$htmlContent."\': '+response); - jQuery('#".$htmlContent."').val(response); // If #htmlcontent is a input name or textarea - jQuery('#".$htmlContent."').html(response); // If #htmlContent is a div - //jQuery('#".$htmlContent."preview').val(response); + jQuery('#".$htmlContent."').val(response); // If #htmlcontent is a input name or textarea + jQuery('#".$htmlContent."').html(response); // If #htmlContent is a div + //jQuery('#".$htmlContent."preview').val(response); - if (CKEDITOR.instances) { - var editorInstance = CKEDITOR.instances.".$htmlContent."; - if (editorInstance) { - editorInstance.setReadOnly(0); - editorInstance.setData(response); + if (CKEDITOR.instances) { + var editorInstance = CKEDITOR.instances.".$htmlContent."; + if (editorInstance) { + editorInstance.setReadOnly(0); + editorInstance.setData(response); + } + //var editorInstancepreview = CKEDITOR.instances.".$htmlContent."preview; + //if (editorInstancepreview) { + // editorInstancepreview.setData(response); + //} } - //var editorInstancepreview = CKEDITOR.instances.".$htmlContent."preview; - //if (editorInstancepreview) { - // editorInstancepreview.setData(response); - //} - } - // remove readonly - $('#ai_instructions".$htmlContent."').val(''); + // remove readonly + $('#ai_instructions".$htmlContent."').val(''); - apicallfinished = 1; - if (timeoutfinished) { + apicallfinished = 1; + if (timeoutfinished) { + $('#ai_status_message".$htmlContent."').hide(); + } + }, + error: function(xhr, status, error) { + alert(error); + console.error('error ajax', status, error); $('#ai_status_message".$htmlContent."').hide(); } - }, - error: function(xhr, status, error) { - alert(error); - console.error('error ajax', status, error); - $('#ai_status_message".$htmlContent."').hide(); - } - }); + }); + } }); }); From 824f4e06b5441469304858392e1c6385a5c565de Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Mon, 17 Feb 2025 02:27:36 +0100 Subject: [PATCH 2/2] Debug v21 smartphone --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index baec057484e..0a83062a908 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3353,7 +3353,7 @@ if (!GETPOST('hide_websitemenu')) { print ''; - print ''; + print ''; // Print nav arrows $pagepreviousid = 0;