From 31c2aa5c6380bb27b69014ab545034a808dd6573 Mon Sep 17 00:00:00 2001 From: ldestailleur Date: Sun, 16 Feb 2025 19:54:58 +0100 Subject: [PATCH] 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(); - } - }); + }); + } }); });