1+ console . log ( 'captchetat-widget.js' )
12
23/**
34 * @param {HTMLElement } container
@@ -40,21 +41,26 @@ export const addLinksToHead = container => {
4041
4142// Define captchaEtat object
4243export const captchaEtat = ( function ( ) {
44+ console . log ( 'captchetat-widget.js captchaEtat' )
4345 function _init ( container = document ) {
46+ console . log ( 'captchetat-widget.js init()' )
4447 const widgets = container . querySelectorAll ( '.js-captcha-widget' ) ;
4548
4649 for ( const widget of widgets ) {
4750 const htmlContainer = widget . querySelector ( '.captcha-html-container' ) ;
51+ console . log ( 'htmlContainer ::' , htmlContainer ) ;
4852 const idInput = widget . querySelector ( '.captcha-input [name*="[captcha_id]"]' ) ;
53+ console . log ( 'idInput ::' , idInput ) ;
54+
4955 if ( htmlContainer . querySelector ( '.captcha-html' ) ) {
5056 return ;
5157 }
5258
5359 fetch ( '/api/simple-captcha' ) . then ( ( response ) => {
5460 console . log ( 'response ::' , response ) ;
5561 return response . text ( ) ;
56- } ) . then ( ( html ) => {
57-
62+ } ) . then ( ( data ) => {
63+ console . log ( 'data ::' , data ) ;
5864 //__________________ add img tag
5965 const parsedData = JSON . parse ( html ) ;
6066 const imageBase64 = parsedData . imageb64 ;
@@ -65,7 +71,9 @@ export const captchaEtat = (function () {
6571 img . classList = "captch-etat-v2" ;
6672 console . log ( 'imageBase64' , imageBase64 ) ;
6773 console . log ( 'img' , img ) ;
68- document . getElementById ( 'form-fre-FR-438825-1795842_fields_captcha' ) . appendChild ( img ) ;
74+
75+ let parent = htmlContainer
76+ htmlContainer . appendChild ( img ) ;
6977 console . log ( 'okkk ::' ) ;
7078 //__________________ add img tag
7179
0 commit comments