@@ -104,54 +104,71 @@ const scriptData = classifaiChatGPTData.enabledFeatures.reduce(
104
104
105
105
apiFetch ( {
106
106
path,
107
- } ) . then ( ( result ) => {
108
- generateTextEl . css ( 'opacity' , '1' ) ;
109
- spinnerEl . hide ( ) ;
110
- isProcessing = false ;
111
-
112
- result . forEach ( ( title ) => {
113
- $ ( '<textarea>' , {
114
- text : title ,
115
- } )
116
- . wrap ( `<div class="classifai-openai__result-item" />` )
117
- . parent ( )
118
- . append (
119
- $ ( '<button />' , {
120
- text : scriptData . title . selectBtnText ,
121
- type : 'button' ,
122
- class : 'button classifai-openai__select-title' ,
123
- } )
107
+ } )
108
+ . then ( ( result ) => {
109
+ generateTextEl . css ( 'opacity' , '1' ) ;
110
+ spinnerEl . hide ( ) ;
111
+ isProcessing = false ;
112
+
113
+ result . forEach ( ( title ) => {
114
+ $ ( '<textarea>' , {
115
+ text : title ,
116
+ } )
117
+ . wrap (
118
+ `<div class="classifai-openai__result-item" />`
119
+ )
120
+ . parent ( )
121
+ . append (
122
+ $ ( '<button />' , {
123
+ text : scriptData . title . selectBtnText ,
124
+ type : 'button' ,
125
+ class : 'button classifai-openai__select-title' ,
126
+ } )
127
+ )
128
+ . appendTo ( '#classifai-openai__results-content' ) ;
129
+ } ) ;
130
+
131
+ // Append disable feature link.
132
+ if (
133
+ ClassifAI ?. opt_out_enabled_features ?. includes (
134
+ 'feature_title_generation'
124
135
)
136
+ ) {
137
+ $ ( '<a>' , {
138
+ text : __ (
139
+ 'Disable this ClassifAI feature' ,
140
+ 'classifai'
141
+ ) ,
142
+ href : ClassifAI ?. profile_url ,
143
+ target : '_blank' ,
144
+ rel : 'noopener noreferrer' ,
145
+ class : 'classifai-disable-feature-link' ,
146
+ } )
147
+ . wrap (
148
+ `<div class="classifai-openai__result-disable-link" />`
149
+ )
150
+ . parent ( )
151
+ . appendTo ( '#classifai-openai__modal' ) ;
152
+ }
153
+
154
+ $ ( '#classifai-openai__results' )
155
+ . show ( )
156
+ . addClass ( 'classifai-openai--fade-in' ) ;
157
+ } )
158
+ . catch ( ( error ) => {
159
+ generateTextEl . css ( 'opacity' , '1' ) ;
160
+ spinnerEl . hide ( ) ;
161
+ isProcessing = false ;
162
+
163
+ $ ( '<span class="error">' )
164
+ . text ( error ?. message )
165
+ . wrap ( `<div class="classifai-openai__result-item" />` )
125
166
. appendTo ( '#classifai-openai__results-content' ) ;
126
- } ) ;
127
167
128
- // Append disable feature link.
129
- if (
130
- ClassifAI ?. opt_out_enabled_features ?. includes (
131
- 'feature_title_generation'
132
- )
133
- ) {
134
- $ ( '<a>' , {
135
- text : __ (
136
- 'Disable this ClassifAI feature' ,
137
- 'classifai'
138
- ) ,
139
- href : ClassifAI ?. profile_url ,
140
- target : '_blank' ,
141
- rel : 'noopener noreferrer' ,
142
- class : 'classifai-disable-feature-link' ,
143
- } )
144
- . wrap (
145
- `<div class="classifai-openai__result-disable-link" />`
146
- )
147
- . parent ( )
148
- . appendTo ( '#classifai-openai__modal' ) ;
149
- }
150
-
151
- $ ( '#classifai-openai__results' )
152
- . show ( )
153
- . addClass ( 'classifai-openai--fade-in' ) ;
154
- } ) ;
168
+ $ ( '#classifai-openai__results' )
169
+ . show ( )
170
+ . addClass ( 'classifai-openai--fade-in' ) ;
171
+ } ) ;
155
172
} ;
156
173
157
174
// Event handler registration to generate the title.
0 commit comments