Skip to content

Commit 409ea22

Browse files
committed
CSV Filename timer update regularly
1 parent cde94b3 commit 409ea22

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

static/script.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,26 @@ let isRecording = false;
290290
let eventSource = null;
291291
let isScanning = false;
292292

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+
293313
// Function to generate timestamp for filename
294314
function getTimestamp() {
295315
const now = new Date();
@@ -335,6 +355,7 @@ function initializeFilename() {
335355
filenameInput.disabled = false; // Ensure input is enabled initially
336356
filenameInput.classList.remove('bg-gray-100', 'dark:bg-gray-700', 'cursor-not-allowed');
337357
filenameInput.classList.add('dark:bg-gray-800');
358+
startTimestampUpdater();
338359
}
339360

340361
// Sanitize filename input - replace spaces and dots with underscores
@@ -728,6 +749,7 @@ function toggleRecording() {
728749
filenameInput.disabled = false;
729750
filenameInput.classList.remove('bg-gray-100', 'dark:bg-gray-700', 'cursor-not-allowed');
730751
filenameInput.classList.add('dark:bg-gray-800');
752+
updateFilenameTimestamp()
731753
showStatus('Recording stopped', 'fa-stop-circle', 'text-red-500');
732754
}
733755
})

0 commit comments

Comments
 (0)