@@ -290,6 +290,26 @@ let isRecording = false;
290
290
let eventSource = null ;
291
291
let isScanning = false ;
292
292
293
+ // Function to update the filename timestamp periodically
294
+ function startTimestampUpdater ( ) {
295
+ updateFilenameTimestamp ( ) ;
296
+ setInterval ( updateFilenameTimestamp , 1000 ) ;
297
+ }
298
+
299
+ // Update the filename timestamp in the input field
300
+ function updateFilenameTimestamp ( ) {
301
+ // Only update if recording is stop
302
+ if ( ! isRecording ) {
303
+ const defaultName = `ChordsPy_${ getTimestamp ( ) } ` ;
304
+ filenameInput . placeholder = defaultName ;
305
+
306
+ // If the input is empty or has the default pattern, update the value too
307
+ if ( ! filenameInput . value || filenameInput . value . startsWith ( 'ChordsPy_' ) ) {
308
+ filenameInput . value = defaultName ;
309
+ }
310
+ }
311
+ }
312
+
293
313
// Function to generate timestamp for filename
294
314
function getTimestamp ( ) {
295
315
const now = new Date ( ) ;
@@ -335,6 +355,7 @@ function initializeFilename() {
335
355
filenameInput . disabled = false ; // Ensure input is enabled initially
336
356
filenameInput . classList . remove ( 'bg-gray-100' , 'dark:bg-gray-700' , 'cursor-not-allowed' ) ;
337
357
filenameInput . classList . add ( 'dark:bg-gray-800' ) ;
358
+ startTimestampUpdater ( ) ;
338
359
}
339
360
340
361
// Sanitize filename input - replace spaces and dots with underscores
@@ -728,6 +749,7 @@ function toggleRecording() {
728
749
filenameInput . disabled = false ;
729
750
filenameInput . classList . remove ( 'bg-gray-100' , 'dark:bg-gray-700' , 'cursor-not-allowed' ) ;
730
751
filenameInput . classList . add ( 'dark:bg-gray-800' ) ;
752
+ updateFilenameTimestamp ( )
731
753
showStatus ( 'Recording stopped' , 'fa-stop-circle' , 'text-red-500' ) ;
732
754
}
733
755
} )
0 commit comments