@@ -81,7 +81,8 @@ <h3>Settings</h3>
81
81
placeholder =""> You are a helpful assistant. Answer the user's questions but say 'I don't know that' if you don't know the answer.</ textarea >
82
82
< label for ="apiKey "> API Key</ label >
83
83
< input type ="text " id ="apiKey " name ="apiKey "
84
- placeholder ="sk-01234-put-your-api-key-here. It-is-not-stored-on-any-server. ">
84
+ placeholder ="sk-01234-put-your-api-key-here. It-is-not-stored-on-any-server. "
85
+ onblur ="maskInput() " onfocus ="unmaskInput() ">
85
86
< label for ="baseUrl "> Base URL (optional):</ label >
86
87
< input type ="text " id ="baseUrl " name ="baseUrl "
87
88
placeholder ="https://api.openai.com/v1/chat/completions "
@@ -196,6 +197,20 @@ <h3 class="mb-0">Chat</h3>
196
197
//}
197
198
) ;
198
199
200
+ // Mask the API key input
201
+ function maskInput ( ) {
202
+ var input = document . getElementById ( "apiKey" ) ;
203
+ if ( input . value !== "" ) {
204
+ input . type = "password" ; // Change to password to show bullets
205
+ }
206
+ }
207
+
208
+ // Unmask the API key input
209
+ function unmaskInput ( ) {
210
+ var input = document . getElementById ( "apiKey" ) ;
211
+ input . type = "text" ; // Change back to text to show input and placeholder
212
+ }
213
+
199
214
// set remember the api key to a local cookie
200
215
document . getElementById ( 'settingsForm' ) . addEventListener ( 'submit' , function ( e ) {
201
216
e . preventDefault ( ) ;
@@ -220,6 +235,7 @@ <h3 class="mb-0">Chat</h3>
220
235
}
221
236
if ( name . trim ( ) === 'apiKey' ) {
222
237
document . getElementById ( 'apiKey' ) . value = decodeURIComponent ( value ) ;
238
+ maskInput ( ) ;
223
239
}
224
240
if ( name . trim ( ) === 'baseUrl' ) {
225
241
document . getElementById ( 'baseUrl' ) . value = decodeURIComponent ( value ) ;
@@ -244,10 +260,10 @@ <h3 class="mb-0">Chat</h3>
244
260
245
261
// Export chat history and prompt to a text file
246
262
document . getElementById ( 'exportChatAndPrompt' ) . addEventListener ( 'click' , function ( ) {
247
- const exportData = { }
248
- exportData [ "history" ] = chatInstance . historyGetAllCopy ( ) ;
263
+ const exportData = { }
264
+ exportData [ "history" ] = chatInstance . historyGetAllCopy ( ) ;
249
265
exportData [ "prompt" ] = document . getElementById ( 'prompt' ) . value ;
250
-
266
+
251
267
const blob = new Blob ( [ JSON . stringify ( exportData , null , 2 ) ] , { type : 'application/json' } ) ;
252
268
const url = URL . createObjectURL ( blob ) ;
253
269
const dateTime = new Date ( ) . toISOString ( ) . replace ( / [: .] / g, '-' ) ;
0 commit comments